This commit is contained in:
zino
2022-10-28 15:10:44 +02:00
parent 957f7057ce
commit a9b1c6c698
4 changed files with 43 additions and 0 deletions

2
.gitignore vendored Normal file
View File

@@ -0,0 +1,2 @@
logs/*
!logs/.gitkeep

1
alias Normal file
View File

@@ -0,0 +1 @@
alias update-code-server='/bin/bash /home/zino/projects/update-code-server/update-code-server.sh'

0
logs/.gitkeep Normal file
View File

40
update-code-server.sh Normal file
View File

@@ -0,0 +1,40 @@
#!/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"