blob: b9f0afab5329d018999687f047293b0c315d2e77 (
plain)
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
|
#!/bin/bash
_appname="tabbyml"
_appuser="tabbyml"
_appprefix="/opt"
_appdataprefix="/var/opt"
_apphome="${_appprefix}/${_appname}"
_appdata="${_appdataprefix}/${_appname}"
pre_install() {
msg "Creaing user tabbyml..."
getent passwd $_appuser >/dev/null || useradd -r -s /bin/false -d "$_apphome" "$_appuser"
}
_install() {
# Install default config if needed
if [ ! -f "/etc/${_appname}/server.conf" ]; then
msg "Installing default server config..."
install -Dm644 "/usr/share/${_appname}/server.conf" "/etc/${_appname}/server.conf"
# Generate the secret key if needed
msg "Generating random SECRET_KEY..."
secret_key="$(uuidgen)"
sed -i "s/{{GENERATED_KEY}}/${secret_key}/" "/etc/${_appname}/server.conf"
fi
if [ ! -f "/etc/${_appname}/config.toml" ]; then
msg "Installing default config.toml"
install -Dm644 "/usr/share/${_appname}/config.toml" "/etc/${_appname}/config.toml"
fi
if [ ! -L "${_appdata}/config.toml" ]; then
msg "Setting up config.toml symlink"
ln -s "/etc/${_appname}/config.toml" "${_appdata}/config.toml"
fi
# Ensure appropriate permissions
chown -R "$_appuser:$_appuser" "${_apphome}" || return 1
chown -R "$_appuser:$_appuser" "${_appdata}" || return 1
chmod -R g+rwX "${_appdata}" || return 1
}
post_install() {
_install || echo -e "\nERROR: Failed to install dependencies\n"
}
post_upgrade() {
_install || echo -e "\nERROR: Failed to install dependencies\n"
}
|