netdata-updater at cron fixes
Costa Tsaousis (ktsaou) committed
May 20, 2017 at 15:07 UTC
02df36ead693e837aa52aeeb10fe508a064692d8
1 file changed
+42
-11
netdata-installer.sh
+42
-11
@@ -71,6 +71,7 @@ setcap="$(which setcap 2>/dev/null || command -v setcap 2>/dev/null)"
71
ME="$0"
72
DONOTSTART=0
73
DONOTWAIT=0
74
+AUTOUPDATE=0
75
NETDATA_PREFIX=
76
LIBS_ARE_HERE=0
77
NETDATA_CONFIGURE_OPTIONS="${NETDATA_CONFIGURE_OPTIONS-}"
@@ -98,6 +99,12 @@ Valid <installer options> are:
99
Do not wait for the user to press ENTER.
100
Start immediately building it.
101
102
+ --auto-update | -u
103
+
104
+ Install netdata-updater to cron,
105
+ to update netdata automatically once per day
106
+ (can only be done for installation from git)
107
+
108
--enable-plugin-freeipmi
109
--disable-plugin-freeipmi
110
@@ -203,6 +210,10 @@ do
210
then
211
DONOTWAIT=1
212
shift 1
213
+ elif [ "$1" = "--auto-update" -o "$1" = "-u" ]
214
+ then
215
+ AUTOUPDATE=1
216
+ shift 1
217
elif [ "$1" = "--enable-plugin-freeipmi" ]
218
then
219
NETDATA_CONFIGURE_OPTIONS="${NETDATA_CONFIGURE_OPTIONS} --enable-plugin-freeipmi"
@@ -1250,21 +1261,41 @@ REINSTALL
1261
echo >&2 "only if it fails (it does not print anything when it can update netdata).${TPUT_RESET}"
1262
if [ "${UID}" -eq "0" ]
1263
then
1253
- if [ -d "/etc/cron.daily" -a ! -f "/etc/cron.daily/netdata-updater" ]
1264
+ crondir=
1265
+ [ -d "/etc/periodic/daily" ] && crondir="/etc/periodic/daily"
1266
+ [ -d "/etc/cron.daily" ] && crondir="/etc/cron.daily"
1267
+
1268
+ if [ ! -z "${crondir}" ]
1269
+ then
1270
+ if [ -f "${crondir}/netdata-updater.sh" -a ! -f "${crondir}/netdata-updater" ]
1271
then
1255
- echo >&2 "${TPUT_DIM}Run this to automatically check and install netdata updates once per day:${TPUT_RESET}"
1256
- echo >&2
1257
- echo >&2 "${TPUT_YELLOW}${TPUT_BOLD}ln -s ${PWD}/netdata-updater.sh /etc/cron.daily/netdata-updater${TPUT_RESET}"
1258
- elif [ -d "/etc/periodic/daily" -a ! -f "/etc/periodic/daily/netdata-updater" ]
1272
+ # remove .sh from the filename under cron
1273
+ progress "Fixing netdata-updater filename at cron"
1274
+ mv -f "${crondir}/netdata-updater.sh" "${crondir}/netdata-updater"
1275
+ fi
1276
+
1277
+ if [ ! -f "${crondir}/netdata-updater" ]
1278
+ then
1279
+ if [ "${AUTOUPDATE}" = "1" ]
1280
+ then
1281
+ progress "Installing netdata-updater at cron"
1282
+ run ln -s "${PWD}/netdata-updater.sh" "${crondir}/netdata-updater"
1283
+ else
1284
+ echo >&2 "${TPUT_DIM}Run this to automatically check and install netdata updates once per day:${TPUT_RESET}"
1285
+ echo >&2
1286
+ echo >&2 "${TPUT_YELLOW}${TPUT_BOLD}ln -s ${PWD}/netdata-updater.sh ${crondir}/netdata-updater${TPUT_RESET}"
1287
+ fi
1288
+ else if [ "${AUTOUPDATE}" = "1" ]
1289
then
1260
- echo >&2 "${TPUT_DIM}Run this to automatically check and install netdata updates once per day:${TPUT_RESET}"
1261
- echo >&2
1262
- echo >&2 "${TPUT_YELLOW}${TPUT_BOLD}ln -s ${PWD}/netdata-updater.sh /etc/periodic/daily/netdata-updater${TPUT_RESET}"
1290
+ progress "Refreshing netdata-updater at cron"
1291
+ run rm "${crondir}/netdata-updater"
1292
+ run ln -s "${PWD}/netdata-updater.sh" "${crondir}/netdata-updater"
1293
+ fi
1294
fi
1295
fi
1265
-elif [ -f "netdata-updater.sh" ]
1266
- then
1267
- rm "netdata-updater.sh"
1296
+else
1297
+ [ -f "netdata-updater.sh" ] && rm "netdata-updater.sh"
1298
+ [ "${AUTOUPDATE}" = "1" ] && echo >&2 "Your installation method does not support daily auto-updating via cron."
1299
fi
1300
1301
# -----------------------------------------------------------------------------