From 44cc2666a923f80cdcde81ecf47afd3c2ad3f5c0 Mon Sep 17 00:00:00 2001 From: beepboopbelong Date: Wed, 4 Mar 2020 20:20:33 +0100 Subject: [PATCH] Initial commit --- setup.sh | 15 +++++++++++++++ update_page.sh | 20 ++++++++++++++++++++ 2 files changed, 35 insertions(+) create mode 100644 setup.sh create mode 100644 update_page.sh diff --git a/setup.sh b/setup.sh new file mode 100644 index 0000000..821fd4e --- /dev/null +++ b/setup.sh @@ -0,0 +1,15 @@ +#!/bin/bash +USER=$(whoami) +CRON_DIR=/var/spool/cron/$USER +CRON_JOB="0 0 * * * /home/$USER/update_page.sh" # a simple cron job that runs everyday + +# allow user to add cron commands +sudo echo $USER >> /etc/cron.allow +# setup a cron file for the user +sudo touch $CRON_DIR +sudo /usr/bin/crontab $CRON_DIR +# setup the cron job +sudo echo $CRON_JOB >> $CRON_DIR + +echo "Checking cronjobs..." +sudo crontab -u $USER -l \ No newline at end of file diff --git a/update_page.sh b/update_page.sh new file mode 100644 index 0000000..60a1e1b --- /dev/null +++ b/update_page.sh @@ -0,0 +1,20 @@ +#!/bin/bash +GIT_URL=https://git.lain.church/Jellyman-Group/Sern-Site.git +OUTPUT_DIR=~/site +WWW_DIR=/var/www/html/ +WWW_DATA_USER=www-data + +# remove the old site +rm -rf $OUTPUT_DIR + +# clone the new site +git clone $GIT_URL $OUTPUT_DIR + +# Remove the README.md from the dir +rm $OUTPUT_DIR/README.md + +# Copy data to webdir +sudo cp $OUTPUT_DIR/* $WWW_DIR + +# Change ownership +sudo chown -R $WWW_DATA_USER:$WWW_DATA_USER $WWW_DIR \ No newline at end of file