@@ -42,6 +42,8 @@ sleep 0.5
4242zm_print " 📱 Detecting Architecture" 0.3 " h"
4343
4444. " $MODPATH /common.sh"
45+ . " $MODPATH /install_i18n.sh"
46+ . " $MODPATH /install_func.sh"
4547if [ -z " $ABI " ]; then
4648 abort " ❌ Unsupported architecture: $( uname -m) "
4749fi
@@ -118,34 +120,48 @@ ZM_DATA="/data/adb/zeromount"
118120zm_print " 📁 Preparing Data" 0.3 " h"
119121
120122FRESH_INSTALL=false
123+ USER_RESET=false
124+ mkdir -p " $ZM_DATA "
125+ mkdir -p " $ZM_DATA /logs"
126+
127+ if [ ! -f " $ZM_DATA /config.toml" ] && [ -f " $ZM_DATA /.stash/config.toml" ]; then
128+ restore_stash && zm_print " ✅ $( _msg config_stash_restored) "
129+ fi
130+
121131if [ ! -f " $ZM_DATA /config.toml" ]; then
122132 FRESH_INSTALL=true
123133fi
124134
125- # Upgrade detection (PIF-style): old module dir exists → preserve settings,
126- # clean stale state, and restore SELinux contexts on peer modules.
127135IS_UPGRADE=false
128136OLD_MODULE=" /data/adb/modules/meta-zeromount"
129137if [ -d " $OLD_MODULE " ] && [ " $FRESH_INSTALL " = false ]; then
130138 IS_UPGRADE=true
131139fi
132140
133- mkdir -p " $ZM_DATA "
134- mkdir -p " $ZM_DATA /logs"
135- zm_print " ✅ Data directory ready"
141+ zm_print " ✅ $( _msg data_ready) "
142+
143+ if [ " $FRESH_INSTALL " = false ]; then
144+ ui_print " "
145+ zm_print " ⚙️ $( _msg config_prompt) " 0.3 " h"
146+ zm_print " 🔊 $( _msg vol_up_preserve) "
147+ zm_print " 🔉 $( _msg vol_down_reset) "
148+ ui_print " "
149+ choose_config 0
150+ if [ $? -eq 1 ]; then
151+ USER_RESET=true
152+ fi
153+ fi
136154
137- if [ " $FRESH_INSTALL " = true ]; then
138- zm_print " 🔧 Writing default config "
155+ if [ " $FRESH_INSTALL " = true ] || [ " $USER_RESET " = true ] ; then
156+ zm_print " 🔧 $( _msg config_default ) "
139157 " $BIN " config defaults > " $ZM_DATA /config.toml" 2> /dev/null || true
140- # Snapshot current Android settings so boot-completed doesn't override them
141158 [ " $( settings get global development_settings_enabled 2> /dev/null) " = " 1" ] && \
142159 " $BIN " config set adb.developer_options true 2> /dev/null
143160 [ " $( settings get global adb_enabled 2> /dev/null) " = " 1" ] && \
144161 " $BIN " config set adb.usb_debugging true 2> /dev/null
145162 VBS=$(( 4096 + ($(od - An - tu1 - N1 / dev/ urandom) % 8 ) * 1024 ))
146163 " $BIN " config set brene.vbmeta_size " $VBS " 2> /dev/null
147164 zm_print " ✅ vbmeta_size randomized: $VBS "
148- # Detect device language for WebUI + description strings
149165 DEVICE_LANG=$( getprop ro.system.locale 2> /dev/null)
150166 [ -z " $DEVICE_LANG " ] && DEVICE_LANG=$( getprop persist.sys.locale 2> /dev/null)
151167 [ -z " $DEVICE_LANG " ] && DEVICE_LANG=$( getprop ro.product.locale 2> /dev/null)
@@ -163,9 +179,7 @@ if [ "$FRESH_INSTALL" = true ]; then
163179 esac
164180 " $BIN " config set ui.language " $LANG_CODE " 2> /dev/null
165181else
166- zm_print " ✅ Existing config preserved"
167- # Merge new keys: load fills defaults for missing fields, dump writes them back
168- " $BIN " config dump > " $ZM_DATA /config.toml.tmp" 2> /dev/null && mv " $ZM_DATA /config.toml.tmp" " $ZM_DATA /config.toml"
182+ zm_print " ✅ $( _msg config_preserved) "
169183fi
170184
171185if [ " $IS_UPGRADE " = true ]; then
@@ -203,8 +217,18 @@ VBH_FILE="/data/adb/VerifiedBootHash/VerifiedBootHash.txt"
203217if [ -f " $VBH_FILE " ]; then
204218 VBH=$( cat " $VBH_FILE " 2> /dev/null | head -1 | tr -d ' [:space:]' )
205219 if [ -n " $VBH " ]; then
206- " $BIN " config set brene.verified_boot_hash " $VBH " 2> /dev/null
207- zm_print " ✅ VerifiedBootHash imported"
220+ if [ " $FRESH_INSTALL " = true ] || [ " $USER_RESET " = true ]; then
221+ " $BIN " config set brene.verified_boot_hash " $VBH " 2> /dev/null
222+ zm_print " ✅ $( _msg vbh_imported) "
223+ else
224+ EXISTING_VBH=$( " $BIN " config get brene.verified_boot_hash 2> /dev/null)
225+ if [ -z " $EXISTING_VBH " ]; then
226+ " $BIN " config set brene.verified_boot_hash " $VBH " 2> /dev/null
227+ zm_print " ✅ $( _msg vbh_imported) "
228+ else
229+ zm_print " ✅ $( _msg vbh_kept) "
230+ fi
231+ fi
208232 fi
209233fi
210234
0 commit comments