Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash -x
- ##################### Copy /opt folder to /mnt with progress
- DIALOGRC=${DIALOGRC}
- CONFIGFILE=/opt/setup/setup-tuxhat.conf
- DIALOG=${DIALOG=dialog}
- # config file for theme black and white
- if [[ -f $CONFIGFILE ]]; then
- source $CONFIGFILE
- else
- echo "Error missing file: setup-tuxhat.conf - Required by program"
- exit 1
- fi
- ## Create an array of all files in /opt directory
- DIRS=(/opt/setup/bin/setup-tuxhat/*)
- #Destination directory
- DEST="/mnt/usr/bin/"
- # Create $DEST if does not exits
- [ ! -d $DEST ] && mkdir -p $DEST
- # Show a progress bar
- # ---------------------------------
- # Redirect dialog commands input using substitution
- #
- DIALOGRC="$DIALOGRC" $DIALOG --title "Copy System files" --gauge "Copying files..." 10 75 < <(
- # Get total number of files in array
- n=${#DIRS[*]};
- # set counter - it will increase every-time a file is copied to $DEST
- i=0
- #
- # Start the for loop
- #
- # read each file from $DIRS array
- # $f has filename
- for f in "${DIRS[@]}"
- do
- # calculate progress
- PCT=$(( 100*(++i)/n ))
- # update dialog box
- cat <<EOF
- XXX
- $PCT
- Copying file "$f"...
- XXX
- EOF
- # copy file $f to $DEST
- /bin/cp -ar $f ${DEST} &>/dev/null
- done
- )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement