sh templates and owncast unit file #9
38
scripts/sh/_templates/goapps/deploy_app.sh
Normal file
38
scripts/sh/_templates/goapps/deploy_app.sh
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
DISTRIB=$(awk -F= '/^NAME/{print $2}' /etc/os-release)
|
||||||
|
echo "Detected $DISTRIB"
|
||||||
|
if [ ${DISTRIB} = "openSUSE Leap" ]
|
||||||
|
echo
|
||||||
|
then
|
||||||
|
if [ ! -d /opt/app ]
|
||||||
|
then
|
||||||
|
echo "app not found. Preparing Install"
|
||||||
|
|
||||||
|
# Distrib package manager installs deps
|
||||||
|
zypper in --no-recommends -y git make
|
||||||
|
REPO="<repo_url.git>"
|
||||||
|
mkdir /opt/app
|
||||||
|
useradd -rUd /opt/app -s /bin/false app
|
||||||
|
chown app:app /opt/app
|
||||||
|
chmod 750 /opt/app
|
||||||
|
usermod -aG app pratyush
|
||||||
|
usermod -aG app georg
|
||||||
|
sudo -u app git clone $REPO /opt/app/app-git
|
||||||
|
cd /opt/app/app-git || exit
|
||||||
|
sudo -u app make build
|
||||||
|
sudo -u app chmod +x app
|
||||||
|
ln -s /opt/app/app-git/app /opt/app/app
|
||||||
|
|
||||||
|
# Insert application specific commands here.
|
||||||
|
|
||||||
|
# consider a change in directory structure based on applications?
|
||||||
|
# update the statement below accordingly.
|
||||||
|
sudo cp path/to/unitfile /etc/systemd/system/app.service
|
||||||
|
sudo systemctl daemon-reload
|
||||||
|
sudo systemctl enable --now app.service
|
||||||
|
else
|
||||||
|
echo "Existing app installation or leftovers detected. Consider remove_app.sh."
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo "This is currently only compatible with SUSE Leap nodes."
|
||||||
|
fi
|
26
scripts/sh/_templates/goapps/remove_app.sh
Normal file
26
scripts/sh/_templates/goapps/remove_app.sh
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
# Check for existing installation in `/opt`.
|
||||||
|
|
||||||
|
if [ ! -d /opt/app ]
|
||||||
|
then
|
||||||
|
echo "This will kill running app services and cause data loss! Remove app? "
|
||||||
|
read text -r
|
||||||
|
|
||||||
|
# https://github.com/koalaman/shellcheck/wiki/SC3015
|
||||||
|
# https://github.com/koalaman/shellcheck/wiki/SC2003
|
||||||
|
# Need a POSIX compatible regex soln below!
|
||||||
|
expr "$text" : "^[Yy]$" > /dev/null
|
||||||
|
if [ "$text" ]
|
||||||
|
then
|
||||||
|
echo "Removing app"
|
||||||
|
systemctl disable --now app.service || true
|
||||||
|
rm -f /etc/systemd/system/app.service
|
||||||
|
rm -rf /opt/app
|
||||||
|
userdel -f app
|
||||||
|
groupdel -f app
|
||||||
|
echo "OK"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo "Could not find a compatible installation of app."
|
||||||
|
fi
|
26
scripts/sh/_templates/goapps/update_app.sh
Normal file
26
scripts/sh/_templates/goapps/update_app.sh
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
# Only supports git source builds currently.
|
||||||
|
|
||||||
|
if [ -f /opt/app/app-git/app ]
|
||||||
|
then
|
||||||
|
echo "This will immediately stop app if it is running. Update app on this system? "
|
||||||
|
read text -r
|
||||||
|
expr "$text" : "^[Yy]$" > /dev/null
|
||||||
|
if [ "$text" ]
|
||||||
|
then
|
||||||
|
# Inconsistent `sudo` use?
|
||||||
|
systemctl stop app.service
|
||||||
|
|
||||||
|
# Update golang using `deploy_go`
|
||||||
|
|
||||||
|
cd /opt/app/app-git || exit
|
||||||
|
rm -f app
|
||||||
|
git pull
|
||||||
|
sudo -u app make build
|
||||||
|
# insert misc commands as needed.
|
||||||
|
systemctl start app.service
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo "app does not seem to be installed. Consider deploy_app.sh."
|
||||||
|
fi
|
12
systemd/owncast.service
Normal file
12
systemd/owncast.service
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=Owncast Service
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=simple
|
||||||
|
WorkingDirectory=/opt/owncast/
|
||||||
|
ExecStart=/opt/owncast/owncast
|
||||||
|
Restart=on-failure
|
||||||
|
RestartSec=5
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
Loading…
Reference in New Issue
Block a user