35 lines
1 KiB
Bash
Executable file
35 lines
1 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
|
|
echo "Clearing journald > 30 days"
|
|
sudo journalctl --vacuum-time=30d
|
|
|
|
echo "Applying system upgrades"
|
|
sudo apt-get update
|
|
sudo apt-get autoclean
|
|
sudo apt-get upgrade
|
|
|
|
## rclone in LTS is too old
|
|
function upgrade_rclone() {
|
|
echo "Checking rclone..."
|
|
# get installed version
|
|
_LOCAL=$(dpkg-query --showformat='${Version}' --show rclone)
|
|
|
|
# get latest version, strip leading "v" (v1.55.1 -> 1.55.1)
|
|
_REMOTE=$(curl -s "https://api.github.com/repos/rclone/rclone/releases/latest" | grep -Po '"tag_name": "\K.*?(?=")')
|
|
_REMOTE=${_REMOTE#v}
|
|
|
|
# bash doesn't see versions as numbers, but as strings
|
|
if [[ "${_LOCAL}" != "${_REMOTE}" ]]; then
|
|
echo "Upgrading rclone - installed ${_LOCAL}, latest ${_REMOTE}"
|
|
curl -L -o /tmp/rclone-latest.deb \
|
|
"https://downloads.rclone.org/rclone-current-linux-amd64.deb"
|
|
if [[ $? -eq 0 ]]; then
|
|
sudo apt-get install /tmp/rclone-latest.deb
|
|
rm -f /tmp/rclone-latest.deb
|
|
fi
|
|
else
|
|
echo "Installed rclone is the latest - ${_LOCAL}"
|
|
fi
|
|
}
|
|
|
|
upgrade_rclone
|