Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision Next revision Both sides next revision | ||
linux_wiki:os_install_post_install [2017/09/12 22:55] billdozor [Post Install Script] |
linux_wiki:os_install_post_install [2017/09/12 23:07] billdozor [Post Install Script] |
||
---|---|---|---|
Line 309: | Line 309: | ||
* This script does all the heavy lifting (system updates, configuration, | * This script does all the heavy lifting (system updates, configuration, | ||
- | Post install script: Provide logging and error checking | + | ===== Post Install Script: Parent ===== |
+ | |||
+ | **Post install script**: Provide logging and error checking | ||
<code bash postinstall.sh> | <code bash postinstall.sh> | ||
+ | #!/bin/bash | ||
+ | # Title: postinstall.sh | ||
+ | # Description: | ||
+ | # Last Updated: 2016-10-24 | ||
+ | # Most Recent Changes: | ||
+ | ####################################################################################### | ||
+ | |||
+ | function print_usage | ||
+ | { | ||
+ | echo | ||
+ | echo " Usage: postinstall.sh [-y]" | ||
+ | echo | ||
+ | echo " | ||
+ | echo | ||
+ | echo " | ||
+ | echo " | ||
+ | echo " | ||
+ | echo " | ||
+ | echo | ||
+ | exit 1 | ||
+ | } | ||
+ | |||
+ | # | ||
+ | # Get Script Arguments | ||
+ | # | ||
+ | # Reset POSIX variable in case it has been used previously in this shell | ||
+ | OPTIND=1 | ||
+ | |||
+ | # By default, do not force run script. Prompt for running or not. | ||
+ | force_run_script=" | ||
+ | |||
+ | while getopts " | ||
+ | case " | ||
+ | h) # -h (help) argument | ||
+ | print_usage | ||
+ | exit 0 | ||
+ | ;; | ||
+ | y) # -y (yes to running script) argument | ||
+ | force_run_script=" | ||
+ | ;; | ||
+ | *) # invalid argument | ||
+ | print_usage | ||
+ | exit 0 | ||
+ | ;; | ||
+ | esac | ||
+ | done | ||
+ | |||
+ | ## | ||
+ | ## Pre-req checks | ||
+ | ## | ||
+ | |||
+ | ## Ensure we are root ## | ||
+ | if [[ $(id --user) -ne 0 ]]; then | ||
+ | echo ">> | ||
+ | exit 1 | ||
+ | fi | ||
+ | |||
+ | ## | ||
+ | ## Set Script Variables | ||
+ | ## | ||
+ | |||
+ | # Set base path from executed command (relative or full path works) | ||
+ | base_path=" | ||
+ | |||
+ | # Set log file and script locations | ||
+ | postinstall_log="/ | ||
+ | postinstall_worker=" | ||
+ | |||
+ | ## | ||
+ | ## Setup Logging | ||
+ | ## | ||
+ | echo -e ">> | ||
+ | |||
+ | # Clear log and timestamp the beginning | ||
+ | cat /dev/null > ${postinstall_log} | ||
+ | echo -e "---- Log Started: $(date) ----\n" | ||
+ | |||
+ | ## | ||
+ | ## Execute External Scripts | ||
+ | ## | ||
+ | # Start script, pass base path argument | ||
+ | if [[ ${force_run_script} == " | ||
+ | ${base_path}${postinstall_worker} -d ${base_path} 2>&1 | tee -a ${postinstall_log} | ||
+ | elif [[ ${force_run_script} == " | ||
+ | ${base_path}${postinstall_worker} -d ${base_path} -y 2>&1 | tee -a ${postinstall_log} | ||
+ | else | ||
+ | echo -e ">> | ||
+ | exit 1 | ||
+ | fi | ||
+ | |||
+ | ## | ||
+ | ## Close Logs, Show Location | ||
+ | ## | ||
+ | # Ending timestamp | ||
+ | echo -e " | ||
+ | |||
+ | # Reminder of where the log file is at | ||
+ | echo -e " | ||
+ | echo -e " | ||
</ | </ | ||
- | Post install worker: Perform the actual installations/ | + | ===== Post Install Script: Worker ===== |
+ | |||
+ | **Post install worker**: Perform the actual installations/ | ||
<code bash worker_postinstall.sh> | <code bash worker_postinstall.sh> | ||
</ | </ |