Last active
June 16, 2024 03:18
-
-
Save NNdroid/452887e896122ee45ec0dd7e355f395c to your computer and use it in GitHub Desktop.
a shell scripts for debian\ubuntu netbird upgrade
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
GITHUB_API="https://api.github.com/repos/netbirdio/netbird/releases" | |
function check_error() { | |
if [ $? == 1 ]; then | |
echo $1 | |
exit 1 | |
fi | |
} | |
function install_pkgs() { | |
apt install jq curl wget -y | |
} | |
function get_arch() { | |
arch=$(uname -m) | |
if [ "$arch" == "x86_64" ]; then | |
echo "amd64" | |
elif [ "$arch" == "aarch64" ]; then | |
echo "arm64" | |
else | |
echo "null" | |
fi | |
} | |
function install() { | |
arch=$(get_arch) | |
echo "OS arch: ${arch}" | |
download_url=$(curl "${GITHUB_API}" | jq -r --arg arch "$arch" '.[0].assets[] | select(.name | test("netbird_[0-9]+\\.[0-9]+\\.[0-9]+_linux_\($arch)\\.deb")) | .browser_download_url') | |
check_error "get download url error." | |
if [ -z "$download_url" ]; then | |
echo "get download url error." | |
else | |
echo "download deb from: {download_url}" | |
wget -O netbird.deb "${download_url}" | |
check_error "a error for download deb." | |
dpkg -i netbird.deb | |
rm -rf netbird.deb | |
fi | |
} | |
function main() { | |
install_pkgs | |
install | |
} | |
main |
#!/bin/bash if [ ! -f "/etc/cron.daily/netbird-upgrade" ]; then wget -O /etc/cron.daily/netbird-upgrade "https://gist.githubusercontent.com/NNdroid/452887e896122ee45ec0dd7e355f395c/raw/3c2a6fbf82fc7e2f6e767345bdaf7d9fc6a820d5/netbird_upgrade.sh" chmod +x /etc/cron.daily/netbird-upgrade fi bash /etc/cron.daily/netbird-upgrade
or
[ ! -f "/etc/cron.daily/netbird-upgrade" ] && wget -O /etc/cron.daily/netbird-upgrade "https://gist.githubusercontent.com/NNdroid/452887e896122ee45ec0dd7e355f395c/raw/3c2a6fbf82fc7e2f6e767345bdaf7d9fc6a820d5/netbird_upgrade.sh" && chmod +x /etc/cron.daily/netbird-upgrade; bash /etc/cron.daily/netbird-upgrade
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
curl "https://gist.githubusercontent.com/NNdroid/452887e896122ee45ec0dd7e355f395c/raw/3c2a6fbf82fc7e2f6e767345bdaf7d9fc6a820d5/netbird_upgrade.sh" | bash