Compare commits
15 Commits
Author | SHA1 | Date | |
---|---|---|---|
c32e38ca10 | |||
c2cadd1542 | |||
4cb2831e9a | |||
ee31a9f8e2 | |||
beec20cdda | |||
7ef957c2d7 | |||
d7c8c7a43a | |||
d56cdc78eb | |||
151d89d9f0 | |||
8d2944d00c | |||
9ddd8198ee | |||
ff6c7a66d7 | |||
129c85929c | |||
b1a6359473 | |||
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
|
55
update.sh
Executable file
55
update.sh
Executable file
@ -0,0 +1,55 @@
|
||||
#! /bin/sh -
|
||||
|
||||
CPOLIS_REPO_URL="https://git.streifling.com/api/v1/repos/jason/cpolis/releases"
|
||||
EXTRACTION_DIR=$HOME
|
||||
CPOLIS_DIR=$EXTRACTION_DIR/cpolis
|
||||
TAILWINDCSS_REPO_URL=https://api.github.com/repos/tailwindlabs/tailwindcss/releases/latest
|
||||
TMP_DIR=/tmp
|
||||
BIN_DIR=/usr/local/bin
|
||||
|
||||
check_dependency() {
|
||||
if ! which $1 >/dev/null 2>&1; then
|
||||
echo "$1 needs to be installed" >&2
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
if ! groups | grep -E 'root|wheel|sudo' >/dev/null; then
|
||||
echo "You need administrative privileges for this script" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
check_dependency curl
|
||||
check_dependency go
|
||||
check_dependency jq
|
||||
check_dependency tar
|
||||
check_dependency xargs
|
||||
|
||||
echo -e '\nDownloading cpolis...' >&2
|
||||
rm -fr $CPOLIS_DIR/*
|
||||
latest_release=$(curl -s $CPOLIS_REPO_URL | jq -r '.[0].tag_name')
|
||||
curl -Lo $TMP_DIR/cpolis.tar.gz https://git.streifling.com/jason/cpolis/archive/$latest_release.tar.gz
|
||||
tar -xzf $TMP_DIR/cpolis.tar.gz -C $EXTRACTION_DIR
|
||||
rm $TMP_DIR/cpolis.tar.gz
|
||||
|
||||
echo -e '\nDownloading TailwindCSS...' >&2
|
||||
curl -s $TAILWINDCSS_REPO_URL |
|
||||
grep -F browser_download_url |
|
||||
grep -F linux-x64 |
|
||||
cut -d'"' -f4 |
|
||||
xargs -r curl -Lo $CPOLIS_DIR/tailwindcss
|
||||
chmod +x $CPOLIS_DIR/tailwindcss
|
||||
$CPOLIS_DIR/tailwindcss -i web/static/css/input.css -o web/static/css/style.css
|
||||
|
||||
echo -e 'Building cpolis...' >&2
|
||||
go build -o $TMP_DIR/cpolis $CPOLIS_DIR/cmd/main.go
|
||||
|
||||
echo -e 'Setting system files up...' >&2
|
||||
sudo mv $TMP_DIR/cpolis $BIN_DIR/cpolis
|
||||
sudo chown root:root $BIN_DIR/cpolis
|
||||
chmod +x $BIN_DIR/cpolis
|
||||
|
||||
sudo mv $CPOLIS_DIR/cpolis.service $SYSTEMD_DIR
|
||||
sudo chown root:root $SYSTEMD_DIR/cpolis.service
|
||||
sudo systemctl daemon-reload
|
||||
sudo systemctl is-active --quiet cpolis.service && sudo systemctl restart cpolis.service
|
Reference in New Issue
Block a user