38 lines
1016 B
Bash
38 lines
1016 B
Bash
#!/bin/sh
|
|
set -e
|
|
|
|
# create user which peach-web runs as
|
|
id -u peach &>/dev/null || adduser --quiet peach
|
|
|
|
# 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;
|
|
}
|
|
}
|
|
EOF
|
|
|
|
# update sudoers to allow peach-web to stop and restart go-sbot.service
|
|
mkdir -p /etc/sudoers.d/
|
|
|
|
SYSTEMCTL=$(which 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"
|
|
|
|
cat <<EOF > /etc/sudoers.d/peach-web
|
|
peach ALL=(ALL) NOPASSWD: $START, $STOP, $RESTART, $ENABLE, $DISABLE
|
|
EOF
|
|
chmod 0440 /etc/sudoers.d/peach-web
|
|
|
|
# cargo deb automatically replaces this token below, see https://github.com/mmstick/cargo-deb/blob/master/systemd.md
|
|
#DEBHELPER# |