-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuncbiag_update_webpage_for_cron_job.script
executable file
·54 lines (39 loc) · 1.58 KB
/
uncbiag_update_webpage_for_cron_job.script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#! /usr/bin/env bash
# Before running this for the first time (and possibly making it a cron job) clone the repository
# to make it a cron job, log into your server and do the following
#
# crontab -u myusername -e
#
# add the following (adapted to your personal case) to your crontab
#
# 0 0 * * * /home/myusername/uncbiag-webpage/uncbiag_update_webpage_for_cron_job.script
#
# This will run it every midnight
#
# Here are some site-specific settings
SCRIPT_DIRECTORY='/home/mn/uncbiag-webpage'
GIT_REPOSITORY_DIRECTORY='/home/mn/uncbiag-webpage/uncbiag-academic-kickstart'
TARGET_DEPLOY_DIRECTORY='/var/www/html'
HUGO_BINARY='/home/linuxbrew/.linuxbrew/bin/hugo'
cd $SCRIPT_DIRECTORY
rm -rf $GIT_REPOSITORY_DIRECTORY
#git config --global --add safe.directory /afs/cs.unc.edu/home/mn/uncbiag-webpage/uncbiag-academic-kickstart/themes/academic
git clone https://github.com/uncbiag/uncbiag-academic-kickstart
cd uncbiag-academic-kickstart
git submodule update --init --recursive
# Setting a base-url, for local set it to BASE_URL='http://0.0.0.0:8000/' and then run it with cd deploy, python -m http.server
BASE_URL='https://biag.cs.unc.edu/'
# update the github repo
cd $GIT_REPOSITORY_DIRECTORY
git checkout master
git pull origin master
# run hugo
$HUGO_BINARY --baseURL=$BASE_URL
# copy the directory into a target directory
rsync -v --checksum -r public/* $TARGET_DEPLOY_DIRECTORY
# set the permissions
chmod -R 755 $TARGET_DEPLOY_DIRECTORY
# delete it
rm -rf $GIT_REPOSITORY_DIRECTORY
# once run, send an email
echo Ran webpage update at `date` | mail -e -s "uncbiag webpage update" [email protected]