CHA

Created Diff never expires
22 removals
Lines
Total
Removed
Words
Total
Removed
To continue using this feature, upgrade to
Diffchecker logo
Diffchecker Pro
116 lines
22 additions
Lines
Total
Added
Words
Total
Added
To continue using this feature, upgrade to
Diffchecker logo
Diffchecker Pro
116 lines
#! /bin/sh
#! /bin/sh
export clr_red="\e[0;31m"
export clr_red="\e[0;31m"
export clr_grn="\e[0;32m"
export clr_grn="\e[0;32m"
export clr_choko="\e[0;35m"
export clr_choko="\e[0;35m"
export clr_std="\e[m"
export clr_std="\e[m"
FAILED=0
FAILED=0


echo -e $clr_grn
echo -e $clr_grn


case $1 in
case $1 in
start)
start)
TERM=linux setterm --cursor on --blink off >/dev/tty0 </dev/tty0
TERM=linux setterm --cursor on --blink off >/dev/tty0 </dev/tty0
echo 1 >/sys/class/graphics/fbcon/cursor_blink
echo 1 >/sys/class/graphics/fbcon/cursor_blink
echo Running $0 $@
echo Running $0 $@
MOUNTCMD='mount --bind ./$DIR /$DIR'
MOUNTCMD='mount --bind ./$DIR /$DIR'
if [ ! -e ./first_boot_completed ]
if [ ! -e ./first_boot_completed ]
then
then
echo "Initial setup"
echo "Initial setup"
for DIR in \
for DIR in \
opt/capcom \
opt/capcom \
usr/share/roms
usr/share/roms
do
do
if [ $FAILED -eq 0 ]
if [ $FAILED -eq 0 ]
then
then
echo -n "Copying /$DIR: "
echo -n "Copying /$DIR: "
if [ -d /$DIR ]
if [ -d /$DIR ]
then
then
COPYCMD='cp -ru /$DIR ./$DIR/..'
COPYCMD='cp -ru /$DIR ./$DIR/..'
else
else
COPYCMD='cp -u /$DIR ./$DIR'
COPYCMD='cp -u /$DIR ./$DIR'
fi
fi
eval "CMD=\"$COPYCMD\""
eval "CMD=\"$COPYCMD\""
echo "(" $CMD ")"
echo "(" $CMD ")"
$CMD
$CMD
if [ $? -eq 0 ]
if [ $? -eq 0 ]
then
then
echo "SUCCEEDED"
echo "SUCCEEDED"
else
else
echo -e "${clr_red}FAILED${clr_grn}"
echo -e "${clr_red}FAILED${clr_grn}"
FAILED=1
FAILED=1
fi
fi
sync
sync
fi
fi
done
done
if [ $FAILED -eq 1 ]
if [ $FAILED -eq 1 ]
then
then
echo -e "${clr_red}Initial setup failed. Not applying CHA_MOD${clr_grn}"
echo -e "${clr_red}Initial setup failed. Not applying CHA_MOD${clr_grn}"
else
else
echo "Creating 'first_boot_completed' file"
echo "Creating 'first_boot_completed' file"
touch ./first_boot_completed
touch ./first_boot_completed
# Reboot after copying for system stabilty reasons
# Reboot after copying for system stabilty reasons
sync
sync
reboot -f
reboot -f
fi
fi
fi
fi
# If /dev/ttyS0 is not used then start a getty login shell on it
# If /dev/ttyS0 is not used then start a getty login shell on it
# if [ ! `lsof | grep -e ttyS0` ]
if [ ! `lsof | grep -e ttyS0` ]
# then
then
# while /bin/true
while /bin/true
# do
do
# setsid /sbin/getty -L /dev/ttyS0 0 vt100
setsid /sbin/getty -L /dev/ttyS0 0 vt100
# done &
done &
# fi
fi
# # Start FTP server if it exists, even if initial setup failed
# Start FTP server if it exists, even if initial setup failed
# if [ -x ./uFTP/uFTP ]
if [ -x ./uFTP/uFTP ]
# then
then
# cd uFTP
cd uFTP
# echo "Starting uFTP"
echo "Starting uFTP"
# ./uFTP
./uFTP
# cd ..
cd ..
# fi
fi
# Start dropbear SSH server if it exists but not if initial setup failed
# Start dropbear SSH server if it exists but not if initial setup failed
# if [ -x ./sshd/dropbear -a $FAILED -eq 0 ]
if [ -x ./sshd/dropbear -a $FAILED -eq 0 ]
# then
then
# cd sshd
cd sshd
# echo "Starting dropbear SSH server"
echo "Starting dropbear SSH server"
# ./dropbear -r ./dropbear_ecdsa_host_key -r ./id_rsa -R -E -B
./dropbear -r ./dropbear_ecdsa_host_key -r ./id_rsa -R -E -B
# cd ..
cd ..
# fi
fi
;;
;;
stop)
stop)
MOUNTCMD='umount /$DIR'
MOUNTCMD='umount /$DIR'
# Kill capcom to ensure directories can be unmounted
# Kill capcom to ensure directories can be unmounted
echo "Stopping capcom, uFTP, dropbear"
echo "Stopping capcom, uFTP, dropbear"
until [ `ps | grep -e capcom -e uFTP -e dropbear | wc -l` -eq 1 ]
until [ `ps | grep -e capcom -e uFTP -e dropbear | wc -l` -eq 1 ]
do
do
killall capcom uFTP dropbear 2>/dev/null
killall capcom uFTP dropbear 2>/dev/null
done
done
;;
;;
*)
*)
MOUNTCMD="echo >/dev/null"
MOUNTCMD="echo >/dev/null"
echo "usage: $0 [start|stop]"
echo "usage: $0 [start|stop]"
;;
;;
esac
esac


# 'Overmount' the various games-related directories
# 'Overmount' the various games-related directories
# Note - No sounds/music/set1
# Note - No sounds/music/set1
if [ $FAILED -eq 0 ]
if [ $FAILED -eq 0 ]
then
then
for DIR in \
for DIR in \
opt/capcom/assets/capcom-home-arcade-last.png \
opt/capcom/assets/capcom-home-arcade-last.png \
opt/capcom/assets/games.txt \
opt/capcom/assets/games.txt \
opt/capcom/assets/games \
opt/capcom/assets/games \
opt/capcom/assets/options \
opt/capcom/assets/options \
opt/capcom/assets/sounds \
opt/capcom/assets/sounds \
usr/share/roms \
usr/share/roms \
usr/lib/libretro/fba_libretro.so
usr/lib/libretro/fba_libretro.so
do
do
eval "CMD=\"$MOUNTCMD\""
eval "CMD=\"$MOUNTCMD\""
echo $CMD
echo $CMD
$CMD
$CMD
done
done
fi
fi
sync
sync
echo -e "${clr_std}"
echo -e "${clr_std}"