Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # Copyright (C) 2012 Quiliro Ordóñez and IgnorantGuru
- #
- # This program is free software: you can redistribute it and/or modify
- # it under the terms of the GNU Affero General Public License as
- # published by the Free Software Foundation, either version 3 of the
- # License, or (at your option) any later version.
- #
- # This program is distributed in the hope that it will be useful,
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
- # GNU Affero General Public License for more details.
- #
- # You should have received a copy of the GNU Affero General Public
- # License along with this program.If not, see
- # <http://www.gnu.org/licenses/>.
- #
- # http://igurublog.wordpress.com
- # quiliro [at] fsfla [dot] org
- #
- #
- # Instructions to replicate:
- #
- # Copy the operating system to another USB memory by changing to the
- # directory where the image is and executing this command:
- # dd if=bom_compartilhar.img of=/dev/sdb
- # where sdb is the device corresponding to the destination USB memory.
- # You should type:
- # mount
- #
- # to discover which devices are currently mounted and deduce which one
- # is you destination USB memory. Then unmount the destination USB
- # memory and proceed to copy the operating system.
- #
- # Configure Num Lock to OFF in BIOS.
- #
- # Note: If you didn't copy the operating system from my image, you
- # should install the necesary packages. On Parabola GNU, the command
- # is:
- # pacman -S udevil rsync dosfstools sudo
- #
- # In order to start this script on boot, make it executable with:
- # chmod u+x copiar_usb.bash
- #
- # and at the end of Parabola's /etc/rc.local file, add:
- # devmon --exec-on-drive "/home/bom/copiar_usb.bash %f %d" &
- # setleds -num +caps -scroll < /dev/tty1 &
- #
- # Keep hacking this script and let us know your progress!
- #
- keyboard="/dev/tty1"
- echo
- echo "Changing Caps Lock to OFF"
- setleds -caps < $keyboard
- native_path=`udevil --show-info $1 | grep "^ native-path:" | sed 's/^ native-path: *\(.*\) */\1/'`
- usb_port="${native_path##*/usb[[:digit:]]/}"
- echo
- echo "native_path is " $native_path
- echo "usb_port is " $usb_port
- usb_port="${usb_port%%/*}"
- echo "Now usb_port is " $usb_port
- echo
- echo "%f device filesystem - is " $1
- echo "%d mount directory - is " $2
- echo
- case "$usb_port" in
- "1-1" )
- echo
- echo "Changing Num Lock to ON"
- setleds +num < $keyboard
- ## One attempt at erasing the recycle bin:
- # echo "Testing if enough space is left on the device"
- # contents="du -s /home/bom/bom_compartilhar"
- # (( $( read -d '' -ra df < <(LC_ALL=C df -P "$1" ); echo "${df[10]}" ) < contents)) && echo rm -rf "$2"/.Trash*;
- #
- ## Another attempt at erasing the recycle bin:
- # free_space=$(df | grep $1 | awk '{ print '$4'; }')
- # if [ $contents -lt $free_space ]; then
- # echo "Not enough free space on $2. Erasing Trash bin."
- # find $2 -name ".Trash*" -exec rm -rf {} \;
- # fi
- echo
- echo "Downloading to device $1 on port $usb_port mounted on $2"
- echo
- rsync -a /home/bom/bom_compartilhar "$2"/
- ;;
- "2-1" )
- echo
- echo "Changing Scroll Lock to ON"
- setleds +scroll < $keyboard
- echo
- echo "Uploading from device $1 on port $usb_port mounted on $2"
- echo
- rsync -a "$2"/bom_compartilhar /home/bom/
- ;;
- "" )
- echo "usb port for device \"$1\" could not be determined"
- exit 1
- ;;
- * )
- echo "usb port $usb_port for device $1 ignored"
- esac
- devmon --unmount $1
- echo
- echo "Changing Caps Lock to ON and the others to OFF"
- setleds -num +caps -scroll < $keyboard
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement