#!/bin/bash DOWNLOADLINK="https://r.mistserver.org/dl/mistserver_64V3.3.tar.gz" if [ "`whoami`" != "root" ]; then echo "Must be root to install" exit fi echo Downloading and installing binaries curl -L -s -o - $DOWNLOADLINK | tar -C /usr/bin/ -xvz if [ "$?" != "0" ]; then echo "Download and install failed, please verify internet connectivity or contact support." exit fi if pgrep MistController >/dev/null ; then if kill -s USR1 `pgrep -o MistController` ; then echo "Update complete" else echo "Update installed, but MistServer will have to be manually restarted" fi exit fi LINE=`stat /proc/1/exe | sed -n 1p | cut -d'>' -s -f2` #using $? to determine systemd or init if echo $LINE | grep -q systemd; then echo "detected systemd" if curl -L -s -o "/etc/systemd/system/mistserver.service" "https://mistserver.org/mistserver.service" ; then systemctl enable mistserver && echo "Successfully installed MistServer using systemd. Starting MistServer." && systemctl start mistserver && exit echo "Something went wrong. Please install manually or contact support." else echo "Download of systemd service failed, please verify internet connectivity or contact support." exit fi else echo "detected init" if curl -L -s -o "/etc/init.d/mistserver" "https://mistserver.org/mistserver.init" ; then chmod +x "/etc/init.d/mistserver" if which chkconfig ; then chkconfig mistserver on && echo "Successfully installed MistServer using init. Starting MistServer." && service mistserver start && exit fi if which update-rc.d ; then echo "detected upstart ( = older ubuntu versions)" update-rc.d mistserver start 42 2 3 4 5 . stop 42 0 1 6 . && update-rc.d mistserver defaults && echo "Successfully installed MistServer using upstart (init). Starting MistServer." && service mistserver start && exit fi echo "Something went wrong. Please install manually or contact support." else echo "Download of init script failed, please verify internet connectivity or contact support." exit fi fi