1 | #!/bin/bash
|
---|
2 |
|
---|
3 | # Run this script with optional args:
|
---|
4 | # 1 - username for the service to run as (defaults to www-data)
|
---|
5 | # 2 - the name for the service (defaults to greenstone3) - change this eg if you want to run two greenstone services
|
---|
6 | if [ -d "/etc/systemd/system/" ] ; then
|
---|
7 |
|
---|
8 | if [ "x$GSDL3SRCHOME" = "x" ] ; then
|
---|
9 | cd .. && source ./gs3-setup.sh && cd service.d
|
---|
10 | fi
|
---|
11 |
|
---|
12 | gsdl_service_username=${1-www-data}
|
---|
13 | gsdl_service_name=${2-greenstone3}
|
---|
14 |
|
---|
15 | echo ""
|
---|
16 |
|
---|
17 | echo "****"
|
---|
18 | echo "* Generating $gsdl_service_name.service from greenstone3.service.in"
|
---|
19 | echo "* using user $gsdl_service_username"
|
---|
20 | echo "****"
|
---|
21 | cat greenstone3.service.in \
|
---|
22 | | sed "s%@GSDL3SRCHOME@%$GSDL3SRCHOME%g" \
|
---|
23 | | sed "s%@GSDL_SERVICE_USERNAME@%$gsdl_service_username%g" \
|
---|
24 | > $gsdl_service_name.service
|
---|
25 |
|
---|
26 | echo "****"
|
---|
27 | echo "* Copying $gsdl_service_name.service to /etc/systemd/system/"
|
---|
28 | echo "****"
|
---|
29 | sudo /bin/cp $gsdl_service_name.service /etc/systemd/system/.
|
---|
30 |
|
---|
31 | echo ""
|
---|
32 | echo "----"
|
---|
33 | echo "General info:"
|
---|
34 | echo " In the event of the service being updated, you will most likely need to run:"
|
---|
35 | echo " sudo systemctl daemon-reload"
|
---|
36 | echo ""
|
---|
37 | echo " To enable this service to be run at boot-up time, run:"
|
---|
38 | echo " sudo systemctl enable $gsdl_service_name"
|
---|
39 | echo "----"
|
---|
40 |
|
---|
41 | else
|
---|
42 | echo "Error: Failed to find '/etc/systemd/system'" >&2
|
---|
43 | echo "This install script was developed on a Debian system." >&2
|
---|
44 | echo "It looks like your Linux Distribution uses a different directory structure for services" >&2
|
---|
45 |
|
---|
46 | exit 1
|
---|
47 | fi
|
---|
48 |
|
---|