Skip to content

Commit 5cd9501

Browse files
committed
corrected instant play that could only be launched once
1 parent 305aa2b commit 5cd9501

File tree

3 files changed

+21
-9
lines changed

3 files changed

+21
-9
lines changed

FunKey/board/funkey/rootfs-overlay/usr/local/sbin/instant_play

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ SELF="$(basename ${0})"
77
INSTANT_PLAY_FILE="/mnt/instant_play"
88
RESUME_PLAY_FILE="/mnt/resume_play"
99
LAST_OPK_FILE="/mnt/last_opk"
10+
PID_PATH="/var/run/pid_path"
11+
REBOOTING_FILE="/run/rebooting"
1012

1113
usage() {
1214
>&2 echo "Usage: ${SELF} load"
@@ -50,7 +52,7 @@ load)
5052
fi
5153

5254
# Unmount last OPK, if any
53-
if [ -r "${LAST_OPK_FILE}" ]; then
55+
if [ -r "${LAST_OPK_FILE}" -a ! -f "${REBOOTING_FILE}" ]; then
5456
umount /opk
5557
rm "${LAST_OPK_FILE}"
5658
fi
@@ -64,23 +66,22 @@ save)
6466

6567
# Write quick load file args
6668
echo -n "" > "${INSTANT_PLAY_FILE}"
67-
# First arg is prog name, forcing real path
6869
printf "'" >> "${INSTANT_PLAY_FILE}"
69-
bin_name=$(printf %s "$1" | sed "s/'/'\\\\''/g")
70-
bin_path="$(pwd)"/"$(basename "$bin_name")"
70+
# First arg is prog name, forcing real path
71+
bin=$(printf %s "$1" | sed "s/'/'\\\\''/g")
72+
bin_name=$(basename "$bin")
73+
bin_path="$(cat $PID_PATH)"/"$bin_name"
7174
echo -n "$bin_path" >> "${INSTANT_PLAY_FILE}"
72-
shift
7375
printf "' " >> "${INSTANT_PLAY_FILE}"
76+
shift
7477

75-
while :
78+
while [ "$#" != "0" ]
7679
do
7780
printf "'" >> "${INSTANT_PLAY_FILE}"
7881
printf %s "$1" | sed "s/'/'\\\\''/g" >> "${INSTANT_PLAY_FILE}"
79-
shift
80-
case $# in 0) break; esac
8182
printf "' " >> "${INSTANT_PLAY_FILE}"
83+
shift
8284
done
83-
printf "'\n" >> "${INSTANT_PLAY_FILE}"
8485

8586
# Add the magic sauce to launch the process in background,
8687
# record the PID into a file, wait for the process to

FunKey/board/funkey/rootfs-overlay/usr/local/sbin/pid

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ PID_FILE="/var/run/funkey.pid"
99
usage() {
1010
>&2 echo "Usage: ${SELF} record pid"
1111
>&2 echo " ${SELF} erase"
12+
>&2 echo " ${SELF} print"
1213
exit 1
1314
}
1415

@@ -40,6 +41,10 @@ case "${1}" in
4041
erase_pid
4142
;;
4243

44+
print)
45+
cat "${PID_FILE}"
46+
;;
47+
4348
*)
4449
usage
4550
;;

FunKey/board/funkey/rootfs-overlay/usr/local/sbin/powerdown

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
SELF="$(basename ${0})"
77
PID_FILE="/var/run/funkey.pid"
8+
PID_PATH="/var/run/pid_path"
89
REBOOTING_FILE="/run/rebooting"
910

1011
usage() {
@@ -16,6 +17,11 @@ usage() {
1617

1718
schedule_powerdown() {
1819

20+
# Save current pid path before closing bin
21+
# (won't work if bin is already closed)
22+
pid_path=$(dirname $(readlink /proc/$(pid print)/exe))
23+
echo -n "$pid_path" > "$PID_PATH"
24+
1925
# Send USR1 signal to the running FunKey process to warn about
2026
# impending shutdown
2127
pkill -USR1 -F "${PID_FILE}" > /dev/null 2>&1

0 commit comments

Comments
 (0)