-
Notifications
You must be signed in to change notification settings - Fork 0
/
makeInstaller.sh
executable file
·90 lines (71 loc) · 2.69 KB
/
makeInstaller.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#!/bin/bash
gitHash=$1
gitTag=$2
declare -A linux0=(
[name]="linuxx86"
[cliBin]="emapc-cli-linux-x86"
[serviceBin]="emapc-srv-linux-x86"
[lib]="pdftotext32"
[uninstaller]="uninstall-linuxx86.sh"
)
declare -A linux1=(
[name]="linuxx64"
[cliBin]="emapc-cli-linux-x64"
[serviceBin]="emapc-srv-linux-x64"
[lib]="pdftotext64"
[uninstaller]="uninstall-linuxx64.sh"
)
declare -n linux
declare -A mac0=(
[name]="macx64"
[cliBin]="emapc-cli-macos-x64"
[serviceBin]="emapc-srv-mac-x64"
[lib]="mac/pdftotext64"
)
declare -n mac
echo "make linux installers"
for linux in ${!linux@}; do
echo "make ${linux[name]} installer"
echo "#!/bin/bash
if [[ \"\$1\" != \"cli\" && \"\$1\" != \"srv\" ]]; then
echo \"USAGE: install-${linux[name]} <cli or srv>\"
exit 0
fi
if [[ \$EUID -ne 0 ]]; then
echo \"This script must be run as root\"
exit 1
fi
mkdir -p /usr/local/emapc/input
mkdir -p /usr/local/emapc/output
mkdir -p /usr/local/emapc/archive
mkdir -p /usr/local/emapc/lib/pdftotext/linux
rm -rf /usr/local/emapc/${linux[uninstaller]}
curl -L https://raw.githubusercontent.com/matzehecht/EinsatzMonitor-Alarm-PDF-Converter/$gitHash/lib/uninstaller/${linux[uninstaller]} -o /usr/local/emapc/${linux[uninstaller]}
rm -rf /usr/local/emapc/lib/pdftotext/linux/${linux[lib]}
curl -L https://raw.githubusercontent.com/matzehecht/EinsatzMonitor-Alarm-PDF-Converter/001c5ab1155e1811ce36590dad7589fe3617dc3b/lib/pdftotext/linux/${linux[lib]} -o /usr/local/emapc/lib/pdftotext/linux/${linux[lib]}
if [[ \"\$1\" == \"cli\" ]]; then
rm -rf /usr/local/emapc/emapc-cli
curl -L https://github.com/matzehecht/EinsatzMonitor-Alarm-PDF-Converter/releases/download/$gitTag/${linux[cliBin]} -o /usr/local/emapc/emapc-cli
chmod +x /usr/local/emapc/emapc-cli
ln -s /usr/local/emapc/emapc-cli /usr/local/bin/
fi
if [[ \"\$1\" == \"srv\" ]]; then
rm -rf /usr/local/emapc/emapc-service
curl -L https://github.com/matzehecht/EinsatzMonitor-Alarm-PDF-Converter/releases/download/$gitTag/${linux[serviceBin]} -o /usr/local/emapc/emapc-service
curl -L https://raw.githubusercontent.com/matzehecht/EinsatzMonitor-Alarm-PDF-Converter/$gitHash/example.conf.yml -o /usr/local/emapc/example.conf.yml
if [ ! -f /usr/local/emapc/emapc.conf.yml ]; then cp /usr/local/emapc/example.conf.yml /usr/local/emapc/emapc.conf.yml; fi
echo \"[Unit]
Description=This is a service for running the emapc.
[Service]
User=root
WorkingDirectory=/usr/local/emapc/
ExecStart=emapc-service
Restart=always
[Install]
WantedBy=multi-user.target\" > /etc/systemd/system/emapc-service.service
sudo systemctl daemon-reload
sudo systemctl start emapc-service.service
fi
" > install-${linux[name]}.sh
chmod +x install-${linux[name]}.sh
done