From 05e687c6c6b45fa6eae1898b876abcea8ec6f0e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Vinot?= Date: Wed, 9 Oct 2013 17:33:54 +0200 Subject: [PATCH] Fix #11 Play a sound while converting documents. --- copy_to_final.sh | 11 +++++++++-- deb/.keepdir | 0 fs/etc/rc.local | 2 ++ fs/home/kitten/kitten_mount_src | 2 +- fs/opt/groomer/constraint.sh | 4 +++- fs/opt/groomer/functions.sh | 4 ++-- fs/opt/groomer/init.sh | 2 ++ fs/opt/groomer/music.sh | 15 +++++++++++++++ midi/.keepdir | 0 prepare_rPI.sh | 2 +- 10 files changed, 35 insertions(+), 7 deletions(-) create mode 100644 deb/.keepdir create mode 100755 fs/opt/groomer/music.sh create mode 100644 midi/.keepdir diff --git a/copy_to_final.sh b/copy_to_final.sh index 29c2d9f..b452544 100755 --- a/copy_to_final.sh +++ b/copy_to_final.sh @@ -1,5 +1,8 @@ #!/bin/bash +set -e +set -x + CHROOT_PATH='/mnt/arm_rPi' if [ "$(id -u)" != "0" ]; then @@ -14,11 +17,12 @@ fi tar -cvpzf backup.tar.gz -C fs/ . tar -xzf backup.tar.gz -C ${CHROOT_PATH}/ cp deb/led ${CHROOT_PATH}/usr/sbin/led +cp -rf midi ${CHROOT_PATH}/opt/ # needed just once, make sure the size of the partition is correct #losetup -o $((122880 * 512)) /dev/loop0 FINAL_2013-09-10-wheezy-raspbian.img -e2fsck -f /dev/loop0 -resize2fs /dev/loop0 +#e2fsck -f /dev/loop0 +#resize2fs /dev/loop0 #losetup -d /dev/loop0 #sudo dd bs=4M if=FINAL_2013-09-10-wheezy-raspbian.img of=/dev/sdd @@ -27,3 +31,6 @@ resize2fs /dev/loop0 # if it is, use fdisk to remove the second partition and recreate it (you will # not lose the data). # See resize_img.md + + +# It is also a good idea to run raspi-config once and enable the console login (allow debugging) diff --git a/deb/.keepdir b/deb/.keepdir new file mode 100644 index 0000000..e69de29 diff --git a/fs/etc/rc.local b/fs/etc/rc.local index ee56e62..8d832f6 100755 --- a/fs/etc/rc.local +++ b/fs/etc/rc.local @@ -21,6 +21,8 @@ if [ -e /dev/sda ]; then if [ -e /dev/sdb ]; then cd /opt/groomer /usr/sbin/led & + # avoid possibe misuse + /sbin/ifconfig eth0 down ./init.sh /sbin/shutdown -h now fi diff --git a/fs/home/kitten/kitten_mount_src b/fs/home/kitten/kitten_mount_src index b5a1614..26b7180 100755 --- a/fs/home/kitten/kitten_mount_src +++ b/fs/home/kitten/kitten_mount_src @@ -1,7 +1,7 @@ #!/bin/bash set -e -set -x +#set -x if [ $# -eq 2 ]; then mount -o noexec,nosuid,nodev "${1}" "${2}" diff --git a/fs/opt/groomer/constraint.sh b/fs/opt/groomer/constraint.sh index ca2b30c..3b220e2 100644 --- a/fs/opt/groomer/constraint.sh +++ b/fs/opt/groomer/constraint.sh @@ -1,14 +1,15 @@ DEV_SRC='/dev/sda' DEV_DST='/dev/sdb1' + # User allowed to do the following commands without password USERNAME='kitten' HOME="/home/${USERNAME}" +MUSIC="/opt/midi/" TMP="/tmp/" # Paths used in multiple scripts SRC="${TMP}/src" - DST="${TMP}/dst" TEMP="${DST}/temp" ZIPTEMP="${DST}/ziptemp" @@ -19,6 +20,7 @@ LOGS="${DST}/logs" SUDO='/usr/bin/sudo' ID=`/usr/bin/id -u` SYNC='/bin/sync' +TIMIDITY='/usr/bin/timidity' # root commands. # To avoid the risk that an attacker use -o remount on mount and other nasty diff --git a/fs/opt/groomer/functions.sh b/fs/opt/groomer/functions.sh index 6651e77..ebb8319 100755 --- a/fs/opt/groomer/functions.sh +++ b/fs/opt/groomer/functions.sh @@ -1,7 +1,7 @@ #!/bin/bash -#set -e -set -x +set -e +#set -x source ./constraint.sh source ./constraint_conv.sh diff --git a/fs/opt/groomer/init.sh b/fs/opt/groomer/init.sh index 1627deb..d3f7168 100755 --- a/fs/opt/groomer/init.sh +++ b/fs/opt/groomer/init.sh @@ -17,6 +17,8 @@ clean(){ trap clean EXIT TERM INT +./music.sh & + su ${USERNAME} -c ./groomer.sh diff --git a/fs/opt/groomer/music.sh b/fs/opt/groomer/music.sh new file mode 100755 index 0000000..4f9f6e2 --- /dev/null +++ b/fs/opt/groomer/music.sh @@ -0,0 +1,15 @@ +#!/bin/bash + +set -e +#set -x + +source ./constraint.sh + +# Force output on analog +amixer cset numid=3 1 + +files=(${MUSIC}*) + +while true; do + $TIMIDITY ${files[RANDOM % ${#files[@]}]} +done diff --git a/midi/.keepdir b/midi/.keepdir new file mode 100644 index 0000000..e69de29 diff --git a/prepare_rPI.sh b/prepare_rPI.sh index 5eaa316..83881be 100755 --- a/prepare_rPI.sh +++ b/prepare_rPI.sh @@ -7,7 +7,7 @@ dpkg-reconfigure locales apt-get update apt-get dist-upgrade apt-get autoremove -apt-get install libreoffice p7zip-full libfontforge1 +apt-get install libreoffice p7zip-full libfontforge1 timidity dpkg -i libpoppler37*.deb pdf2htmlex*.deb chown -R kitten:kitten /home/kitten