From a9b1c6c69894e64b7774c828709081fed124f40a Mon Sep 17 00:00:00 2001 From: zino Date: Fri, 28 Oct 2022 15:10:44 +0200 Subject: [PATCH] init --- .gitignore | 2 ++ alias | 1 + logs/.gitkeep | 0 update-code-server.sh | 40 ++++++++++++++++++++++++++++++++++++++++ 4 files changed, 43 insertions(+) create mode 100644 .gitignore create mode 100644 alias create mode 100644 logs/.gitkeep create mode 100644 update-code-server.sh diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..a837ace --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +logs/* +!logs/.gitkeep \ No newline at end of file diff --git a/alias b/alias new file mode 100644 index 0000000..7c4386c --- /dev/null +++ b/alias @@ -0,0 +1 @@ +alias update-code-server='/bin/bash /home/zino/projects/update-code-server/update-code-server.sh' \ No newline at end of file diff --git a/logs/.gitkeep b/logs/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/update-code-server.sh b/update-code-server.sh new file mode 100644 index 0000000..06d6805 --- /dev/null +++ b/update-code-server.sh @@ -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" \ No newline at end of file