First try

This commit is contained in:
2024-03-19 17:41:47 +00:00
parent 89e450be5a
commit 3441f370e4
2 changed files with 52 additions and 0 deletions

View File

@@ -0,0 +1,10 @@
[Unit]
Description=OpenVSCode Server Service
[Service]
Type=simple
ExecStart=/bin/bash /root/openvscode-server_service/openvscode-server.sh
Restart=always
[Install]
WantedBy=multi-user.target

View File

@@ -0,0 +1,42 @@
#!/bin/bash
# Function to check for updates
check_update() {
latest_version=$(curl -s https://api.github.com/repos/gitpod-io/openvscode-server/releases/latest | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/')
installed_version=$(openvscode-server --version | cut -d ' ' -f 2)
if [[ $latest_version != $installed_version ]]; then
echo "New version available: $latest_version"
download_url="https://github.com/gitpod-io/openvscode-server/releases/download/$latest_version/openvscode-server-$latest_version-$(get_architecture).tar.gz"
echo "Downloading $latest_version..."
wget "$download_url" -O /tmp/openvscode-server.tar.gz
echo "Removing previous version..."
sudo rm -rf /usr/local/bin/openvscode-server
echo "Installing $latest_version..."
sudo tar -xzf /tmp/openvscode-server.tar.gz -C /usr/local/bin/
rm /tmp/openvscode-server.tar.gz
echo "Updated to $latest_version"
else
echo "No updates available"
fi
}
# Function to get architecture
get_architecture() {
case $(uname -m) in
"x86_64") echo "x64" ;;
"aarch64") echo "arm64" ;;
"armv7l") echo "armhf" ;;
*) echo "Unsupported architecture" ;;
esac
}
# Main function
main() {
check_update
# Run openvscode-server
openvscode-server
}
main