-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
executable file
·73 lines (53 loc) · 1.99 KB
/
install.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#!/bin/bash
#: - Get location of this file (https://stackoverflow.com/questions/59895/how-can-i-get-the-source-directory-of-a-bash-script-from-within-the-script-itsel)
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
###### ++++++++++++++++++++++++++++ ######
###### +++ Install apt packaged +++ ######
###### ++++++++++++++++++++++++++++ ######
echo "Installing MP3Box ..."
#: [sudo]
#: - Installing MP3Box / gpac for video converting
apt-get -y install gpac
###### +++++++++++++++++++++++++++++++++++ ######
###### +++ Install python requirements +++ ######
###### +++++++++++++++++++++++++++++++++++ ######
install_req () { # To be run without sudo, pass SCRIPT_DIR as #1 parameter
echo "Installing virtualenv ..."
#: - Installing virtualenv
python3 -m pip install virtualenv
#: - Create and activate venv
#: - ${1} referring to arg #1
echo "Creating virtual environment ${1}/venv ..."
python3 -m virtualenv "${1}/venv"
source "${1}/venv/bin/activate"
#: - Install python requirements
echo "Installing python dependencies ..."
python3 -m pip install -r "${1}/requirements.txt"
#: - Deactivate venv
deactivate
}
export -f install_req
#: - Run function as logged in user
su "$(logname)" -c "install_req ${SCRIPT_DIR}"
###### ++++++++++++++++++++++++++++++ ######
###### +++ Configure app service +++ ######
###### ++++++++++++++++++++++++++++++ ######
echo "Preparing app service ..."
sed -i -e "s#{directory}#$SCRIPT_DIR#g" "${SCRIPT_DIR}/app.service"
echo "Copying service ..."
#: [sudo]
#: - Copy service file to systemd
cp "${SCRIPT_DIR}/app.service" "/lib/systemd/system"
echo "Update services ..."
#: [sudo]
#: - Reload to get access to new configuratons
systemctl daemon-reload
echo "Enable app service ..."
#: [sudo]
#: - Enable app service to start automatically after reboot
systemctl enable app.service
echo "Start app service ..."
#: [sudo]
#: - Start app service now without reboot
systemctl start app.service
echo "DONE"