Skip to content
Snippets Groups Projects
Commit 1b9422c5 authored by Bob Mottram's avatar Bob Mottram
Browse files

Separate static content directory

parent 1583df53
No related branches found
No related tags found
No related merge requests found
...@@ -154,6 +154,7 @@ function upgrade_etesync { ...@@ -154,6 +154,7 @@ function upgrade_etesync {
pip3 install -U -r requirements.txt uwsgi pip3 install -U -r requirements.txt uwsgi
python3 manage.py migrate python3 manage.py migrate
chown -R etesync:etesync /etc/etesync chown -R etesync:etesync /etc/etesync
chown -R www-data:www-data "/var/www/$ETESYNC_DOMAIN_NAME/htdocs"
systemctl restart etesync systemctl restart etesync
} }
...@@ -163,15 +164,18 @@ function backup_local_etesync { ...@@ -163,15 +164,18 @@ function backup_local_etesync {
ETESYNC_DOMAIN_NAME=$(get_completion_param "etesync domain") ETESYNC_DOMAIN_NAME=$(get_completion_param "etesync domain")
fi fi
source_directory=/etc/etesync
suspend_site "${ETESYNC_DOMAIN_NAME}" suspend_site "${ETESYNC_DOMAIN_NAME}"
systemctl stop etesync systemctl stop etesync
source_directory=/etc/etesync
dest_directory=etesync dest_directory=etesync
backup_directory_to_usb "$source_directory" $dest_directory backup_directory_to_usb "$source_directory" $dest_directory
source_directory="/var/www/$ETESYNC_DOMAIN_NAME/htdocs"
dest_directory=etesyncstatic
backup_directory_to_usb "$source_directory" $dest_directory
restart_site restart_site
systemctl start etesync systemctl start etesync
} }
...@@ -203,6 +207,24 @@ function restore_local_etesync { ...@@ -203,6 +207,24 @@ function restore_local_etesync {
chown -R etesync:etesync "$etesync_dir" chown -R etesync:etesync "$etesync_dir"
rm -rf $temp_restore_dir rm -rf $temp_restore_dir
fi fi
temp_restore_dir=/root/tempetesyncstatic
etesync_dir="/var/www/$ETESYNC_DOMAIN_NAME/htdocs"
restore_directory_from_usb $temp_restore_dir etesync
if [ -d $temp_restore_dir ]; then
if [ -d "$temp_restore_dir$etesync_dir" ]; then
cp -rp "$temp_restore_dir$etesync_dir"/* "$etesync_dir"/
else
if [ ! -d "$etesync_dir" ]; then
mkdir "$etesync_dir"
fi
cp -rp "$temp_restore_dir"/* "$etesync_dir"/
fi
chown -R www-data:www-data "$etesync_dir"
rm -rf $temp_restore_dir
fi
systemctl start etesync systemctl start etesync
restart_site restart_site
...@@ -317,6 +339,8 @@ function install_etesync { ...@@ -317,6 +339,8 @@ function install_etesync {
sed -i "s|ALLOWED_HOSTS =.*|ALLOWED_HOSTS = [ '${ETESYNC_DOMAIN_NAME}', '${ETESYNC_ONION_HOSTNAME}' ]|g" /etc/etesync/etesync_server/settings.py sed -i "s|ALLOWED_HOSTS =.*|ALLOWED_HOSTS = [ '${ETESYNC_DOMAIN_NAME}', '${ETESYNC_ONION_HOSTNAME}' ]|g" /etc/etesync/etesync_server/settings.py
sed -i "s|STATIC_ROOT =.*|STATIC_ROOT = os.environ.get('DJANGO_STATICS','/var/www/$ETESYNC_DOMAIN_NAME/htdocs')|g" /etc/etesync/etesync_server/settings.py
pip3 install -r requirements.txt uwsgi pip3 install -r requirements.txt uwsgi
python3 manage.py migrate python3 manage.py migrate
...@@ -398,6 +422,9 @@ function install_etesync { ...@@ -398,6 +422,9 @@ function install_etesync {
echo 'WorkingDirectory=/etc/etesync'; echo 'WorkingDirectory=/etc/etesync';
echo "ExecStart=/usr/bin/python3 /etc/etesync/manage.py runserver localhost:${ETESYNC_PORT_INTERNAL}"; echo "ExecStart=/usr/bin/python3 /etc/etesync/manage.py runserver localhost:${ETESYNC_PORT_INTERNAL}";
echo 'Environment=USER=etesync'; echo 'Environment=USER=etesync';
echo "Environment=DJANGO_STATICS=/var/www/$ETESYNC_DOMAIN_NAME/htdocs";
echo "Environment=DJANGO_PORT=${ETESYNC_PORT_INTERNAL}";
echo 'Environment=SERVER="standalone"';
echo 'Restart=always'; echo 'Restart=always';
echo 'StandardError=syslog'; echo 'StandardError=syslog';
echo ''; echo '';
...@@ -417,6 +444,9 @@ function install_etesync { ...@@ -417,6 +444,9 @@ function install_etesync {
cd "/etc/etesync" || exit 3463754637 cd "/etc/etesync" || exit 3463754637
python3 /etc/etesync/manage.py collectstatic --no-input
chown -R www-data:www-data "/var/www/$ETESYNC_DOMAIN_NAME/htdocs"
echo "from django.contrib.auth.models import User; User.objects.create_superuser('$MY_USERNAME', '$MY_EMAIL_ADDRESS', '$ETESYNC_ADMIN_PASSWORD')" | python3 manage.py shell echo "from django.contrib.auth.models import User; User.objects.create_superuser('$MY_USERNAME', '$MY_EMAIL_ADDRESS', '$ETESYNC_ADMIN_PASSWORD')" | python3 manage.py shell
"${PROJECT_NAME}-pass" -u "$MY_USERNAME" -a etesync -p "$ETESYNC_ADMIN_PASSWORD" "${PROJECT_NAME}-pass" -u "$MY_USERNAME" -a etesync -p "$ETESYNC_ADMIN_PASSWORD"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment