peach-workspace/peach-web/debian/postinst

38 lines
1012 B
Plaintext
Raw Normal View History

2021-08-06 17:58:40 +00:00
#!/bin/sh
set -e
# create user which peach-web runs as
id -u peach &>/dev/null || adduser --quiet peach
2021-08-06 17:58:40 +00:00
# create nginx config
cat <<EOF > /etc/nginx/sites-enabled/default
server {
listen 80 default_server;
server_name peach.local www.peach.local;
# remove trailing slash if found
rewrite ^/(.*)/$ /$1 permanent;
location / {
proxy_pass http://127.0.0.1:8000;
2021-08-06 17:58:40 +00:00
}
}
EOF
# update sudoers to allow peach-web to stop and restart go-sbot.service
mkdir -p /etc/sudoers.d/
2022-04-18 20:45:28 +00:00
SYSTEMCTL=/bin/systemctl
START="${SYSTEMCTL} start go-sbot.service"
RESTART="${SYSTEMCTL} restart go-sbot.service"
STOP="${SYSTEMCTL} stop go-sbot.service"
ENABLE="${SYSTEMCTL} enable go-sbot.service"
DISABLE="${SYSTEMCTL} disable go-sbot.service"
2021-08-06 17:58:40 +00:00
cat <<EOF > /etc/sudoers.d/peach-web
peach ALL=(ALL) NOPASSWD: $START, $STOP, $RESTART, $ENABLE, $DISABLE
2021-08-06 17:58:40 +00:00
EOF
chmod 0440 /etc/sudoers.d/peach-web
2021-08-06 17:58:40 +00:00
# cargo deb automatically replaces this token below, see https://github.com/mmstick/cargo-deb/blob/master/systemd.md
#DEBHELPER#