copy updater script instead of linking it (#5010)
* copy updater script instead of linking it fix lifecycle test * better installation msg * updater and uninstaller shouldn't be in .gitignore * discard copied uninstaller script
Paweł Krupa committed
Jan 2, 2019 at 11:03 UTC
8839f96e1fe274daaecb7482df6b09a9022b9903
3 files changed
+27
-37
.gitignore
-1
@@ -104,7 +104,6 @@ collectors/fping.plugin/fping.plugin
104
105
# installer generated files
106
netdata-uninstaller.sh
107
-netdata-updater.sh
107
108
# cmake files
109
cmake-build-debug/
netdata-installer.sh
+20
-29
@@ -911,44 +911,35 @@ END
911
echo >&2 "Uninstall script is located at: ${TPUT_RED}${TPUT_BOLD}./netdata-uninstaller.sh${TPUT_RESET}"
912
913
if [ -d .git ]; then
914
- cp ./packaging/installer/netdata-updater.sh netdata-updater.sh
915
- sed -i "s|THIS_SHOULD_BE_REPLACED_BY_INSTALLER_SCRIPT|${REINSTALL_PWD}|" netdata-updater.sh
916
- chmod 755 netdata-updater.sh
917
- echo >&2 "Update script is located at: ${TPUT_GREEN}${TPUT_BOLD}./netdata-updater.sh${TPUT_RESET}"
918
- echo >&2
919
- echo >&2 "${TPUT_DIM}${TPUT_BOLD}netdata-updater.sh${TPUT_RESET}${TPUT_DIM} can work from cron. It will trigger an email from cron"
920
- echo >&2 "only if it fails (it does not print anything when it can update netdata).${TPUT_RESET}"
921
- if [ "${UID}" -eq "0" ]; then
914
+ if [ "${UID}" -ne "0" ]; then
915
+ [ "${AUTOUPDATE}" = "1" ] && echo >&2 "You need to run the installer as root for auto-updating via cron."
916
+ else
917
crondir=
918
[ -d "/etc/periodic/daily" ] && crondir="/etc/periodic/daily"
919
[ -d "/etc/cron.daily" ] && crondir="/etc/cron.daily"
920
926
- if [ ! -z "${crondir}" ]; then
927
- if [ -f "${crondir}/netdata-updater.sh" -a ! -f "${crondir}/netdata-updater" ]; then
928
- # remove .sh from the filename under cron
929
- progress "Fixing netdata-updater filename at cron"
930
- mv -f "${crondir}/netdata-updater.sh" "${crondir}/netdata-updater"
921
+ if [ -z "${crondir}" ]; then
922
+ [ "${AUTOUPDATE}" = "1" ] && echo >&2 "Cannot figure out the cron directory to install netdata-updater"
923
+ else
924
+ if [ -f "${crondir}/netdata-updater.sh" ]; then
925
+ progress "Removing incorrect netdata-updater filename in cron"
926
+ rm -f "${crondir}/netdata-updater.sh"
927
fi
928
933
- if [ ! -f "${crondir}/netdata-updater" ]; then
934
- if [ "${AUTOUPDATE}" = "1" ]; then
935
- progress "Installing netdata-updater at cron"
936
- run ln -fs "${PWD}/netdata-updater.sh" "${crondir}/netdata-updater"
937
- else
938
- echo >&2 "${TPUT_DIM}Run this to automatically check and install netdata updates once per day:${TPUT_RESET}"
939
- echo >&2
940
- echo >&2 "${TPUT_YELLOW}${TPUT_BOLD}sudo ln -fs ${PWD}/netdata-updater.sh ${crondir}/netdata-updater${TPUT_RESET}"
941
- fi
929
+ if [ "${AUTOUPDATE}" = "1" ]; then
930
+ progress "Installing new netdata-updater in cron"
931
+ sed "s|THIS_SHOULD_BE_REPLACED_BY_INSTALLER_SCRIPT|${REINSTALL_PWD}|" ./packaging/installer/netdata-updater.sh > ${crondir}/netdata-updater
932
+ chmod 0755 ${crondir}/netdata-updater
933
+ echo >&2 "Update script is located at ${TPUT_GREEN}${TPUT_BOLD}${crondir}/netdata-updater${TPUT_RESET}"
934
+ echo >&2
935
+ echo >&2 "By default ${TPUT_DIM}${TPUT_BOLD}netdata-updater${TPUT_RESET}${TPUT_DIM} works from cron. It will trigger an email from cron"
936
+ echo >&2 "only if it fails (it should not print anything when it can update netdata).${TPUT_RESET}"
937
else
943
- progress "Refreshing netdata-updater at cron"
944
- run rm "${crondir}/netdata-updater"
945
- run ln -fs "${PWD}/netdata-updater.sh" "${crondir}/netdata-updater"
938
+ echo >&2 "${TPUT_DIM}Run this to automatically check and install netdata updates once per day:${TPUT_RESET}"
939
+ echo >&2
940
+ echo >&2 "${TPUT_YELLOW}${TPUT_BOLD}sudo ${crondir}/netdata-updater${TPUT_RESET}"
941
fi
947
- else
948
- [ "${AUTOUPDATE}" = "1" ] && echo >&2 "Cannot figure out the cron directory to install netdata-updater."
942
fi
950
- else
951
- [ "${AUTOUPDATE}" = "1" ] && echo >&2 "You need to run the installer as root for auto-updating via cron."
943
fi
944
else
945
[ -f "netdata-updater.sh" ] && rm "netdata-updater.sh"
tests/lifecycle.sh
+7
-7
@@ -15,20 +15,20 @@ git config user.email "test@example.com"
15
git config user.name "test"
16
17
echo "========= INSTALL ========="
18
-./netdata-installer.sh --dont-wait --dont-start-it --install /tmp &>/dev/null
18
+./netdata-installer.sh --dont-wait --dont-start-it --auto-update --install /tmp &>/dev/null
19
# Copy uninstaller as upgrader will overwrite it with a version from master branch
20
cp netdata-uninstaller.sh /tmp/netdata-uninstaller.sh
21
22
echo "========= ADD GARBAGE ========="
23
-touch test
24
-git add test
23
+touch garbagefile
24
+git add garbagefile
25
git commit -m 'test commit'
26
touch new_file
27
git status
28
29
echo "========= UPDATE ========="
30
-./netdata-updater.sh
30
+/etc/periodic/daily/netdata-updater
31
32
-#echo "========= UNINSTALL ========="
33
-#mv /tmp/netdata-uninstaller.sh ./netdata-uninstaller.sh
34
-#./netdata-uninstaller.sh --yes --force
32
+echo "========= UNINSTALL ========="
33
+mv /tmp/netdata-uninstaller.sh ./netdata-uninstaller.sh
34
+./netdata-uninstaller.sh --yes --force