13,420
edits
Changes
Created page with ' #!/bin/bash # grab.bash # Author: Murray Saul # Date Created: November 17, 2010 # Date Modified: June 3, 2011 # Purpose: To allow ce admin to "grab" Sunday School wor…'
#!/bin/bash
# grab.bash
# Author: Murray Saul
# Date Created: November 17, 2010
# Date Modified: June 3, 2011
# Purpose: To allow ce admin to "grab" Sunday School work
# to be placed on USB device to take home. Copy of
# word also placed on "Sunday_School" directory for
# extra backup...
# Determine USB device Name
# Prompt for user account
zenity --info --text "<b>WELCOME TO GRAB WORK!</b>\n\nThis program will allow instructors to \"grab\" student work on the computer lab. The instructor then has the option to remove \"grabbed\" work, and to automatically copy work on the instructor's USB stick.\n\nPlease click <b>OK</b> to continue."
zenity --info --text "PLEASE <b>INSERT YOUR USB STICK</b> INTO THE SERVER.\n\nAfter you have inserted your USB device, then click <b>OK</b> to continue."
sleep 3
set $(ls /media | sed "s/ /_/g" | sed "s/^/FALSE &/") > /dev/null
content=$*
usbChoice=$(zenity --title "Select USB Device" --list --text "Please select <b>your USB device</b>:" --radiolist --column "Pick" --column "USB Name" $content)
usbDriveName="$(echo $usbChoice | sed "s/_/ /g")"
dateStamp=$(date +"%d_%B_%y")
timeStamp=$(date +"%H_%M_%S_%p")
cd /media
pwd
cd "${usbDriveName}"
mkdir -p churchLab/$dateStamp/$timeStamp 2> /dev/null
mkdir -p /home/teacher/churchLab/$dateStamp/$timeStamp 2> /dev/null
sudo chown teacher:teacher /home/teacher/churchLab/$dateStamp/$timeStamp
cd churchLab/$dateStamp/$timeStamp
account=$(zenity --height 250 --text "<b>Select Computer Accounts to \"Grab Work\" From:</b>" --list --checklist --column "" --column "Computer Account" FALSE jamm FALSE studio )
set $(echo $account | tr '|' ' ') > /dev/null
for x
do
# Prompt for application to yank for each account
application=$(zenity --height 350 --text "Select applications to grab for\naccount called \"<b>$x</b>\":" --list --checklist --column "" --column "Application" FALSE tuxpaintings FALSE wordProcessing FALSE slideShows )
set $(echo $application | tr '|' ' ') > /dev/null
for y
do
for ((z=1;z<=7;z++))
do
if [ "$y" = "tuxpaintings" ]
then
cp /home/$x$z/.tuxpaint/saved/* . 2> /dev/null
cp /home/$x$z/.tuxpaint/saved/* /home/teacher/Desktop/churchLab/$dateStamp/$timeStamp 2> /dev/null
fi
if [ "$y" = "wordProcessing" ]
then
cp /home/$x$z/Documents/*.doc . 2> /dev/null
cp /home/$x$z/Documents/*.doc /home/teacher/Desktop/churchLab/$dateStamp/$timeStamp 2> /dev/null
cp /home/$x$z/Documents/*.odt . 2> /dev/null
cp /home/$x$z/Documents/*.odt /home/teacher/Desktop/churchLab/$dateStamp/$timeStamp 2> /dev/null
cp /home/$x$z/Documents/*.pdf . 2> /dev/null
cp /home/$x$z/Documents/*.pdf /home/teacher/Desktop/churchLab/$dateStamp/$timeStamp 2> /dev/null
fi
if [ "$y" = "slideShows" ]
then
cp /home/$x$z/Documents/*.odp . 2> /dev/null
cp /home/$x$z/Documents/*.odp /home/teacher/Desktop/churchLab/$dateStamp/$timeStamp 2> /dev/null
cp /home/$x$z/Documents/*.ppt . 2> /dev/null
cp /home/$x$z/Documents/*.ppt /home/teacher/Desktop/churchLab/$dateStamp/$timeStamp 2> /dev/null
fi
done
chown teacher:teacher ./*
if zenity --question --text "Do you want to delete all <b>$y</b> that you \"grabbed\"?"
then
for ((z=1;z<=7;z++))
do
if [ "$y" = "tuxpaintings" ]
then
rm /home/$x$z/.tuxpaint/saved/* 2> /dev/null
fi
if [ "$y" = "wordProcessing" ]
then
rm /home/$x$z/Documents/*.doc 2> /dev/null
rm /home/$x$z/Documents/*.odt 2> /dev/null
rm /home/$x$z/Documents/*.pdf 2> /dev/null
fi
if [ "$y" = "slideShows" ]
then
rm /home/$x$z/Documents/*.odp 2> /dev/null
rm /home/$x$z/Documents/*.ppt 2> /dev/null
fi
done
fi
done
done
zenity --info --text "<b>GRAB COMPLETED!</b>\n\nPlease verify that you properly "grabbed" this work by <b>checking the date and timestamp subfolders</b> contained in the <b>churchLab</b> Desktop folder.\n\n<b>Please <u>safely</u> remove your USB storage device now...</b>\n\nHave a nice day... and thank you for using <b>GRAB WORK!</b>\n\n"
# grab.bash
# Author: Murray Saul
# Date Created: November 17, 2010
# Date Modified: June 3, 2011
# Purpose: To allow ce admin to "grab" Sunday School work
# to be placed on USB device to take home. Copy of
# word also placed on "Sunday_School" directory for
# extra backup...
# Determine USB device Name
# Prompt for user account
zenity --info --text "<b>WELCOME TO GRAB WORK!</b>\n\nThis program will allow instructors to \"grab\" student work on the computer lab. The instructor then has the option to remove \"grabbed\" work, and to automatically copy work on the instructor's USB stick.\n\nPlease click <b>OK</b> to continue."
zenity --info --text "PLEASE <b>INSERT YOUR USB STICK</b> INTO THE SERVER.\n\nAfter you have inserted your USB device, then click <b>OK</b> to continue."
sleep 3
set $(ls /media | sed "s/ /_/g" | sed "s/^/FALSE &/") > /dev/null
content=$*
usbChoice=$(zenity --title "Select USB Device" --list --text "Please select <b>your USB device</b>:" --radiolist --column "Pick" --column "USB Name" $content)
usbDriveName="$(echo $usbChoice | sed "s/_/ /g")"
dateStamp=$(date +"%d_%B_%y")
timeStamp=$(date +"%H_%M_%S_%p")
cd /media
pwd
cd "${usbDriveName}"
mkdir -p churchLab/$dateStamp/$timeStamp 2> /dev/null
mkdir -p /home/teacher/churchLab/$dateStamp/$timeStamp 2> /dev/null
sudo chown teacher:teacher /home/teacher/churchLab/$dateStamp/$timeStamp
cd churchLab/$dateStamp/$timeStamp
account=$(zenity --height 250 --text "<b>Select Computer Accounts to \"Grab Work\" From:</b>" --list --checklist --column "" --column "Computer Account" FALSE jamm FALSE studio )
set $(echo $account | tr '|' ' ') > /dev/null
for x
do
# Prompt for application to yank for each account
application=$(zenity --height 350 --text "Select applications to grab for\naccount called \"<b>$x</b>\":" --list --checklist --column "" --column "Application" FALSE tuxpaintings FALSE wordProcessing FALSE slideShows )
set $(echo $application | tr '|' ' ') > /dev/null
for y
do
for ((z=1;z<=7;z++))
do
if [ "$y" = "tuxpaintings" ]
then
cp /home/$x$z/.tuxpaint/saved/* . 2> /dev/null
cp /home/$x$z/.tuxpaint/saved/* /home/teacher/Desktop/churchLab/$dateStamp/$timeStamp 2> /dev/null
fi
if [ "$y" = "wordProcessing" ]
then
cp /home/$x$z/Documents/*.doc . 2> /dev/null
cp /home/$x$z/Documents/*.doc /home/teacher/Desktop/churchLab/$dateStamp/$timeStamp 2> /dev/null
cp /home/$x$z/Documents/*.odt . 2> /dev/null
cp /home/$x$z/Documents/*.odt /home/teacher/Desktop/churchLab/$dateStamp/$timeStamp 2> /dev/null
cp /home/$x$z/Documents/*.pdf . 2> /dev/null
cp /home/$x$z/Documents/*.pdf /home/teacher/Desktop/churchLab/$dateStamp/$timeStamp 2> /dev/null
fi
if [ "$y" = "slideShows" ]
then
cp /home/$x$z/Documents/*.odp . 2> /dev/null
cp /home/$x$z/Documents/*.odp /home/teacher/Desktop/churchLab/$dateStamp/$timeStamp 2> /dev/null
cp /home/$x$z/Documents/*.ppt . 2> /dev/null
cp /home/$x$z/Documents/*.ppt /home/teacher/Desktop/churchLab/$dateStamp/$timeStamp 2> /dev/null
fi
done
chown teacher:teacher ./*
if zenity --question --text "Do you want to delete all <b>$y</b> that you \"grabbed\"?"
then
for ((z=1;z<=7;z++))
do
if [ "$y" = "tuxpaintings" ]
then
rm /home/$x$z/.tuxpaint/saved/* 2> /dev/null
fi
if [ "$y" = "wordProcessing" ]
then
rm /home/$x$z/Documents/*.doc 2> /dev/null
rm /home/$x$z/Documents/*.odt 2> /dev/null
rm /home/$x$z/Documents/*.pdf 2> /dev/null
fi
if [ "$y" = "slideShows" ]
then
rm /home/$x$z/Documents/*.odp 2> /dev/null
rm /home/$x$z/Documents/*.ppt 2> /dev/null
fi
done
fi
done
done
zenity --info --text "<b>GRAB COMPLETED!</b>\n\nPlease verify that you properly "grabbed" this work by <b>checking the date and timestamp subfolders</b> contained in the <b>churchLab</b> Desktop folder.\n\n<b>Please <u>safely</u> remove your USB storage device now...</b>\n\nHave a nice day... and thank you for using <b>GRAB WORK!</b>\n\n"