diff options
author | Bailey Kasin | 2020-01-20 03:51:01 -0800 |
---|---|---|
committer | Bailey Kasin | 2020-01-20 03:51:01 -0800 |
commit | 100a48feefd0bf02fbca2622a2b671101d2660cc (patch) | |
tree | d22a55f5f34fe737363ee20da55105a5e2f536de /gogios.install | |
parent | 07e4f895f3730974d767d5488a4f2eaf7f73ecce (diff) | |
download | aur-100a48feefd0bf02fbca2622a2b671101d2660cc.tar.gz |
Update gogios.install for the new build system
Diffstat (limited to 'gogios.install')
-rw-r--r-- | gogios.install | 54 |
1 files changed, 28 insertions, 26 deletions
diff --git a/gogios.install b/gogios.install index 9810ef1957ec..aa07d8af0bd0 100644 --- a/gogios.install +++ b/gogios.install @@ -1,35 +1,37 @@ -post_install() { - if [ ! -f /etc/gogios/checks.json ]; then - echo "Making default check file" - cp /etc/gogios/example.json /etc/gogios/checks.json +pre_install() { + if ! grep "^gogios:" /etc/group &>/dev/null; then + groupadd -r gogios fi - if [ ! -f /etc/gogios/gogios.toml ]; then - echo "Making default config" - cp /etc/gogios/gogios.sample.toml /etc/gogios/gogios.toml + if ! id gogios &>/dev/null; then + useradd -r -M gogios -s /bin/false -d /var/spool/gogios -g gogios fi +} - if [ ! -f /opt/gogios/js/current.json ]; then - echo "Making current results file" - cp /etc/gogios/checks.json /opt/gogios/js/current.json - fi +post_install() { + LOG_DIR=/var/log/gogios + SCRIPT_DIR=/usr/lib/gogios/scripts - if [ ! -f /var/log/gogios ]; then - mkdir /var/log/gogios + test -d $LOG_DIR || mkdir -p $LOG_DIR + chown -R -L gogios:gogios $LOG_DIR + chmod 755 $LOG_DIR + + cp -f $SCRIPT_DIR/gogios.service /usr/lib/systemd/system/gogios.service + systemctl enable gogios || true + systemctl daemon-reload || true + + # Add defaults file if it doesn't exist + if [[ ! -d /etc/default/gogios ]]; then + touch /etc/default/gogios fi - if id "gogios" >/dev/null 2>&1; then - echo "gogios user already exists" - else - mkdir -p /var/spool/gogios - useradd --system --user-group --home-dir /var/spool/gogios --create-home --shell /sbin/nologin gogios - chown gogios:gogios /var/spool/gogios + # If the user has no checks yet, give them the example file + if [ ! -f /etc/gogios/checks.json ]; then + echo "Making default check file" + cp /etc/gogios/example.json /etc/gogios/checks.json fi - - chown gogios:gogios -R /var/log/gogios - chmod 0764 -R /var/log/gogios - chown gogios:gogios -R /usr/lib/gogios - chown gogios:gogios -R /etc/gogios + + # Gogios will fail to start if these files aren't owned chown gogios:gogios -R /opt/gogios } @@ -37,8 +39,8 @@ post_upgrade() { post_install } -pre_remove() { - systemctl stop gogios +post_remove() { systemctl disable gogios + rm -f /usr/lib/systemd/system/gogios.service } |