|
23 | 23 |
|
24 | 24 | case ${1} in |
25 | 25 | load) |
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 |
29 | 32 |
|
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 |
32 | 38 |
|
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}" |
38 | 41 |
|
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}" |
40 | 49 | rm -f "${RESUME_PLAY_FILE}" |
| 50 | + keymap default |
| 51 | + termfix_all |
| 52 | + fi |
41 | 53 |
|
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 |
55 | 55 | 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}" |
58 | 58 | fi |
59 | | - ;; |
| 59 | + ;; |
60 | 60 |
|
61 | 61 | save) |
62 | | - if [ ${#} -lt 2 ]; then |
63 | | - usage |
64 | | - fi |
65 | | - shift |
66 | | - |
67 | | - # Write quick load file args |
68 | | - echo -n "" > "${INSTANT_PLAY_FILE}" |
69 | | - printf "'" >> "${INSTANT_PLAY_FILE}" |
70 | | - # First arg is prog name, forcing real path |
71 | | - bin=$(printf %s "$1" | sed "s/'/'\\\\''/g") |
| 62 | + if [ ${#} -lt 2 ]; then |
| 63 | + usage |
| 64 | + fi |
| 65 | + shift |
| 66 | + |
| 67 | + # Write quick load file args |
| 68 | + echo -n "" > "${INSTANT_PLAY_FILE}" |
| 69 | + printf "'" >> "${INSTANT_PLAY_FILE}" |
| 70 | + # First arg is prog name, forcing real path |
| 71 | + bin=$(printf %s "$1" | sed "s/'/'\\\\''/g") |
72 | 72 | bin_name=$(basename "$bin") |
73 | 73 | bin_path="$(cat $PID_PATH)"/"$bin_name" |
74 | | - echo -n "$bin_path" >> "${INSTANT_PLAY_FILE}" |
| 74 | + echo -n "$bin_path" >> "${INSTANT_PLAY_FILE}" |
75 | 75 | printf "' " >> "${INSTANT_PLAY_FILE}" |
76 | 76 | shift |
77 | 77 |
|
78 | | - while [ "$#" != "0" ] |
79 | | - do |
| 78 | + while [ "$#" != "0" ] |
| 79 | + do |
80 | 80 | printf "'" >> "${INSTANT_PLAY_FILE}" |
81 | 81 | printf %s "$1" | sed "s/'/'\\\\''/g" >> "${INSTANT_PLAY_FILE}" |
82 | 82 | printf "' " >> "${INSTANT_PLAY_FILE}" |
83 | 83 | shift |
84 | | - done |
| 84 | + done |
85 | 85 |
|
86 | | - # Add the magic sauce to launch the process in background, |
87 | | - # record the PID into a file, wait for the process to |
88 | | - # terminate and erase the recorded PID |
89 | | - cat << EOF >> "${INSTANT_PLAY_FILE}" |
| 86 | + # Add the magic sauce to launch the process in background, |
| 87 | + # record the PID into a file, wait for the process to |
| 88 | + # terminate and erase the recorded PID |
| 89 | + cat << EOF >> "${INSTANT_PLAY_FILE}" |
90 | 90 | & |
91 | 91 | pid record \$! |
92 | 92 | wait \$! |
93 | 93 | pid erase |
94 | 94 | EOF |
95 | 95 |
|
96 | | - # Now terminate gracefully |
97 | | - exec powerdown now |
98 | | - ;; |
| 96 | + # Now terminate gracefully |
| 97 | + exec powerdown now |
| 98 | + ;; |
99 | 99 |
|
100 | 100 | *) |
101 | | - usage |
102 | | - ;; |
| 101 | + usage |
| 102 | + ;; |
103 | 103 | esac |
104 | 104 | exit 0 |
105 | | - |
0 commit comments