diff --git a/src/common/system/settings.h b/src/common/system/settings.h index 00b441de82..46417bfa29 100644 --- a/src/common/system/settings.h +++ b/src/common/system/settings.h @@ -10,7 +10,7 @@ #include "utils/json.h" #define MAX_BRIGHTNESS 10 -#define MAIN_UI_SETTINGS "/appconfigs/system.json" +#define MAIN_UI_SETTINGS "/mnt/SDCARD/system.json" #define CMD_TO_RUN_PATH "/mnt/SDCARD/.tmp_update/cmd_to_run.sh" #define RETROARCH_CONFIG "/mnt/SDCARD/RetroArch/.retroarch/retroarch.cfg" #define HISTORY_PATH \ diff --git a/src/common/theme/load.h b/src/common/theme/load.h index 565cc58436..8f5258805f 100644 --- a/src/common/theme/load.h +++ b/src/common/theme/load.h @@ -8,7 +8,7 @@ #include "utils/file.h" #include "utils/str.h" -#define SYSTEM_CONFIG "/appconfigs/system.json" +#define SYSTEM_CONFIG "/mnt/SDCARD/system.json" #define FALLBACK_FONT "/customer/app/Exo-2-Bold-Italic.ttf" #define FALLBACK_PATH "/mnt/SDCARD/miyoo/app/" #define SYSTEM_RESOURCES "/mnt/SDCARD/.tmp_update/res/" diff --git a/src/tweaks/reset.h b/src/tweaks/reset.h index f60477698b..cb6591db1a 100644 --- a/src/tweaks/reset.h +++ b/src/tweaks/reset.h @@ -102,10 +102,10 @@ void action_resetMainUI(void *pt) if (!_disable_confirm && !_confirmReset(title_str, "Are you sure you want to\nreset MainUI settings?")) return; - system("rm -f /appconfigs/system.json"); + system("rm -f /mnt/SDCARD/system.json"); char cmd_str[80]; - sprintf(cmd_str, "cp /mnt/SDCARD/.tmp_update/res/miyoo%d_system.json /appconfigs/system.json", DEVICE_ID); + sprintf(cmd_str, "cp /mnt/SDCARD/.tmp_update/res/miyoo%d_system.json /mnt/SDCARD/system.json", DEVICE_ID); system(cmd_str); if (DEVICE_ID == MIYOO354) { diff --git a/static/build/.tmp_update/bin/MainUI-283-clean b/static/build/.tmp_update/bin/MainUI-283-clean index 84f34b3bf5..ea3cd16f24 100644 Binary files a/static/build/.tmp_update/bin/MainUI-283-clean and b/static/build/.tmp_update/bin/MainUI-283-clean differ diff --git a/static/build/.tmp_update/bin/MainUI-283-expert b/static/build/.tmp_update/bin/MainUI-283-expert index 0cdc185d73..d2a958d029 100644 Binary files a/static/build/.tmp_update/bin/MainUI-283-expert and b/static/build/.tmp_update/bin/MainUI-283-expert differ diff --git a/static/build/.tmp_update/bin/MainUI-354-clean b/static/build/.tmp_update/bin/MainUI-354-clean index 79d9662d1a..b62821c449 100644 Binary files a/static/build/.tmp_update/bin/MainUI-354-clean and b/static/build/.tmp_update/bin/MainUI-354-clean differ diff --git a/static/build/.tmp_update/bin/MainUI-354-expert b/static/build/.tmp_update/bin/MainUI-354-expert index e87a389373..184c78e8d2 100644 Binary files a/static/build/.tmp_update/bin/MainUI-354-expert and b/static/build/.tmp_update/bin/MainUI-354-expert differ diff --git a/static/build/.tmp_update/bin/shutdown b/static/build/.tmp_update/bin/shutdown index 08fc70c75b..f568292eab 100644 --- a/static/build/.tmp_update/bin/shutdown +++ b/static/build/.tmp_update/bin/shutdown @@ -28,13 +28,23 @@ if [ "$0" = "/tmp/_shutdown" ]; then killall -9 main # mandatory to avoid the suppression of .tmp_update ! killall -9 updater killall -9 runtime.sh - killall -9 smbd - + killall -9 smbd + kill_hooked_tasks sleep 0.1 kill_hooked_tasks -9 - + sync + + if [ -f /mnt/SDCARD/system.json ]; then + mkdir -p /mnt/SDCARD/.tmp_update/config/system + mv -f /mnt/SDCARD/system.json "/mnt/SDCARD/.tmp_update/config/system/$(read_uuid).json" + sync + fi + + rm -f /appconfigs/system.json 2> /dev/null + rm -f /mnt/SDCARD/update.log 2> /dev/null + umount /etc/passwd /etc/group /etc/profile umount /mnt/SDCARD/miyoo/app/MainUI umount /mnt/SDCARD/RetroArch/retroarch @@ -42,23 +52,23 @@ if [ "$0" = "/tmp/_shutdown" ]; then swapoff /mnt/SDCARD/cachefile umount -r /mnt/SDCARD umount /mnt/SDCARD - + ############# DEBUG ############# # fuser -m /mnt/SDCARD > /appconfigs/shutdown.log # lsof /mnt/SDCARD >> /appconfigs/shutdown.log # mount >> /appconfigs/shutdown.log ################################# - + if [ "$1" = "-r" ]; then /sbin/reboot else if [ "$(cat /tmp/deviceModel)" = "283" ]; then - /sbin/reboot # no poweroff command on Miyoo Mini + /sbin/reboot # no poweroff command on Miyoo Mini else /sbin/poweroff fi fi - + fi if [ ! -f /tmp/_shutdown ]; then @@ -66,7 +76,10 @@ if [ ! -f /tmp/_shutdown ]; then fi # run the script totally detached from current shell -pgrep -f /tmp/_shutdown || (set -m; su root -c "/usr/bin/nohup /tmp/_shutdown $1 /dev/null 2>&1 &") +pgrep -f /tmp/_shutdown || ( + set -m + su root -c "/usr/bin/nohup /tmp/_shutdown $1 /dev/null 2>&1 &" +) while true; do sleep 10 done diff --git a/static/build/.tmp_update/runtime.sh b/static/build/.tmp_update/runtime.sh index 03d6ed5241..09dd33582a 100644 --- a/static/build/.tmp_update/runtime.sh +++ b/static/build/.tmp_update/runtime.sh @@ -496,6 +496,26 @@ init_system() { start_audioserver + device_settings="/mnt/SDCARD/.tmp_update/config/system/$(read_uuid).json" + if [ -f "$device_settings" ]; then + cp -f "$device_settings" /mnt/SDCARD/system.json + fi + + # make sure MainUI settings exist + if [ ! -f /mnt/SDCARD/system.json ]; then + if [ -f /appconfigs/system.json ]; then + cp -f /appconfigs/system.json /mnt/SDCARD/system.json + else + cp -f $sysdir/res/miyoo${DEVICE_ID}_system.json /mnt/SDCARD/system.json + fi + fi + + # link /appconfigs/system.json to SD card + if [ -L /appconfigs/system.json ] && [ "$(readlink /appconfigs/system.json)" == "/mnt/SDCARD/system.json" ]; then + rm /appconfigs/system.json + fi + ln -s /mnt/SDCARD/system.json /appconfigs/system.json + if [ $DEVICE_ID -eq $MODEL_MM ]; then # init charger detection if [ ! -f /sys/devices/gpiochip0/gpio/gpio59/direction ]; then @@ -505,11 +525,11 @@ init_system() { if [ $(/customer/app/jsonval vol) -ne 20 ] || [ $(/customer/app/jsonval mute) -ne 0 ]; then # Force volume and mute settings - cat /appconfigs/system.json | + cat /mnt/SDCARD/system.json | sed 's/^\s*"vol":\s*[0-9][0-9]*/\t"vol":\t20/g' | sed 's/^\s*"mute":\s*[0-9][0-9]*/\t"mute":\t0/g' \ > temp - mv -f temp /appconfigs/system.json + mv -f temp /mnt/SDCARD/system.json fi fi diff --git a/static/build/.tmp_update/script/diagnostics/util_snapshot.sh b/static/build/.tmp_update/script/diagnostics/util_snapshot.sh index 1b1f4fd1d0..2ae7ea45e7 100644 --- a/static/build/.tmp_update/script/diagnostics/util_snapshot.sh +++ b/static/build/.tmp_update/script/diagnostics/util_snapshot.sh @@ -37,10 +37,10 @@ program=$(basename "$0" .sh) ################## main() { - log "Generating system snapshot, please wait" - snapshot - log "Starting exporter" - $diagsdir/util_exporter.sh + log "Generating system snapshot, please wait" + snapshot + log "Starting exporter" + $diagsdir/util_exporter.sh } ################## @@ -102,18 +102,18 @@ get_lcd_voltage() { # Check LCD voltage incase it's been changed by user echo "$((voltage_tenths / 10)).$((voltage_tenths % 10)) volts." } -actual_uptime() { +actual_uptime() { uptime=$(cut -d. -f1 /proc/uptime) - + uptime_days=$((uptime / 60 / 60 / 24)) uptime_hours=$((uptime / 60 / 60 % 24)) uptime_minutes=$((uptime / 60 % 60)) uptime_seconds=$((uptime % 60)) - + echo "Uptime: $uptime_days days, $uptime_hours hours, $uptime_minutes minutes, $uptime_seconds seconds" } -system_healthcheck () { +system_healthcheck() { log "Generating system healthcheck" write_info "Onion version:" "cat $sysdir/onionVersion/version.txt" $sysinfo_file write_info "Firmware version:" "/etc/fw_printenv miyoo_version" $sysinfo_file @@ -130,9 +130,9 @@ system_healthcheck () { write_info "LCD Voltage:" "get_lcd_voltage" $sysinfo_file write_info "Framebuffer info:" "cat /proc/mi_modules/fb/mi_fb0" $sysinfo_file write_info "More framebuffer info:" "fbset" $sysinfo_file - write_info "System.json state:" "cat /appconfigs/system.json" $sysinfo_file - write_info "Keymap state:" "cat $sysdir/config/keymap.json" $sysinfo_file - write_info "Config folder dump" "ls -alhR $sysdir/config/" $sysinfo_file + write_info "System.json state:" "cat /mnt/SDCARD/system.json" $sysinfo_file + write_info "Keymap state:" "cat $sysdir/config/keymap.json" $sysinfo_file + write_info "Config folder dump" "ls -alhR $sysdir/config/" $sysinfo_file dmesg > "$workingdir/sysinfo/dmesg.log" log "Finished generating healthcheck" } @@ -173,11 +173,11 @@ wpa_supplicant_health_check() { fi } -wpa_supplicant_contains_networks() { +wpa_supplicant_contains_networks() { if [[ -f "$wpa_conf_path" ]]; then num_ssids=$(grep -c "ssid=" "$wpa_conf_path") num_disabled=$(grep -c "disabled=" "$wpa_conf_path") - + echo "$num_ssids SSIDs configured, $num_disabled SSIDs disabled" else echo "Wpa_supplicant.conf is not present" @@ -185,11 +185,11 @@ wpa_supplicant_contains_networks() { } get_wpa_supplicant() { # print the file aswell but remove the users ssid/psk - worth doing a full formatting check on the file incase syntax is broken by someone manually editing. - if [ ! -f "$wpa_conf_path" ]; then - echo "File not found: $wpa_conf_path" - fi + if [ ! -f "$wpa_conf_path" ]; then + echo "File not found: $wpa_conf_path" + fi - sed 's/ssid="[^"]*"/ssid="redacted"/g; s/psk="[^"]*"/psk="redacted"/g' "$wpa_conf_path" + sed 's/ssid="[^"]*"/ssid="redacted"/g; s/psk="[^"]*"/psk="redacted"/g' "$wpa_conf_path" } check_hostapd_conf() { @@ -221,7 +221,7 @@ wifi_healthcheck() { write_info "Network service:" "get_netserv_status" $networkinfo_file write_info "Checking size of hostapd.conf:" "check_hostapd_conf" $networkinfo_file write_info "Checking size of dnsmasq.conf" "check_dnsmasq_conf" $networkinfo_file - write_info "Wpa_supplicant.conf health:" "wpa_supplicant_health_check" $networkinfo_file + write_info "Wpa_supplicant.conf health:" "wpa_supplicant_health_check" $networkinfo_file write_info "Wpa_supplicant.conf ssid count:" "wpa_supplicant_contains_networks" $networkinfo_file write_info "Wpa_supplicant.conf sanitised dump:" "get_wpa_supplicant" $networkinfo_file write_info "WiFi Status:" "ifconfig" $networkinfo_file @@ -265,9 +265,9 @@ create_dir_logs() { # Currently creates a list of roms which can take a while de fi done } - + ################## ## CALL MAIN FUNCTION ## ################## -main "$@" \ No newline at end of file +main "$@" diff --git a/static/build/.tmp_update/script/network/wpsclient.sh b/static/build/.tmp_update/script/network/wpsclient.sh index 9d5a2d839f..730590e27e 100644 --- a/static/build/.tmp_update/script/network/wpsclient.sh +++ b/static/build/.tmp_update/script/network/wpsclient.sh @@ -7,9 +7,9 @@ export IMGPOP=$sysdir/bin/imgpop # Syntax: ./imgpop duration delay image_path x_position y_position. main() { - if ifconfig wlan0 &>/dev/null; then + if ifconfig wlan0 &> /dev/null; then if is_running wpa_supplicant && is_running udhcpc; then - wifiup + wifiup fi sleep 1 log "WPS: Wi-Fi is up" @@ -25,19 +25,19 @@ main() { wpa_supplicant -B -D nl80211 -iwlan0 -c /appconfigs/wpa_supplicant.conf sleep 2 killall -9 imgpop - sed -i 's/"wifi":\s*0/"wifi": 1/' /appconfigs/system.json # tell mainui that wifi needs to be kept up once started - + sed -i 's/"wifi":\s*0/"wifi": 1/' /mnt/SDCARD/system.json # tell mainui that wifi needs to be kept up once started + if is_running wpa_supplicant; then wifiup sleep 1 fi - + touch /tmp/dont_restart_wifi sync fi start_udhcpc - $WPACLI disable_network all > /dev/null 2>&1 &# disconnect any existing networks + $WPACLI disable_network all > /dev/null 2>&1 & # disconnect any existing networks log "WPS: Disconnecting from current network" $WPACLI wps_pbc # start wps log "WPS: Trying to connect to WPS host" @@ -45,7 +45,7 @@ main() { start_time=$(date +%s) while true; do - IP=$(ip route get 1 2>/dev/null | awk '{print $NF;exit}') + IP=$(ip route get 1 2> /dev/null | awk '{print $NF;exit}') if [ -z "$IP" ]; then wpsflicker @@ -60,9 +60,9 @@ main() { log "WPS: Failed to connect.." sleep 5 exit - else + else wpsconnected - fi + fi fi else break @@ -77,8 +77,8 @@ main() { exit } -start_udhcpc(){ - udhcpc -i wlan0 -s /etc/init.d/udhcpc.script > /dev/null 2>&1 & +start_udhcpc() { + udhcpc -i wlan0 -s /etc/init.d/udhcpc.script > /dev/null 2>&1 & } kill_udhcpc() { @@ -89,7 +89,7 @@ kill_udhcpc() { conn_cleanup() { kill_udhcpc - start_udhcpc + start_udhcpc } is_running() { @@ -97,11 +97,11 @@ is_running() { pgrep "$process_name" > /dev/null } -wifiquery(){ +wifiquery() { $IMGPOP 5 0 "$icondir/wifiquery.png" 84 428 > /dev/null 2>&1 & } -wifiup(){ +wifiup() { $IMGPOP 5 0 "$icondir/wifiup.png" 84 428 > /dev/null 2>&1 & } diff --git a/static/dist/miyoo/app/.tmp_update/install.sh b/static/dist/miyoo/app/.tmp_update/install.sh index 02d8413959..a4185ac4ef 100644 --- a/static/dist/miyoo/app/.tmp_update/install.sh +++ b/static/dist/miyoo/app/.tmp_update/install.sh @@ -294,7 +294,7 @@ run_installation() { if [ $system_only -ne 1 ]; then if [ $reset_configs -eq 1 ]; then - cp -f $sysdir/res/miyoo${DEVICE_ID}_system.json /appconfigs/system.json + cp -f $sysdir/res/miyoo${DEVICE_ID}_system.json /mnt/SDCARD/system.json fi # Start the battery monitor