cpolis/update.sh

35 lines
1.5 KiB
Bash
Raw Normal View History

#! /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
2024-08-18 13:56:41 +02:00
! which curl >/dev/null 2>&1 && echo "curl needs to be installed" >&2 && exit 1
! which go >/dev/null 2>&1 && echo "go needs to be installed" >&2 && exit 1
! which jq >/dev/null 2>&1 && echo "jq needs to be installed" >&2 && exit 1
! which tar >/dev/null 2>&1 && echo "tar needs to be installed" >&2 && exit 1
! which xargs >/dev/null 2>&1 && echo "xargs needs to be installed" >&2 && exit 1
2024-08-18 17:06:49 +02:00
rm -fr $CPOLIS_PATH/*
latest_release=$(curl -s $CPOLIS_REPO_URL | jq -r '.[0].tag_name')
curl -Lo /tmp/cpolis.tar.gz https://git.streifling.com/jason/cpolis/archive/$latest_release.tar.gz
tar -xzf /tmp/cpolis.tar.gz -C $CPOLIS_PATH
rm /tmp/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
2024-08-18 16:59:49 +02:00
chmod +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