mirror of
https://github.com/gtxaspec/wz_mini_hacks.git
synced 2024-11-25 14:57:19 +00:00
fix upgrading from old layout
This commit is contained in:
parent
45f89119ce
commit
be472d5afa
@ -43,7 +43,7 @@ fi
|
||||
|
||||
install_upgrade_script() {
|
||||
echo "Installing latest upgrade-script"
|
||||
cp /opt/Upgrade/wz_mini_hacks-master/SD_ROOT/wz_mini/usr/bin/upgrade-run.sh /opt/wz_mini/bin/upgrade-run.sh
|
||||
cp /opt/Upgrade/wz_mini_hacks-master/SD_ROOT/wz_mini/bin/upgrade-run.sh /opt/wz_mini/bin/upgrade-run.sh
|
||||
/opt/wz_mini/bin/upgrade-run.sh backup_begin
|
||||
}
|
||||
|
||||
|
171
SD_ROOT/wz_mini/usr/bin/upgrade-run.sh
Executable file
171
SD_ROOT/wz_mini/usr/bin/upgrade-run.sh
Executable file
@ -0,0 +1,171 @@
|
||||
#!/bin/sh
|
||||
|
||||
if [ -L /dev/fd ]; then
|
||||
echo fd exists
|
||||
else
|
||||
echo fd does not exist, link
|
||||
ln -s /proc/self/fd /dev/fd
|
||||
fi
|
||||
|
||||
LOG_FILE=/opt/upgrade_wz_mini.log
|
||||
exec > >(busybox tee -a ${LOG_FILE}) 2>&1
|
||||
|
||||
setup() {
|
||||
|
||||
echo "Create Upgrade directory"
|
||||
mkdir /opt/Upgrade
|
||||
|
||||
echo "Create backup files directory"
|
||||
mkdir /opt/Upgrade/preserve
|
||||
|
||||
echo "Download latest master"
|
||||
wget --no-check-certificate https://github.com/gtxaspec/wz_mini_hacks/archive/refs/heads/master.zip -O /opt/Upgrade/wz_mini.zip; sync
|
||||
|
||||
echo "Extract archive"
|
||||
unzip /opt/Upgrade/wz_mini.zip -d /opt/Upgrade/
|
||||
|
||||
echo "Verify file integrity"
|
||||
cd /opt/Upgrade/wz_mini_hacks-master
|
||||
md5sum -c file.chk
|
||||
|
||||
if [ $? -eq 0 ]
|
||||
then
|
||||
echo "files OK"
|
||||
install_upgrade_script
|
||||
else
|
||||
echo "Failure: archive has corrupted files"
|
||||
echo "Delete failed upgrade dir"
|
||||
rm -rf /opt/Upgrade
|
||||
exit 1
|
||||
fi
|
||||
|
||||
}
|
||||
|
||||
install_upgrade_script() {
|
||||
echo "Installing latest upgrade-script"
|
||||
cp /opt/Upgrade/wz_mini_hacks-master/SD_ROOT/wz_mini/bin/upgrade-run.sh /opt/wz_mini/bin/upgrade-run.sh
|
||||
/opt/wz_mini/bin/upgrade-run.sh backup_begin
|
||||
}
|
||||
|
||||
backup_begin() {
|
||||
echo "Backup user config"
|
||||
cp /opt/wz_mini/wz_mini.conf /opt/Upgrade/preserve/
|
||||
cp -r /opt/wz_mini/etc/configs /opt/Upgrade/preserve/
|
||||
cp -r /opt/wz_mini/etc/ssh /opt/Upgrade/preserve/
|
||||
cp -r /opt/wz_mini/etc/wireguard /opt/Upgrade/preserve/
|
||||
sync
|
||||
|
||||
echo "Rebooting into UPGRADE MODE"
|
||||
reboot
|
||||
}
|
||||
|
||||
|
||||
upgrade_mode_start() {
|
||||
|
||||
export WZMINI_CFG=/opt/wz_mini/wz_mini.conf
|
||||
|
||||
[ -f $WZMINI_CFG ] && source $WZMINI_CFG
|
||||
|
||||
set -x
|
||||
|
||||
#WCV3 AUDIO GPIO
|
||||
GPIO=63
|
||||
V2="false"
|
||||
|
||||
#Check model, change GPIO is HL_PAN2
|
||||
if [[ "$V2" == "false" ]]; then
|
||||
mount -t jffs2 /dev/mtdblock6 /configs
|
||||
if [[ $(cat /configs/.product_config | grep PRODUCT_MODEL) == "PRODUCT_MODEL=HL_PAN2" ]]; then
|
||||
umount /configs
|
||||
GPIO=7
|
||||
fi
|
||||
else
|
||||
echo "not HL_PAN2"
|
||||
fi
|
||||
|
||||
|
||||
#test for v2
|
||||
if [ -b /dev/mtdblock9 ]; then
|
||||
mount -t jffs2 /dev/mtdblock9 /params
|
||||
if cat /params/config/.product_config | grep WYZEC1-JZ; then
|
||||
V2="true"
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
if [[ "$V2" == "true" ]]; then
|
||||
insmod /opt/wz_mini/lib/modules/3.10.14/kernel/audio.ko
|
||||
LD_LIBRARY_PATH='/opt/wz_mini/lib' /opt/wz_mini/bin/audioplay_t20 /opt/wz_mini/usr/share/audio/upgrade_mode_v2.wav $AUDIO_PROMPT_VOLUME
|
||||
rmmod audio
|
||||
else
|
||||
insmod /opt/wz_mini/lib/modules/3.10.14__isvp_swan_1.0__/kernel/audio.ko spk_gpio=$GPIO alc_mode=0 mic_gain=0
|
||||
/opt/wz_mini/bin/audioplay_t31 /opt/wz_mini/usr/share/audio/upgrade_mode.wav $AUDIO_PROMPT_VOLUME
|
||||
rmmod audio
|
||||
fi
|
||||
|
||||
echo UPGRADE MODE
|
||||
|
||||
umount -l /opt/wz_mini/tmp
|
||||
ls -l /opt/wz_mini/
|
||||
rm -rf /opt/wz_mini/*
|
||||
sync
|
||||
mv /opt/Upgrade/wz_mini_hacks-master/SD_ROOT/wz_mini/* /opt/wz_mini/
|
||||
rm -f /opt/factory_t31_ZMC6tiIDQN
|
||||
mv /opt/Upgrade/wz_mini_hacks-master/SD_ROOT/factory_t31_ZMC6tiIDQN /opt/factory_t31_ZMC6tiIDQN
|
||||
|
||||
diff /opt/wz_mini/wz_mini.conf /opt/Upgrade/preserve/wz_mini.conf
|
||||
|
||||
if [ $(cat /opt/Upgrade/preserve/wz_mini.conf | wc -l) != $(cat /opt/wz_mini/wz_mini.conf | wc -l) ]; then
|
||||
echo "doesn't match, keep old config"
|
||||
mv /opt/wz_mini/wz_mini.conf /opt/wz_mini/wz_mini.conf.dist
|
||||
cp /opt/Upgrade/preserve/wz_mini.conf /opt/wz_mini/
|
||||
else
|
||||
echo "configs match"
|
||||
cp /opt/Upgrade/preserve/wz_mini.conf /opt/wz_mini/
|
||||
fi
|
||||
|
||||
cp /opt/Upgrade/preserve/ssh/* /opt/wz_mini/etc/ssh/
|
||||
cp /opt/Upgrade/preserve/configs/* /opt/wz_mini/etc/configs
|
||||
cp -r /opt/Upgrade/preserve/wireguard /opt/wz_mini/etc/
|
||||
rm -rf /opt/Upgrade
|
||||
sync
|
||||
reboot
|
||||
|
||||
}
|
||||
|
||||
if [[ -e /tmp/dbgflag ]]; then
|
||||
upgrade_mode_start
|
||||
else
|
||||
|
||||
if [ "$1" == "backup_begin" ]; then
|
||||
backup_begin
|
||||
else
|
||||
|
||||
read -r -p "${1:-wz_mini, this will download the latest version from github and upgrade your system. Are you sure? [y/N]} " response
|
||||
case "$response" in
|
||||
[yY][eE][sS]|[yY])
|
||||
if [[ -d /opt/Upgrade ]]; then
|
||||
echo "WARNING: Old Upgrade directory exists"
|
||||
read -r -p "${1:-Unable to proceed, must DELETE old Upgrade directory, are you sure? [y/N]} " response
|
||||
case "$response" in
|
||||
[yY][eE][sS]|[yY])
|
||||
rm -rf /opt/Upgrade
|
||||
sync
|
||||
setup
|
||||
;;
|
||||
*)
|
||||
echo "User denied directory removal, exit"
|
||||
;;
|
||||
esac
|
||||
else
|
||||
setup
|
||||
fi
|
||||
|
||||
;;
|
||||
*)
|
||||
echo "User declined system update, exit"
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
fi
|
3
file.chk
3
file.chk
@ -49,7 +49,7 @@ a8970288e72c871bff6a4484f1e733d6 SD_ROOT/wz_mini/bin/readelf
|
||||
41b56bb30f02bce5f5e2598073151e16 SD_ROOT/wz_mini/bin/ffmpeg
|
||||
e37474a12d76cae16336476cba61e8b8 SD_ROOT/wz_mini/bin/neofetch
|
||||
7fcc716cda1e024dae1045050a135beb SD_ROOT/wz_mini/bin/audioplay_t31
|
||||
700cf139048c487fe60e3eb52416b537 SD_ROOT/wz_mini/bin/upgrade-run.sh
|
||||
d010b7a3e0c22fa6ea7fe1b53a13c119 SD_ROOT/wz_mini/bin/upgrade-run.sh
|
||||
e6a6a9dd8ce138686083a3d4303cea40 SD_ROOT/wz_mini/bin/iperf3
|
||||
0468ffb319707687557353242a518923 SD_ROOT/wz_mini/bin/wg
|
||||
65510c6c4d0db4b4679fc92d1c617fdd SD_ROOT/wz_mini/bin/rtmp-stream.sh
|
||||
@ -77,6 +77,7 @@ ac9f3a5d097d25d5d972c3d2ad288df9 SD_ROOT/wz_mini/usr/bin/ucamera_v2
|
||||
cf049b9446094cc8a7e07a33cf91c4a8 SD_ROOT/wz_mini/usr/bin/watch_up.sh
|
||||
b339aee882a5d1c943ad08e4282ec3fd SD_ROOT/wz_mini/usr/bin/iCamera-dbg
|
||||
20b061689308b2cee7edf3b9b906bca7 SD_ROOT/wz_mini/usr/bin/ucamera
|
||||
d010b7a3e0c22fa6ea7fe1b53a13c119 SD_ROOT/wz_mini/usr/bin/upgrade-run.sh
|
||||
580b1b6e91e72b4a4fef7b21d8954403 SD_ROOT/wz_mini/usr/bin/getSensorType
|
||||
4c780f0455481d106d47d89f0ae04ed5 SD_ROOT/wz_mini/lib/uClibc.tar
|
||||
9afeb088e4cbabbe0b04033b560204d0 SD_ROOT/wz_mini/lib/libimp.so
|
||||
|
Loading…
Reference in New Issue
Block a user