added post-upgrade commands support

This commit is contained in:
Calin Crisan 2015-11-28 20:29:48 +02:00
parent 1a663e7ba8
commit a48ba71660
2 changed files with 60 additions and 0 deletions

View File

@ -0,0 +1,53 @@
#!/bin/bash
test -n "$os_version" || source /etc/init.d/base
sys_version_file="/etc/version"
version_file="/data/etc/version"
post_upgrade_dir="/usr/share/post-upgrade"
hash=$(md5sum $version_file 2>/dev/null | cut -d ' ' -f 1)
sys_hash=$(md5sum $sys_version_file 2>/dev/null | cut -d ' ' -f 1)
test "$hash" == "$sys_hash" && exit 0
function version_gt() {
if [ "$1" != "$2" ] && [ $(echo -e "$2\n$1" | sort -t . | head -n 1) == "$2" ]; then
return 0
else
return 1
fi
}
function run_post_upgrade() {
version="$(source $version_file 2>/dev/null && echo $os_version)"
sys_version="$(source $sys_version_file 2>/dev/null && echo $os_version)"
versions=$(ls -1 $post_upgrade_dir | cut -d '.' -f 1)
for v in $versions; do
if [ -z "$version" ] || version_gt $v $version; then
msg_begin "Post-upgrading to version $v"
out=$($post_upgrade_dir/$v.sh 2>&1)
test $? == 0 && msg_done || msg_fail
echo "$out" | logger -t post-upgrade
fi
done
}
case "$1" in
start)
run_post_upgrade
cp $sys_version_file $version_file
;;
stop)
true
;;
*)
echo "Usage: $0 {start}"
exit 1
esac
exit $?

View File

@ -0,0 +1,7 @@
#!/bin/bash
# option "thumbnailer_interval" has been removed from motionEye config
grep -v 'thumbnailer_interval' /data/etc/motioneye.conf > /tmp/motioneye.conf
mv /tmp/motioneye.conf /data/etc/