Advertisement
Uno-Dan

Install.sh

Jun 19th, 2019
244
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.55 KB | None | 0 0
  1. #!/bin/bash
  2. # File: install.sh
  3. #
  4. # Starts the install, you must copy your public ssh key to the target host before you run this script.
  5. #
  6.  
  7. echo
  8. echo "Starting LFS build process."
  9. echo
  10.  
  11. # Set some constants.
  12. USR=$1 # The build user.
  13. HOST=$2 # The target host.
  14. DEVICE=$3 # Device that will be used for the target system.
  15. SCRIPT=install.sh # Name of this script.
  16. LOGS=./$HOST-logs # The path to the log files.
  17. TIME_LOGS=$LOGS/build-time.log # The time logs file.
  18.  
  19. echo -e "Executing Script: $SCRIPT, Time: $(date)\n" | tee $INFO_LOGS
  20.  
  21. # Save start time for timing the script run time.
  22. start=`date +%s`
  23. source ./lfs-functions.sh
  24.  
  25. # Remove any previous logs.
  26. rm -rf $LOGS
  27.  
  28. # Create the logging directory and time log file.
  29. mkdir -p $LOGS && touch $TIME_LOGS
  30.  
  31. # Copy source bash scripts to target host.
  32. echo -e "Copying source files to target host \"$HOST\"\n"
  33. scp lfs-* root@$HOST:~ &&
  34. echo -e "\nFiles copied to target host \"$HOST\" successfully.\n"
  35.  
  36. # Login to remote host and run distribution prep script.
  37. echo -e "Logging into target host \"$HOST\" as root user.\n"
  38. ssh root@$HOST source ~/lfs-fedora.sh $USR $HOST $DEVICE &&
  39.  
  40. # The distribution script on remote host has finished,
  41. # wait for host to come back online .
  42. wait_for_reboot $HOST &&
  43.  
  44. # Login to target host, the login will trigger the stage 1 prep script to execute.
  45. ssh root@$HOST
  46.  
  47. end=`date +%s`
  48. echo -e "Finished Script: $SCRIPT, Time: $(date)\n" | tee $INFO_LOGS
  49. echo "S:$start E:$end T:$(format_time $[end-start]) S:$SCRIPT" >> $TIME_LOGS
  50. echo Build completed.
  51.  
  52. exit
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement