Created update script and systemd service
This commit is contained in:
parent
77e8edbe16
commit
b5d979dbf8
9
cpolis.service
Normal file
9
cpolis.service
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=cpolis
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
ExecStart=/usr/local/bin/cpolis
|
||||||
|
Restart=on-failure
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=default.target
|
34
update.sh
Executable file
34
update.sh
Executable file
@ -0,0 +1,34 @@
|
|||||||
|
#! /bin/sh -
|
||||||
|
|
||||||
|
CPOLIS_REPO_URL="https://git.streifling.com/api/v1/repos/jason/cpolis/releases"
|
||||||
|
CPOLIS_PATH=$HOME/cpolis
|
||||||
|
TAILWINDCSS_REPO_URL=https://api.github.com/repos/tailwindlabs/tailwindcss/releases/latest
|
||||||
|
SYSTEMD_USER_DIR=$HOME/.config/systemd/user
|
||||||
|
|
||||||
|
! which curl >/dev/null && echo "curl needs to be installed"
|
||||||
|
! which go >/dev/null && echo "go needs to be installed"
|
||||||
|
! which jq >/dev/null && echo "jq needs to be installed"
|
||||||
|
! which tar >/dev/null && echo "tar needs to be installed"
|
||||||
|
! which xargs >/dev/null && echo "xargs needs to be installed"
|
||||||
|
|
||||||
|
latest_release=$(curl -s $CPOLIS_REPO_URL | jq -r '.[0].tag_name')
|
||||||
|
curl -Lo cpolis.tar.gz https://git.streifling.com/jason/cpolis/archive/$latest_release.tar.gz
|
||||||
|
rm -fr $CPOLIS_PATH
|
||||||
|
tar -xzf cpolis.tar.gz -C $CPOLIS_PATH
|
||||||
|
rm cpolis.tar.gz
|
||||||
|
|
||||||
|
curl -s $TAILWINDCSS_REPO_URL |
|
||||||
|
grep -F browser_download_url |
|
||||||
|
grep -F linux-x64 |
|
||||||
|
cut -d'"' -f4 |
|
||||||
|
xargs -r curl -Lo $CPOLIS_PATH/tailwindcss
|
||||||
|
chmod +x $CPOLIS_PATH/tailwindcss
|
||||||
|
$CPOLIS_PATH/tailwindcss -i web/static/css/input.css -o web/static/css/style.css
|
||||||
|
|
||||||
|
go build -o $CPOLIS_PATH/cpolis $CPOLIS_PATH/cmd/main.go
|
||||||
|
chmox +x $CPOLIS_PATH/cpolis
|
||||||
|
|
||||||
|
[ ! -f $SYSTEMD_USER_DIR ] && mkdir -p $SYSTEMD_USER_DIR
|
||||||
|
mv $CPOLIS_PATH/cpolis.service $SYSTEMD_USER_DIR
|
||||||
|
systemctl --user daemon-reload
|
||||||
|
systemctl --user is-active --quiet cpolis.service && systemctl --user restart cpolis.service
|
Loading…
x
Reference in New Issue
Block a user