aboutsummaryrefslogtreecommitdiff
path: root/mod/lorea-status/install.sh
diff options
context:
space:
mode:
Diffstat (limited to 'mod/lorea-status/install.sh')
-rwxr-xr-xmod/lorea-status/install.sh74
1 files changed, 74 insertions, 0 deletions
diff --git a/mod/lorea-status/install.sh b/mod/lorea-status/install.sh
new file mode 100755
index 000000000..c4a50c17e
--- /dev/null
+++ b/mod/lorea-status/install.sh
@@ -0,0 +1,74 @@
+#!/bin/sh
+#
+# Install status.lorea.org website and activate it
+#
+
+INSTALL_DIR=/usr/local
+DOMAIN=status.lorea.org
+
+# Sanity check
+if [ ! -d ./bin -o ! -f ./bin/lorea_refresh_status ] ; then
+ echo "This script must run from the source tree."
+ exit 1
+fi
+if [ $(id -un) != 'root' ] ; then
+ echo "This script must be run by root."
+ exit 1
+fi
+if [ ! -x /bin/zsh ] ; then
+ echo "*warning* Package zsh is not installed."
+ echo -n "Do you want to install it now? [yN] "
+ read -s
+ case $REPLY in
+ [Yy]*)
+ apt-get install zsh
+ ;;
+ *)
+ echo "OK, don't forget to install it!"
+ ;;
+ esac
+fi
+if [ ! -x /usr/sbin/nginx ] ; then
+ echo "*warning* Package nginx is not installed."
+ echo -n "Do you want to install it now? [yN] "
+ read -s
+ case $REPLY in
+ [Yy]*)
+ apt-get install nginx
+ ;;
+ *)
+ echo "OK, don't forget to install it!"
+ ;;
+ esac
+fi
+
+# Install script
+install -m 0755 ./bin/lorea_refresh_status $INSTALL_DIR/bin
+install -m 0755 ./etc/lorea-status /etc/default
+
+# Install web
+mkdir -p /var/www/$DOMAIN/pub
+chown www-data:www-data /var/www/$DOMAIN/pub
+for file in index.html status.css status.js jquery.js ; do
+ install -C -D -m 0644 -t /var/www/$DOMAIN ./www/$file
+done
+
+# Configure Nginx
+install -C -D -m 0644 ./etc/status.lorea.org /etc/nginx/sites-available
+ln -sf /etc/nginx/sites-available/status.lorea.org /etc/nginx/sites-enabled
+
+# Install crontab
+install -m 0644 ./etc/crontab /etc/cron.d/lorea_refresh_status
+
+# Bootstrap JSON data
+su - www-data -c "$INSTALL_DIR/bin/lorea_refresh_status"
+
+# Wrap up
+if [ -x /usr/sbin/nginx ] ; then
+ nginx_status=$(/etc/init.d/nginx status)
+ if [ "$nginx_status" = "nginx is running." ] ; then
+ /etc/init.d/nginx reload
+ else
+ echo "Nginx not running: not reloaded."
+ fi
+fi