Last active
January 12, 2021 12:03
-
-
Save yasn77/864ebf83b6feb9adbf15c523155c03c6 to your computer and use it in GitHub Desktop.
This file contains 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
[Unit] | |
Description=Update opsctl using daily timer | |
Wants=update-opsctl.timer | |
[Service] | |
Type=oneshot | |
ExecStart=<PATH_TO_UPDATE_OPSCTL_SCRIPT> | |
[Install] | |
WantedBy=multi-user.target |
This file contains 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
#!/usr/bin/env bash | |
# Requires opsctl version 1.9.0 (https://github.com/giantswarm/opsctl/releases/tag/v1.9.0) | |
set -o errexit | |
set -o nounset | |
set -o pipefail | |
OPSCTL_BINDIR=${OPSCTL_BINDIR:-"${HOME}/.local/bin"} | |
if [ -x ${OPSCTL_BINDIR}/opsctl ] | |
then | |
VER_CHECK_EXIT_CODE="$(${OPSCTL_BINDIR}/opsctl version check &>/dev/null; echo $?)" | |
else | |
echo "${OPSCTL_BINDIR}/opsctl is not there or isn't executable" | |
exit 1 | |
fi | |
if [ "$VER_CHECK_EXIT_CODE" == "125" ] | |
then | |
echo -n "🔺 Updating..." | |
${OPSCTL_BINDIR}/opsctl version update | |
echo "...Done 🚀" | |
else | |
echo "You already have the latest opsctl release 👍" | |
fi |
This file contains 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
[Unit] | |
Description=Update opsctl | |
[Timer] | |
OnCalendar=daily | |
Persistent=true | |
[Install] | |
WantedBy=timers.target |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
To use: