|
Server IP : 128.199.20.84 / Your IP : 108.162.242.88 Web Server : Apache/2.4.41 (Ubuntu) System : Linux competent-maruti 5.4.0-128-generic #144-Ubuntu SMP Tue Sep 20 11:00:04 UTC 2022 x86_64 User : www-data ( 33) PHP Version : 8.0.20 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare, MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF Directory (0755) : /var/lib/python/../python/../python/../python/../tpm/../python/../dpkg/info/ |
| [ Home ] | [ C0mmand ] | [ Upload File ] |
|---|
#!/bin/sh
# vim: noexpandtab
set -ue
SVC_NAME=droplet-agent
INSTALL_DIR=/opt/digitalocean/${SVC_NAME}
CRON_SCHEDULE=/etc/cron.hourly
CRON=${CRON_SCHEDULE}/${SVC_NAME}
INIT_SVC_FILE="/etc/init/${SVC_NAME}.conf"
SYSTEMD_SVC_FILE="/etc/systemd/system/${SVC_NAME}.service"
main() {
if command -v systemctl >/dev/null 2>&1; then
# systemd is used, remove the upstart script
rm -f "${INIT_SVC_FILE}"
# systemctl enable --now is unsupported on older versions of debian/systemd
echo "enable systemd service"
systemctl daemon-reload
systemctl enable -f ${SVC_NAME}
systemctl restart ${SVC_NAME}
elif command -v initctl >/dev/null 2>&1; then
# upstart is used, remove the systemd script
rm -f "${SYSTEMD_SVC_FILE}"
echo "enable upstart service"
initctl stop ${SVC_NAME} || true
initctl reload-configuration
initctl start ${SVC_NAME}
else
echo "Unknown init system. Exiting..." >/dev/stderr
exit 1
fi
patch_updates
}
patch_updates() {
# make sure we have the latest
[ -f "${CRON}" ] && rm -f "${CRON}"
script="${INSTALL_DIR}/scripts/update.sh"
mkdir -p ${CRON_SCHEDULE}
cat <<-EOF >"${CRON}"
#!/bin/sh
/bin/bash ${script} >/var/log/droplet-agent.update.log 2>&1
EOF
chmod +x "${CRON}"
}
main