Index

joshstock.in / e654c77

Source for serving and static templating/compiling of https://joshstock.in.

Latest Commit

{#}TimeHashSubjectAuthor#(+)(-)GPG?
4804 Jan 2020 12:536799f82Create git pager sourceJosh Stockin1480N

Blob @ joshstock.in / installgitpager

text/x-shellscript1146 bytesdownload raw
1#!/usr/bin/env bash
2
3GITPAGERPATH=/srv/gitpager
4SCRIPTPATH=$(dirname $(realpath -s $0))
5
6usage() {
7 echo "usage: sudo ./installgitpager [prod | test]"
8 exit 1
9}
10if [ "$EUID" -ne 0 ]; then
11 echo "error: must run as root"
12 usage
13fi
14if [ $# -eq 0 ]; then
15 usage
16fi
17if [ "$1" != "prod" ] && [ "$1" != "test" ]; then
18 usage
19fi
20if [ "$1" == "prod" ]; then
21 NODE_ENV="production"
22elif [ "$1" == "test" ]; then
23 NODE_ENV="development"
24fi
25
26echo "copying service file to systemd configuration folder"
27cp $SCRIPTPATH/gitpager.service /etc/systemd/system/gitpager.service
28
29echo "modifying service configuration file for node environment variable"
30sed -i "s/\$env/$NODE_ENV/g" /etc/systemd/system/gitpager.service
31
32echo "emptying and deleting old $GITPAGERPATH folder"
33rm -r $GITPAGERPATH
34
35echo "creating new $GITPAGERPATH folder"
36mkdir -p $GITPAGERPATH
37
38echo "copying $SCRIPTPATH/gitpager/* to $GITPAGERPATH"
39cp -r $SCRIPTPATH/gitpager/* $GITPAGERPATH
40
41echo "installing node modules at $GITPAGERPATH"
42npm --prefix $GITPAGERPATH install $GITPAGERPATH
43
44echo "attempting to reload gitpager service"
45systemctl daemon-reload
46service gitpager restart
47
48echo "done"
49