Last active
August 3, 2025 20:50
-
-
Save Mr-Bossman/c7b90995deb348358053c61c56831fd3 to your computer and use it in GitHub Desktop.
Read-only filesystem support for Nginx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
do_install() { | |
cat <<EOF > /etc/systemd/system/ronginx.service | |
[Unit] | |
Description=Read-only filesystem support for Nginx | |
After=tmp.mount | |
[Service] | |
Type=oneshot | |
ExecStart=/bin/ronginx run | |
[Install] | |
WantedBy=multi-user.target | |
RequiredBy=nginx.service | |
EOF | |
mv "$0" /bin/ronginx | |
systemctl enable ronginx.service | |
} | |
run() { | |
chown -R www-data:www-data /var/lib/nginx || true | |
} | |
help() { | |
echo To allow Nginx to run on read-only filesystem run: | |
echo "$0" run | |
echo To install this service run: | |
echo "$0" install | |
} | |
case "$1" in | |
"install") | |
do_install | |
;; | |
"run") | |
run | |
;; | |
*) | |
help | |
;; | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment