64 lines
2.3 KiB
Bash
64 lines
2.3 KiB
Bash
#! /bin/bash
|
|
|
|
# make sure the upload folder exists and is writeable by www-data
|
|
# do not make any changes to an already existing folder
|
|
|
|
if [ ! -e /var/lib/swarmops/upload ]; then
|
|
mkdir -p /var/lib/swarmops/upload
|
|
chown www-data:www-data /var/lib/swarmops/upload
|
|
chmod 777 /var/lib/swarmops/upload
|
|
|
|
# # If there's only 000-default in apache sites, assume new install
|
|
|
|
if "$(ls -l /etc/apache2/sites-enabled/ | wc -l)" = "2" ; then
|
|
|
|
exec 3>&1;
|
|
dialog_selection=$(dialog --title "Autoconfigure Apache?" --menu "This seems to be a new installation of Swarmops Frontend on a newly installed Apache. Would you like to create the necessary site directives and make it the default Apache site?" 0 0 3 1 "No thanks, don't touch my Apache, that's for me alone" 2 "Yes please, make Swarmops the default site for port 80" 3 "Create a Swarmops config, please, but don't enable it" 2>&1 1>&3);
|
|
exec 3>&-;
|
|
|
|
case "$dialog_selection" in
|
|
1 ) echo "Neither reconfiguring Apache nor creating configuration file."
|
|
;;
|
|
2 ) echo "Disabling site 000-default; creating/enabling site 000-swarmops."
|
|
a2dissite 000-default
|
|
cp /usr/share/swarmops/frontend/apache-default-config.txt /etc/apache2/sites-available/000-swarmops.conf
|
|
a2ensite 000-swarmops
|
|
|
|
# # Forcing a stop/start cycle because of install dependency fuckups
|
|
|
|
/etc/init.d/apache2 stop
|
|
/etc/init.d/apache2 start
|
|
;;
|
|
3 ) echo "Creating but not enabling 000-swarmops."
|
|
cp /usr/share/swarmops/frontend/apache-default-config.txt /etc/apache2/sites-available/000-swarmops.conf
|
|
;;
|
|
* ) echo "Unknown return code - $dialog_selection"
|
|
;;
|
|
|
|
esac
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
# make sure the web frontend (and its init routine) can write to machineKey.config
|
|
# TODO: add test here - only chown if it's the pristine, unedited file
|
|
|
|
chown www-data:www-data /etc/swarmops/machineKey.config
|
|
|
|
# make sure the web frontend (and its init) can write to database.config
|
|
|
|
chown www-data:www-data /etc/swarmops/database.config
|
|
|
|
# make sure the web frontend (and its init) can write to symmetricKey.config
|
|
|
|
chown www-data:www-data /etc/swarmops/symmetricKey.config
|
|
|
|
# if we stopped Apache in preinst (1st install), restart it
|
|
|
|
if [ -e /tmp/swarmops-restart-apache.flag ]; then
|
|
/etc/init.d/apache2 start
|
|
rm /tmp/swarmops-restart-apache.flag
|
|
fi
|
|
|