2323
2424case ${1} in
2525load)
26- if [ ${# } -ne 1 ]; then
27- usage
28- fi
26+ if [ ${# } -ne 1 ]; then
27+ usage
28+ fi
29+
30+ # Umount any remaining OPK, if any
31+ umount /opk > /dev/null 2>&1
2932
30- # Umount any remaining OPK, if any
31- umount /opk > /dev/null 2>&1
33+ # Mount last OPK, if any
34+ if [ -r " ${LAST_OPK_FILE} " ]; then
35+ last_opk=$( cat " ${LAST_OPK_FILE} " )
36+ mount -t squashfs " ${last_opk} " /opk
37+ fi
3238
33- # Mount last OPK, if any
34- if [ -r " ${LAST_OPK_FILE} " ]; then
35- last_opk=$( cat " ${LAST_OPK_FILE} " )
36- mount -t squashfs " ${last_opk} " /opk
37- fi
39+ # Remove unnecessary files
40+ rm -f " ${RESUME_PLAY_FILE} "
3841
39- # Remove unnecessary files
42+ # Launch Previous Game if any
43+ if [ -f " ${INSTANT_PLAY_FILE} " ]; then
44+ keymap resume
45+ echo -n " Found Instant Play file, restarting previous game with command: "
46+ cat " ${INSTANT_PLAY_FILE} "
47+ mv " ${INSTANT_PLAY_FILE} " " ${RESUME_PLAY_FILE} "
48+ source " ${RESUME_PLAY_FILE} "
4049 rm -f " ${RESUME_PLAY_FILE} "
50+ keymap default
51+ termfix_all
52+ fi
4153
42- # Launch Previous Game if any
43- if [ -f " ${INSTANT_PLAY_FILE} " ]; then
44- keymap resume
45- echo -n " Found Instant Play file, restarting previous game with command: "
46- cat " ${INSTANT_PLAY_FILE} "
47- mv " ${INSTANT_PLAY_FILE} " " ${RESUME_PLAY_FILE} "
48- source " ${RESUME_PLAY_FILE} "
49- rm -f " ${RESUME_PLAY_FILE} "
50- keymap default
51- termfix_all
52- fi
53-
54- # Unmount last OPK, if any
54+ # Unmount last OPK, if any
5555 if [ -r " ${LAST_OPK_FILE} " -a ! -f " ${REBOOTING_FILE} " ]; then
56- umount /opk
57- rm " ${LAST_OPK_FILE} "
56+ umount /opk
57+ rm " ${LAST_OPK_FILE} "
5858 fi
59- ;;
59+ ;;
6060
6161save)
62- if [ ${# } -lt 2 ]; then
63- usage
64- fi
65- shift
62+ if [ ${# } -lt 2 ]; then
63+ usage
64+ fi
65+ shift
6666
6767 # Get curent binary real path
6868 bin=$( printf %s " $1 " | sed " s/'/'\\\\ ''/g" )
@@ -76,31 +76,30 @@ save)
7676 printf " ' " >> " ${INSTANT_PLAY_FILE} "
7777 shift
7878
79- while [ " $# " != " 0" ]
80- do
79+ while [ " $# " != " 0" ]
80+ do
8181 printf " '" >> " ${INSTANT_PLAY_FILE} "
8282 printf %s " $1 " | sed " s/'/'\\\\ ''/g" >> " ${INSTANT_PLAY_FILE} "
8383 printf " ' " >> " ${INSTANT_PLAY_FILE} "
8484 shift
85- done
85+ done
8686
87- # Add the magic sauce to launch the process in background,
88- # record the PID into a file, wait for the process to
89- # terminate and erase the recorded PID
90- cat << EOF >> "${INSTANT_PLAY_FILE} "
87+ # Add the magic sauce to launch the process in background,
88+ # record the PID into a file, wait for the process to
89+ # terminate and erase the recorded PID
90+ cat << EOF >> "${INSTANT_PLAY_FILE} "
9191&
9292pid record \$ !
9393wait \$ !
9494pid erase
9595EOF
9696
97- # Now terminate gracefully
98- exec powerdown now
99- ;;
97+ # Now terminate gracefully
98+ exec powerdown now
99+ ;;
100100
101101* )
102- usage
103- ;;
102+ usage
103+ ;;
104104esac
105105exit 0
106-
0 commit comments