From 3e221bf3c440a956fefb2e0b11ab20cccc0d578e Mon Sep 17 00:00:00 2001 From: teutat3s <10206665+teutat3s@users.noreply.github.com> Date: Sun, 5 Jun 2022 23:40:31 +0200 Subject: [PATCH] Prepare scripts for nix build integration --- src/linux/lib/smartdc/firstboot | 11 ++++++----- src/linux/lib/smartdc/format-secondary-disk | 2 +- src/linux/lib/smartdc/get-user-data | 2 +- src/linux/lib/smartdc/joyent_rc.local | 16 ++++++++-------- src/linux/lib/smartdc/lib_smartdc_scripts.cfg | 6 +++--- src/linux/lib/smartdc/run-operator-script | 2 +- src/linux/lib/smartdc/run-user-script | 2 +- src/linux/lib/smartdc/send-arp-updates | 2 +- src/linux/lib/smartdc/set-hostid | 2 +- src/linux/lib/smartdc/set-hostname | 2 +- src/linux/lib/smartdc/set-root-authorized-keys | 2 +- src/linux/lib/smartdc/set-rootpassword | 2 +- 12 files changed, 26 insertions(+), 25 deletions(-) diff --git a/src/linux/lib/smartdc/firstboot b/src/linux/lib/smartdc/firstboot index 044adca..6bd022f 100755 --- a/src/linux/lib/smartdc/firstboot +++ b/src/linux/lib/smartdc/firstboot @@ -4,21 +4,22 @@ # For scripts that should be run on first boot only # load common functions and vars -. /lib/smartdc/lib_smartdc_scripts.cfg +. /__replace_lib/smartdc/lib_smartdc_scripts.cfg lib_smartdc_info "Start of $(basename $0) script" # Set root password if root_pw is set in the image manifest -(/lib/smartdc/set-rootpassword) +(/__replace_lib/smartdc/set-rootpassword) # Set hostid -(/lib/smartdc/set-hostid) +(/__replace_lib/smartdc/set-hostid) # Format disk -(/lib/smartdc/format-secondary-disk) +(/__replace_lib/smartdc/format-secondary-disk) # Disable firstboot once all scripts are run lib_smartdc_info "Disabling firstboot" -touch /lib/smartdc/.firstboot-complete-do-not-delete +mkdir -p /var/lib/smartdc +touch /var/lib/smartdc/.firstboot-complete-do-not-delete exit 0 diff --git a/src/linux/lib/smartdc/format-secondary-disk b/src/linux/lib/smartdc/format-secondary-disk index cfc6eb4..777b853 100755 --- a/src/linux/lib/smartdc/format-secondary-disk +++ b/src/linux/lib/smartdc/format-secondary-disk @@ -8,7 +8,7 @@ # by default we provision the whole disk as one partition # load common functions and vars -. /lib/smartdc/lib_smartdc_scripts.cfg +. /__replace_lib/smartdc/lib_smartdc_scripts.cfg SFDISK=`which sfdisk 2> /dev/null` PARTED=`which parted 2> /dev/null` diff --git a/src/linux/lib/smartdc/get-user-data b/src/linux/lib/smartdc/get-user-data index 38a1a04..e2499a1 100755 --- a/src/linux/lib/smartdc/get-user-data +++ b/src/linux/lib/smartdc/get-user-data @@ -7,7 +7,7 @@ # before script "run-user-script" # load common functions and vars -. /lib/smartdc/lib_smartdc_scripts.cfg +. /__replace_lib/smartdc/lib_smartdc_scripts.cfg lib_smartdc_info "Retrieving metadata user-data" diff --git a/src/linux/lib/smartdc/joyent_rc.local b/src/linux/lib/smartdc/joyent_rc.local index 1641417..75f7953 100755 --- a/src/linux/lib/smartdc/joyent_rc.local +++ b/src/linux/lib/smartdc/joyent_rc.local @@ -6,7 +6,7 @@ # this is called from /etc/rc.local # load common functions and vars -. /lib/smartdc/lib_smartdc_scripts.cfg +. /__replace_lib/smartdc/lib_smartdc_scripts.cfg # DO NOT use lib_smartdc_fatal in here # You want the rest of the init script to run @@ -112,14 +112,14 @@ case `uname -s | tr '[:upper:]' '[:lower:]'` in esac # scripts that can run on all systems -(/lib/smartdc/set-root-authorized-keys) -if [[ ! -f /lib/smartdc/.firstboot-complete-do-not-delete ]] ; then - (/lib/smartdc/firstboot) +(/__replace_lib/smartdc/set-root-authorized-keys) +if [[ ! -f /var/lib/smartdc/.firstboot-complete-do-not-delete ]] ; then + (/__replace_lib/smartdc/firstboot) fi -(/lib/smartdc/set-hostname) -(/lib/smartdc/run-operator-script) -(/lib/smartdc/get-user-data) -(/lib/smartdc/run-user-script) +(/__replace_lib/smartdc/set-hostname) +(/__replace_lib/smartdc/run-operator-script) +(/__replace_lib/smartdc/get-user-data) +(/__replace_lib/smartdc/run-user-script) if [[ ! -d /var/lock/subsys ]] ; then mkdir -p /var/lock/subsys diff --git a/src/linux/lib/smartdc/lib_smartdc_scripts.cfg b/src/linux/lib/smartdc/lib_smartdc_scripts.cfg index 1d9a045..37618c7 100755 --- a/src/linux/lib/smartdc/lib_smartdc_scripts.cfg +++ b/src/linux/lib/smartdc/lib_smartdc_scripts.cfg @@ -2,7 +2,7 @@ # Copyright (c) 2014, Joyent, Inc. All rights reserved. # -# Common variables used by scripts in /lib/smartdc +# Common variables used by scripts in /__replace_lib/smartdc # location of binaries that functions use LOGGER=`which logger 2> /dev/null` @@ -10,13 +10,13 @@ UNAME_BIN=`which uname 2> /dev/null` MOUNT_BIN=`which mount 2> /dev/null` MDATA_GET_BIN='/usr/sbin/mdata-get' -SEND_ARP_UPDATES_BIN='/lib/smartdc/send-arp-updates' +SEND_ARP_UPDATES_BIN='/__replace_lib/smartdc/send-arp-updates' # location of common files USER_SCRIPT_FILE='/var/tmp/user-script' USER_SCRIPT_LOCKFILE='/var/tmp/user-script.lock' -# Common functions used by scripts /lib/smartdc +# Common functions used by scripts /__replace_lib/smartdc lib_smartdc_fatal() { echo " " diff --git a/src/linux/lib/smartdc/run-operator-script b/src/linux/lib/smartdc/run-operator-script index e76c813..7a7b38e 100755 --- a/src/linux/lib/smartdc/run-operator-script +++ b/src/linux/lib/smartdc/run-operator-script @@ -3,7 +3,7 @@ # Copyright (c) 2013 Joyent Inc., All rights reserved. # -. /lib/smartdc/lib_smartdc_scripts.cfg +. /__replace_lib/smartdc/lib_smartdc_scripts.cfg SCRIPT=/tmp/.operator-script rm -f $SCRIPT diff --git a/src/linux/lib/smartdc/run-user-script b/src/linux/lib/smartdc/run-user-script index 5830ba8..434fd5a 100755 --- a/src/linux/lib/smartdc/run-user-script +++ b/src/linux/lib/smartdc/run-user-script @@ -10,7 +10,7 @@ # This script is executed on each system boot # load common functions and vars -. /lib/smartdc/lib_smartdc_scripts.cfg +. /__replace_lib/smartdc/lib_smartdc_scripts.cfg # set run_userscript_flag to the string TRUE # to remove $USER_SCRIPT_LOCKFILE so that userscript is ran diff --git a/src/linux/lib/smartdc/send-arp-updates b/src/linux/lib/smartdc/send-arp-updates index f686954..61c49be 100755 --- a/src/linux/lib/smartdc/send-arp-updates +++ b/src/linux/lib/smartdc/send-arp-updates @@ -9,7 +9,7 @@ # This script sends gratuitous arp packets to force an arp cache update # load common functions and vars -. /lib/smartdc/lib_smartdc_scripts.cfg +. /__replace_lib/smartdc/lib_smartdc_scripts.cfg set -o errexit set -o pipefail diff --git a/src/linux/lib/smartdc/set-hostid b/src/linux/lib/smartdc/set-hostid index 00914a9..075b467 100755 --- a/src/linux/lib/smartdc/set-hostid +++ b/src/linux/lib/smartdc/set-hostid @@ -4,7 +4,7 @@ # Explicitly set hostid. # load common functions and vars -. /lib/smartdc/lib_smartdc_scripts.cfg +. /__replace_lib/smartdc/lib_smartdc_scripts.cfg lib_smartdc_info "Start of $(basename $0) script" diff --git a/src/linux/lib/smartdc/set-hostname b/src/linux/lib/smartdc/set-hostname index 95f075d..ba3f4cc 100755 --- a/src/linux/lib/smartdc/set-hostname +++ b/src/linux/lib/smartdc/set-hostname @@ -4,7 +4,7 @@ # # load common functions and vars -. /lib/smartdc/lib_smartdc_scripts.cfg +. /__replace_lib/smartdc/lib_smartdc_scripts.cfg # set system host name in this order # 1) use /etc/hostname if it is not empty diff --git a/src/linux/lib/smartdc/set-root-authorized-keys b/src/linux/lib/smartdc/set-root-authorized-keys index b7a19aa..72466bf 100755 --- a/src/linux/lib/smartdc/set-root-authorized-keys +++ b/src/linux/lib/smartdc/set-root-authorized-keys @@ -9,7 +9,7 @@ # By default this script is called on each boot # load common functions and vars -. /lib/smartdc/lib_smartdc_scripts.cfg +. /__replace_lib/smartdc/lib_smartdc_scripts.cfg # set overwrite_root_akeys to the string OVERWRITE # to overwrite root authorized_keys on reboot diff --git a/src/linux/lib/smartdc/set-rootpassword b/src/linux/lib/smartdc/set-rootpassword index d4ff469..74d42d0 100755 --- a/src/linux/lib/smartdc/set-rootpassword +++ b/src/linux/lib/smartdc/set-rootpassword @@ -12,7 +12,7 @@ # /etc/shadow to ensure a root password is not being overwritten. # load common functions and vars -. /lib/smartdc/lib_smartdc_scripts.cfg +. /__replace_lib/smartdc/lib_smartdc_scripts.cfg lib_smartdc_info "Start of $(basename $0) script" -- 2.36.0