-
Notifications
You must be signed in to change notification settings - Fork 2
/
create.sh
51 lines (51 loc) · 2.07 KB
/
create.sh
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
#!/bin/bash
# Script written by Faraz
# Automates creating a new Journey Blog with nginx
SITENAME="$1" # <- Subdomain
PORT="$2" # <- Random port passed in
if [ -z "$SITENAME" ] || [ -z "$PORT" ]
then
echo 'Error, not enough arguments!'
exit 2
fi
SITEURL=$SITENAME.goghost.pw
SITENAME=journey-$SITENAME
mkdir -p /var/www/$SITENAME
cd /var/www/$SITENAME
echo "Getting latest release!" # TODO make this a symlink for all except config and db files
wget --quiet https://github.com/kabukky/journey/releases/download/v0.1.9/journey-linux-amd64.zip
unzip -qq journey-linux-amd64.zip
rm journey-linux-amd64.zip
mv journey-linux-amd64/ journey
cd journey
sed -i -e "s/8084/$PORT/g" config.json
sed -i -e "s/127.0.0.1:$PORT/$SITEURL:$PORT/g" config.json
echo "start on runlevel [2345]" >> /etc/init/$SITENAME.conf
echo "stop on runlevel [!2345]" >> /etc/init/$SITENAME.conf
echo "respawn" >> /etc/init/$SITENAME.conf
echo "console none" >> /etc/init/$SITENAME.conf
echo "exec /var/www/$SITENAME/journey/journey -log=/var/www/$SITENAME/journey/log.txt" >> /etc/init/$SITENAME.conf
cd /etc/nginx/sites-enabled
echo "server {" >> $SITENAME.conf
echo "listen 0.0.0.0:80;" >> $SITENAME.conf
echo "server_name $SITEURL;" >> $SITENAME.conf
echo "access_log /var/log/nginx/$SITENAME.log;" >> $SITENAME.conf
echo "location / {" >> $SITENAME.conf
echo "proxy_pass http://127.0.0.1:$PORT;" >> $SITENAME.conf
echo " }" >> $SITENAME.conf
echo "}" >> $SITENAME.conf
echo "server {" >> $SITENAME.conf
echo "listen 0.0.0.0:80;" >> $SITENAME.conf
echo "server_name www.$SITEURL;" >> $SITENAME.conf
echo "access_log /var/log/nginx/$SITENAME.log;" >> $SITENAME.conf
echo "location / {" >> $SITENAME.conf
echo "proxy_pass http://127.0.0.1:$PORT;" >> $SITENAME.conf
echo " }" >> $SITENAME.conf
echo "}" >> $SITENAME.conf
service $SITENAME start
service nginx restart
echo "---------------------------------------------------"
echo "You may need to oonfigure your DNS Records if you used a custom domain!"
echo "ALL DONE! $SITEURL is viewable as a Journey blog!"
echo "Setup at $SITEURL/admin"
echo "---------------------------------------------------"