diff options
author | Karen Arutyunov <karen@codesynthesis.com> | 2020-09-05 15:59:50 +0300 |
---|---|---|
committer | Karen Arutyunov <karen@codesynthesis.com> | 2020-09-07 19:21:14 +0300 |
commit | 6dcd9185e76fa64aa3ed7aa4f5de4a6ff179afa0 (patch) | |
tree | c0f5175068327a5b16146ff0ccebf5b14ba205a9 /etc | |
parent | 770cec3aced3cf4808d15eb8e57c9bcf8416252e (diff) |
Add --clean option to etc/private/install/brep-install
Diffstat (limited to 'etc')
-rwxr-xr-x | etc/private/install/brep-install | 39 |
1 files changed, 38 insertions, 1 deletions
diff --git a/etc/private/install/brep-install b/etc/private/install/brep-install index 0c6c2e6..046f99f 100755 --- a/etc/private/install/brep-install +++ b/etc/private/install/brep-install @@ -43,6 +43,14 @@ # Install and configure the brep instance, assuming that the 'brep' user # already exists and this script is executed as this user. # +# --clean +# +# At the end of the brep instance setup remove installation environment- +# specific traces (host name/IP from the configuration files, etc). Normally +# you would use this option to make the "clean" machine copy for +# distribution. Note that if this option is specified, then the brep +# instance will only be unusable after the machine reboot. +# usage="Usage: $0 [<options>]" # build2 toolchain repository certificate fingerprint. Note: this is a @@ -110,6 +118,7 @@ brep_id=63700 # Update the README file on change. # mount= setup= +clean= ops=() while [ "$#" -gt 0 ]; do @@ -128,6 +137,11 @@ while [ "$#" -gt 0 ]; do setup=true shift ;; + --clean) + clean=true + ops+=("$1") + shift + ;; *) break # The end of options is encountered. ;; @@ -162,7 +176,7 @@ EOF # # Note: here we rely on ops to not contain spaces or be empty. # - run exec sudo su -l brep --session-command "'$scr_exe' --setup ${ops[@]}" + run exec sudo su -l brep --session-command "'$scr_exe' --setup ${ops[*]}" fi # Here we assume that we are executed as brep user. @@ -431,3 +445,26 @@ run sudo systemctl start brep-load.timer run sudo systemctl status brep-load.timer >/dev/null run sudo systemctl enable brep-load.timer run sudo systemctl status brep-load.timer >/dev/null + +# Cleanup the installation environment-specific traces, if requested. +# +if [ "$clean" ]; then + + # Stop the relevant services. + # + run sudo systemctl stop brep-load.timer + run sudo systemctl stop apache2 + + # Remove the host name/IP from the configuration. + # + run cp "$scr_dir/brep-module.conf" config/ # Adjusted by brep-startup. + run rm config/loadtab # Recreated by brep-startup. + + # Finally, stop networking and cleanup the DHCP lease information. + # + # Note that after networking is stopped, sudo prints the 'unable to resolve + # host' diagnostics while trying to obtain the host IP. Thus, we execute the + # last two commands via a single sudo call. + # + run sudo bash -c "systemctl stop networking && rm -rf /var/lib/dhcp/*.leases" +fi |