Skip to content

Instantly share code, notes, and snippets.

@matoken

matoken/rcS

Last active Dec 30, 2015
Embed
What would you like to do?
Kobo on Debian でシャットダウン時の画面を表示した状態でシャットダウンする http://hpv.cc/~maty/pukiwiki1/index.php?kobo%2Fdebian#t5ea9d40
#!/bin/sh
PRODUCT=`/bin/kobo_config.sh`;
[ $PRODUCT != trilogy ] && PREFIX=$PRODUCT-
mount -o remount,noatime,nodiratime /dev/mmcblk0p1 /
PLATFORM=freescale
if [ `dd if=/dev/mmcblk0 bs=512 skip=1024 count=1 | grep -c "HW CONFIG"` == 1 ]; then
PLATFORM=ntx508
fi
if [ $PLATFORM == freescale ]; then
if [ ! -s /lib/firmware/imx/epdc_E60_V220.fw ]; then
mkdir -p /lib/firmware/imx
dd if=/dev/mmcblk0 bs=512K skip=10 count=1 | zcat > /lib/firmware/imx/epdc_E60_V220.fw
sync
fi
fi
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/lib:
runlevel=S
prevlevel=N
umask 022
export PATH runlevel prevlevel
for i in /proc /dev /root /tmp /sys /mnt/sd /mnt/onboard /mnt/user /var/lib /var/log /var/run /lib/modules/`uname -r`; do
[ ! -d $i ] && mkdir -p $i
done;
/bin/mount -t proc none /proc
/bin/mount -t tmpfs none -o size=16m /tmp
/bin/mount -t tmpfs none /dev
/bin/mount -t tmpfs none -o size=16k /var/lib
/bin/mount -t tmpfs none -o size=16k /var/log
/bin/mount -t tmpfs none -o size=128k /var/run
/bin/mount -t sysfs none -o size=500k /sys
for i in /var/run/dbus /var/lib/dbus; do
mkdir -p $i
done
mkfifo /tmp/nickel-hardware-status
rm -rf /etc/udev/rules.d/70-persistent-net.rules
echo -e '\000\000\000\000' > /proc/sys/kernel/hotplug
/sbin/udevd -d
/sbin/udevadm control --env=STARTUP=1
/sbin/udevadm trigger
/sbin/udevadm settle --timeout=2
/sbin/udevadm control --env=STARTUP=
#######################################
#
# Marek: custom startup menu
#
#######################################
hostname kobo
ifconfig lo 127.0.0.1
eink_enable_autoupdate
PREVIOUS_DIR=`pwd`
cd /root/python/apps/startup_menu
STARTUP_CHOICE=`python /root/python/apps/startup_menu/menu.py`
cd $PREVIOUS_DIR
eink_disable_autoupdate
# required by telnet and xterm
mkdir -p /dev/pts
mount -t devpts devpts /dev/pts
if [ $STARTUP_CHOICE == "off" ]; then
cat /root/images/power_off.raw | /usr/local/Kobo/pickel showpic
poweroff
fi
if [ $STARTUP_CHOICE == "computer" ]; then
cat /root/images/Loading.raw | /usr/local/Kobo/pickel showpic
#
# check and mount FAT partition
#
dosfsck -a -w /dev/mmcblk0p2
mount -t vfat -o iocharset=utf8 /dev/mmcblk0p2 /mnt/onboard
rm -rf /mnt/onboard/fsck*
rm -rf /mnt/onboard/FSCK*
rm -rf /usr/local/Kobo/db.tgz
cat /root/images/Loading1.raw | /usr/local/Kobo/pickel showpic 1
#
# turn on swap partition
#
swapon /dev/mmcblk0p3
echo -n 8192 > /proc/sys/vm/min_free_kbytes
(
/usr/local/Kobo/pickel disable.rtc.alarm
if [ ! -e /etc/wpa_supplicant/wpa_supplicant.conf ]; then
cp /etc/wpa_supplicant/wpa_supplicant.conf.template /etc/wpa_supplicant/wpa_supplicant.conf
fi
echo 1 > /sys/devices/platform/mxc_dvfs_core.0/enable
/sbin/hwclock -s -u
) &
eink_enable_autoupdate
./debian-startx
eink_disable_autoupdate
if [ -e /debian/home/marek/power_off.raw ]; then
POWER_OFF_IMAGE=/debian/home/marek/power_off.raw
else
POWER_OFF_IMAGE=/root/images/power_off.raw
fi
cat $POWER_OFF_IMAGE | /usr/local/Kobo/pickel showpic
rm /debian/home/marek/power_off.raw
poweroff
fi
if [ $STARTUP_CHOICE == "wifi" ] || [ $STARTUP_CHOICE == "home" ]; then
cat /root/images/wifi.raw | /usr/local/Kobo/pickel showpic
dosfsck -a -w /dev/mmcblk0p2
mount -t vfat -o iocharset=utf8 /dev/mmcblk0p2 /mnt/onboard
rm -rf /mnt/onboard/fsck*
rm -rf /mnt/onboard/FSCK*
rm -rf /usr/local/Kobo/db.tgz
INTERFACE=eth0
WIFI_MODULE=dhd
export INTERFACE
export WIFI_MODULE
if [ ! -e /etc/wpa_supplicant/wpa_supplicant.conf ]; then
cp /etc/wpa_supplicant/wpa_supplicant.conf.template /etc/wpa_supplicant/wpa_supplicant.conf
fi
insmod /drivers/ntx508/wifi/sdio_wifi_pwr.ko
insmod /drivers/ntx508/wifi/dhd.ko
sleep 4
wpa_supplicant -B -D wext -i eth0 -c /etc/wpa_supplicant/wpa_supplicant.conf
ifconfig eth0 up
wlarm_le -i eth0 up
udhcpc -i eth0 -t15 -T10 -A3 -f -q -s /etc/udhcpc.d/default.script
/usr/sbin/inetd /etc/inetd.conf
eink_enable_autoupdate
cd /root/python/apps/startup_menu
python /root/python/apps/startup_menu/show_text.py `ifconfig | grep -o -E '([0-9]{1,3}\.){3}[0-9]{1,3}'`
eink_disable_autoupdate
cat /root/images/power_off.raw | /usr/local/Kobo/pickel showpic
poweroff
fi
if [ $STARTUP_CHOICE != "wifi" ]; then
#######################################
( usleep 400000; /etc/init.d/on-animator.sh ) &
dosfsck -a -w /dev/mmcblk0p2
mount -t vfat -o iocharset=utf8 /dev/mmcblk0p2 /mnt/onboard
rm -rf /mnt/onboard/fsck*
rm -rf /mnt/onboard/FSCK*
rm -rf /usr/local/Kobo/db.tgz
echo -n 8192 > /proc/sys/vm/min_free_kbytes
echo -n 67108864 > /proc/sys/kernel/shmmax
if [ ! -e /mnt/onboard/.kobo ]; then
mkdir -p /mnt/onboard/.kobo
tar zxf /usr/local/Kobo/db.tgz -C /mnt/onboard
sync
echo "Decompressed database"
fi
#
# Marek: changed file name Kobo.tgz -> Kobo2.tgz
# to allow updates' review before applying
#
if [ -e /mnt/onboard/.kobo/Kobo2.tgz ]; then
zcat /mnt/onboard/.kobo/Kobo2.tgz > /dev/null && tar zxf /mnt/onboard/.kobo/Kobo2.tgz -C /usr/local/Kobo/
rm /mnt/onboard/.kobo/Kobo2.tgz
echo "Done upgrading..."
fi
#
# Marek: changed file name KoboRoot.tgz -> KoboRoot2.tgz
# to allow updates' review before applying
#
if [ -e /mnt/onboard/.kobo/KoboRoot2.tgz ]; then
killall on-animator.sh
zcat /etc/images/$PREFIX\ghostbuster.raw.gz | /usr/local/Kobo/pickel showpic
/etc/init.d/update-animator.sh &
zcat /mnt/onboard/.kobo/KoboRoot2.tgz > /dev/null && tar zxf /mnt/onboard/.kobo/KoboRoot2.tgz -C /
if [ -e /mnt/onboard/.kobo/upgrade ]; then
/etc/init.d/upgrade-wifi.sh
rm -rf /mnt/onboard/.kobo/upgrade
fi
rm /mnt/onboard/.kobo/KoboRoot2.tgz
killall update-animator.sh
echo "Done upgrading..."
zcat /etc/images/$PREFIX\ghostbuster.raw.gz | /usr/local/Kobo/pickel showpic
zcat /etc/images/$PREFIX\reboot.raw.gz | /usr/local/Kobo/pickel showpic
sync
reboot
fi
(
/usr/local/Kobo/pickel disable.rtc.alarm
if [ ! -e /etc/wpa_supplicant/wpa_supplicant.conf ]; then
cp /etc/wpa_supplicant/wpa_supplicant.conf.template /etc/wpa_supplicant/wpa_supplicant.conf
fi
echo 1 > /sys/devices/platform/mxc_dvfs_core.0/enable
/sbin/hwclock -s -u
) &
INTERFACE=wlan0
WIFI_MODULE=ar6000
if [ $PLATFORM == ntx508 ]; then
INTERFACE=eth0
WIFI_MODULE=dhd
fi
export INTERFACE
export WIFI_MODULE
export QWS_MOUSE_PROTO="tslib_nocal:/dev/input/event1"
export QWS_KEYBOARD=imx508kbd:/dev/input/event0
export QWS_DISPLAY=Transformed:imx508:Rot90
export NICKEL_HOME=/mnt/onboard/.kobo
export LD_LIBRARY_PATH=/usr/local/Kobo
export WIFI_MODULE_PATH=/drivers/$PLATFORM/wifi/$WIFI_MODULE.ko
export LANG=en_US.UTF-8
export UBOOT_MMC=/etc/u-boot/$PLATFORM/u-boot.mmc
export UBOOT_RECOVERY=/etc/u-boot/$PLATFORM/u-boot.recovery
/bin/dbus-uuidgen > /var/lib/dbus/machine-id
/bin/dbus-daemon --system &
export DBUS_SESSION_BUS_ADDRESS=`/bin/dbus-daemon --session --print-address --fork`
/usr/local/Kobo/hindenburg &
/usr/local/Kobo/nickel -qws -skipFontLoad &
[ $PLATFORM != freescale ] && udevadm trigger &
fi
#!/bin/sh
#-- スクリーンショット取得
xwd -root > ~/power_off.wd
#-- スクリーンショット画像をpng に変換
convert ~/power_off.wd -geometry 800x600 -ordered-dither threshold,32,64,32 ~/power_off.png
#-- png からrgb565 形式に変換
avconv -vcodec png -i ~/power_off.png -vcodec rawvideo -f rawvideo -pix_fmt rgb565 -y ~/power_off.raw
#-- テンポラリファイル削除
rm ~/power_off.wd ~/power_off.png
#-- swesome 終了 -> シャットダウンへ
echo 'awesome.quit()' | awesome-client
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.