codeserver-installer/codeserver-installer_1.0-1_amd64/usr/local/bin/codeserverctl
2024-06-04 11:48:21 +02:00

38 lines
987 B
Plaintext
Executable File

#!/bin/bash
function status() {
echo 'code-server is' $(systemctl is-active code-server)
}
function start() {
systemctl start code-server
}
function stop() {
systemctl stop code-server
}
function upgrade() {
VERSION="$(curl -fsSLI -o /dev/null -w "%{url_effective}" https://github.com/coder/code-server/releases/latest | sed 's:.*/::')"
VERSION=${VERSION#?}
# https://github.com/coder/code-server/releases/download/v4.7.1/code-server-4.7.1-amd64.rpm
wget "https://github.com/coder/code-server/releases/download/v$VERSION/code-server_${VERSION}_amd64.deb"
dpkg -i code-server_${VERSION}_amd64.deb
rm code-server_${VERSION}_amd64.deb
}
case "$1" in
start) start ;;
stop) stop ;;
status) status;;
restart) stop; start ;;
upgrade) upgrade; stop; start;;
*) printf "code-server controller\n\nusage: \n$0 start|stop|restart|upgrade|status\n\n" >&2
exit 1
;;
esac