Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # File: install.sh
- #
- # Starts the install, you must copy your public ssh key to the target host before you run this script.
- #
- # ******** IMPORTANT MAKE SURE YOU HAVE THE CORRECT DEVICE. ALL DATA ON DEVICE WILL BE DELETED *******
- echo
- echo "Starting LFS build process."
- echo
- # Set some constants.
- USR=lfs
- HOST=$1 # The target host.
- DEVICE=sda # Device that will be used for the target system.
- SCRIPT=install.sh # Name of this script.
- LOGS=./$HOST-logs # The path to the log files.
- TIME_LOGS=$LOGS/build-time.log # The time logs file.
- echo -e "Executing Script: $SCRIPT, Time: $(date)\n" | tee $INFO_LOGS
- # Save start time, for timing script run time.
- start=`date +%s`
- source ./lfs-functions.sh &&
- rm -rf $LOGS
- # Create the logging directory and time log file.
- mkdir -p $LOGS && touch $TIME_LOGS
- # Copy source bash scripts to target host.
- echo -e "Copying source files to target host \"$HOST\"\n"
- scp lfs-* root@$HOST:~ &&
- echo -e "\nFiles copied to target host \"$HOST\" successfully.\n"
- # Login to remote host and run distribution prep script.
- echo -e "Logging into target host \"$HOST\" as root user.\n"
- ssh root@$HOST . ~/lfs-fedora.sh $USR $HOST $DEVICE &&
- # The distribution prep script on remote host has finished wait for host to come back online .
- echo
- echo -e "\nRebooting remote host: $HOST\n"
- echo -n "Waiting for host, $HOST to come back online: "
- # Display dots indicating time passing, well waiting for target host to come back online.
- for i in {1..5}; do sleep 1; echo -n "."; done
- while ! ping -c 1 -n -w 1 $HOST &> /dev/null; do echo -n "*"; done
- for i in {1..5}; do sleep 1; echo -n "."; done
- echo
- # Login to target host, the login will trigger the stage 1 prep script to execute.
- ssh root@$HOST &&
- end=`date +%s`
- echo -e "Finished Script: $SCRIPT, Time: $(date)\n" | tee $INFO_LOGS
- echo "S:$start E:$end T:$(format_time $[end-start]) S:$SCRIPT" >> $TIME_LOGS
- echo Build completed.
- exit
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement