mirror of
https://github.com/motioneye-project/motioneyeos.git
synced 2025-07-29 14:16:31 +00:00
Add support for post-upgrade scripts with network
This commit is contained in:
parent
6d374f64b7
commit
8ea36fe63d
@ -3,6 +3,7 @@
|
||||
SYS_VERSION_FILE="/etc/version"
|
||||
VERSION_FILE="/data/etc/version"
|
||||
POST_UPGRADE_DIR="/usr/share/post-upgrade"
|
||||
POST_UPGRADE_NET_SCHEDULED="/data/.post-upgrade-net-scheduled"
|
||||
|
||||
LOG="/var/log/post-upgrade.log"
|
||||
|
||||
@ -30,11 +31,18 @@ function run_post_upgrade() {
|
||||
|
||||
echo "---- post-upgrade from ${version} to ${sys_version} ----" >> ${LOG}
|
||||
|
||||
versions=$(ls -1 ${POST_UPGRADE_DIR} | cut -d '.' -f 1)
|
||||
echo -n > ${POST_UPGRADE_NET_SCHEDULED}
|
||||
|
||||
versions=$(ls -1 ${POST_UPGRADE_DIR} | rev | cut -d '.' -f 2-100 | rev)
|
||||
for v in ${versions}; do
|
||||
if [[ ${v} == "post-upgrade" ]]; then
|
||||
continue
|
||||
fi
|
||||
|
||||
if [[ ${v} == *-net ]]; then # scripts that require network
|
||||
echo "${POST_UPGRADE_DIR}/${v}.sh" >> ${POST_UPGRADE_NET_SCHEDULED}
|
||||
continue
|
||||
fi
|
||||
|
||||
if [[ -z "${version}" ]] || version_gt ${v} ${version}; then
|
||||
msg_begin "Post-upgrading to version ${v}"
|
||||
@ -66,4 +74,3 @@ case "$1" in
|
||||
esac
|
||||
|
||||
exit $?
|
||||
|
||||
|
36
board/common/overlay/etc/init.d/S42postupgradenet
Executable file
36
board/common/overlay/etc/init.d/S42postupgradenet
Executable file
@ -0,0 +1,36 @@
|
||||
#!/bin/bash
|
||||
|
||||
POST_UPGRADE_NET_SCHEDULED="/data/.post-upgrade-net-scheduled"
|
||||
|
||||
LOG="/var/log/post-upgrade.log"
|
||||
|
||||
|
||||
test -n "${OS_VERSION}" || source /etc/init.d/base
|
||||
|
||||
test -s ${POST_UPGRADE_NET_SCHEDULED} || exit 0
|
||||
|
||||
function run_post_upgrade() {
|
||||
for script in $(cat ${POST_UPGRADE_NET_SCHEDULED}); do
|
||||
msg_begin "Running post-upgrade script ${script}"
|
||||
${script} >> ${LOG} 2>&1
|
||||
test $? == 0 && msg_done || msg_fail
|
||||
done
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
start)
|
||||
run_post_upgrade
|
||||
rm ${POST_UPGRADE_NET_SCHEDULED}
|
||||
;;
|
||||
|
||||
stop)
|
||||
true
|
||||
;;
|
||||
|
||||
*)
|
||||
echo "Usage: $0 {start}"
|
||||
exit 1
|
||||
esac
|
||||
|
||||
exit $?
|
||||
|
Loading…
x
Reference in New Issue
Block a user