Files
update-code-server/update-code-server.sh
2022-10-28 15:10:44 +02:00

40 lines
1.0 KiB
Bash

#!/usr/bin/env bash
is_running() {
# check if running
me="$(basename "$0")";
result=$(ps aux | grep -i $me | grep -v "grep" | wc -l)
echo "running: $result"
if [ $result -gt 4 ]
then
exit
fi
}
is_root() {
if [[ $(id -u) -ne 0 ]]
then echo "Please run as root"
exit
fi
}
main_function() {
is_running
is_root
export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/go/bin"
#curl -fsSL https://code-server.dev/install.sh | sh -s -- --dry-run # dry-run
curl -fsSL https://code-server.dev/install.sh | sh # install
#systemctl disable code-server@root # disable automatically created service
systemctl restart code-server
}
ROOTDIR=/home/zino/projects/update-code-server
STATUSFILE=$ROOTDIR/logs/$(date +"%Y-%m-%d-%H-%M-%S").log
echo "$STATUSFILE"
# log everything, but also output to stdout
main_function 2>&1 | tee -a "$STATUSFILE"