advisory-circular/install.sh

42 lines
1.2 KiB
Bash
Raw Normal View History

2020-05-04 00:02:26 +00:00
#!/bin/bash
set -e
install_path=/usr/local/share/advisorycircular
config_path=/etc/advisorycircular
2020-05-04 03:10:54 +00:00
run_path=/var/run/advisorycircular
2020-05-04 00:02:26 +00:00
user=advisorycircular
2020-05-04 03:10:54 +00:00
# Create install, config, and run directories if they doesn't exist.
sudo mkdir -p "$install_path"
sudo mkdir -p "$config_path"
sudo mkdir -p "$run_path"
2020-05-04 00:02:26 +00:00
# Create advisory-circular user if it doesn't exist.
if ! id -u ${user} 2>/dev/null
then
2020-05-04 03:10:54 +00:00
sudo adduser --system --home ${install_path} --no-create-home --quiet ${user}
2020-05-04 00:02:26 +00:00
fi
# Compile.
npm install
npx shadow-cljs compile script
# Install
2020-05-04 03:10:54 +00:00
sudo install intervalexec.py "$install_path"/intervalexec
sudo install advisorycircular.sh "$install_path"/advisorycircular
sudo cp -r node_modules "$install_path"
sudo cp -r .shadow-cljs "$install_path"
sudo mkdir -p "$install_path"/out
sudo cp out/advisorycircular.js "$install_path"/out
sudo cp clean-basestation.sqb "$install_path"
sudo chown -R "$user" "$install_path"
2020-05-04 00:02:26 +00:00
2020-05-04 03:10:54 +00:00
sudo cp config-skel.yaml "$config_path"
sudo cp secrets-skel.yaml "$config_path"
sudo chmod go-r "$config_path"/secrets-skel.yaml
sudo chown -R "$user" "$config_path"
sudo chown -R "$user" "$run_path"
sudo chmod go-w "$run_path"
2020-05-08 01:58:10 +00:00
sudo cp advisorycircular@.service /lib/systemd/system