2121
2222# Convert old prevent launcher file to new frontend disable file
2323if [ -f " ${PREVENT_LAUNCHER_FILE} " ]; then
24- mv " ${PREVENT_LAUNCHER_FILE} " " {DISABLE_FRONTEND_FILE}"
24+ mv " ${PREVENT_LAUNCHER_FILE} " " $ {DISABLE_FRONTEND_FILE}"
2525fi
2626
2727usage () {
@@ -37,12 +37,12 @@ set_frontend() {
3737 local new_frontend=" ${1} "
3838 echo " Setting frontend: ${new_frontend} "
3939 if [ " ${new_frontend} " = " none" ]; then
40- touch " ${DISABLE_FRONTEND_FILE} "
40+ touch " ${DISABLE_FRONTEND_FILE} "
4141 else
42- rm -f " ${DISABLE_FRONTEND_FILE} "
42+ rm -f " ${DISABLE_FRONTEND_FILE} "
4343 fi
4444 if [ " ${frontend} " != " none" ]; then
45- pkill " ${frontend} "
45+ pkill " ${frontend} "
4646 fi
4747 echo " ${new_frontend} " > " ${FRONTEND_FILE} "
4848}
@@ -52,8 +52,8 @@ get_frontend() {
5252
5353 # Check if not empty
5454 if [ " x${frontend} " = " x" ]; then
55- frontend=" ${DEFAULT_FRONTEND} "
56- echo " ${frontend} " > " ${FRONTEND_FILE} "
55+ frontend=" ${DEFAULT_FRONTEND} "
56+ echo " ${frontend} " > " ${FRONTEND_FILE} "
5757 fi
5858
5959 # Return frontend name
@@ -62,62 +62,63 @@ get_frontend() {
6262
6363init_frontend () {
6464 if [ -f " ${LOCK_FILE} " ]; then
65- >&2 echo " ${LOCK_FILE} already exists"
66- exit 1
65+ >&2 echo " ${LOCK_FILE} already exists"
66+ exit 1
6767 fi
6868 touch " ${LOCK_FILE} "
6969
7070 # Then loop to launch the frontend indefinitely
7171 while true ; do
7272
73- # Check if frontend disable file is present
74- if [ -f " ${DISBALE_FRONTEND_FILE} " ]; then
75- echo " ${DISABLE_FRONTEND_FILE} file found, not starting frontend"
76- sleep 5
77- else
78-
79- # Umount any remaining OPK, if any
80- umount /opk > /dev/null 2>&1
81- rm -f " ${LAST_OPK_FILE} "
82-
83- local frontend=" $( get_frontend) "
84- case " ${frontend} " in
85- gmenu2x|retrofe)
86- " ${frontend} " &
87- ;;
88-
89- none)
90- echo " no frontend"
73+ # Check if frontend disable file is present
74+ if [ -f " ${DISABLE_FRONTEND_FILE} " ]; then
75+ echo " ${DISABLE_FRONTEND_FILE} file found, not starting frontend"
9176 sleep 5
92- ;;
93-
94- * )
95- DEFAULT_FRONTEND=retrofe
96- echo " Unrecognized frontend: $frontend , setting $DEFAULT_FRONTEND "
97- set_frontend " ${DEFAULT_FRONTEND} "
98- ;;
99- esac
100-
101- # Record the PID into a file, wait for the process to
102- # terminate and erase the recorded PID
103- pid record $!
104- wait $!
105- pid erase
106-
107- # In case retrofe/opkrun quits with errors, clear graphic VT
108- termfix_all
109-
110- # In case retrofe/opkrun quits with errors, reset default key mapping
111- keymap default
112- fi
113-
114- # Prevent 100% CPU usage
115- sleep 0.5
116-
117- # Exit if console rebooting
118- if [ -f " ${REBOOTING_FILE} " ]; then
119- break
120- fi
77+ else
78+
79+ # Umount any remaining OPK, if any
80+ umount /opk > /dev/null 2>&1
81+ rm -f " ${LAST_OPK_FILE} "
82+
83+ # Launch selected frontend
84+ local frontend=" $( get_frontend) "
85+ case " ${frontend} " in
86+ gmenu2x|retrofe)
87+ " ${frontend} " &
88+ ;;
89+
90+ none)
91+ echo " no frontend"
92+ sleep 5
93+ ;;
94+
95+ * )
96+ DEFAULT_FRONTEND=retrofe
97+ echo " Unrecognized frontend: $frontend , setting $DEFAULT_FRONTEND "
98+ set_frontend " ${DEFAULT_FRONTEND} "
99+ ;;
100+ esac
101+
102+ # Record the PID into a file, wait for the process to
103+ # terminate and erase the recorded PID
104+ pid record $!
105+ wait $!
106+ pid erase
107+
108+ # In case retrofe/opkrun quits with errors, clear graphic VT
109+ termfix_all
110+
111+ # In case retrofe/opkrun quits with errors, reset default key mapping
112+ keymap default
113+ fi
114+
115+ # Prevent 100% CPU usage
116+ sleep 0.5
117+
118+ # Exit if console rebooting
119+ if [ -f " ${REBOOTING_FILE} " ]; then
120+ break
121+ fi
121122 done
122123
123124 # Remove lock file and exit
0 commit comments