advisory-circular/install.sh
2020-05-11 16:51:27 -07:00

42 lines
1.2 KiB
Bash
Executable File

#!/bin/bash
set -e
install_path=/usr/local/share/advisorycircular
config_path=/etc/advisorycircular
run_path=/var/lib/advisorycircular
user=advisorycircular
# 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"
# Create advisory-circular user if it doesn't exist.
if ! id -u ${user} >/dev/null 2>&1
then
sudo adduser --system --home ${install_path} --no-create-home --quiet ${user}
fi
# Compile.
npm install
npx shadow-cljs compile script
# Install
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"
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"
sudo cp advisorycircular@.service /lib/systemd/system