Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion a-seed-from-nothing.sh
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ cd $HOME
git clone https://github.com/stackhpc/beokay.git -b master

# Use Beokay to bootstrap your control host.
[[ -d deployment ]] || beokay/beokay.py create --base-path ~/deployment --kayobe-repo https://opendev.org/openstack/kayobe.git --kayobe-branch stable/2024.1 --kayobe-config-repo https://github.com/stackhpc/a-universe-from-nothing.git --kayobe-config-branch stable/2024.1
[[ -d deployment ]] || beokay/beokay.py create --base-path ~/deployment --kayobe-repo https://github.com/stackhpc/kayobe.git --kayobe-branch stackhpc/2024.1 --kayobe-config-repo https://github.com/stackhpc/a-universe-from-nothing.git --kayobe-config-branch stable/2024.1

# Bump the provisioning time - it can be lengthy on virtualised storage
sed -i.bak 's%^[# ]*wait_active_timeout:.*% wait_active_timeout: 5000%' ~/deployment/src/kayobe/ansible/overcloud-provision.yml
Expand Down Expand Up @@ -158,6 +158,23 @@ fi
export TENKS_CONFIG_PATH=~/deployment/src/kayobe-config/tenks.yml
~/deployment/src/kayobe/dev/tenks-deploy-overcloud.sh ~/deployment/src/tenks

if [[ -f ~/deployment/src/kayobe/dev/tenks-network-reboot-patch.sh ]]; then
echo "Setting up Tenks network persistence..."

# Make sure unit service and script are executable
chmod +x ~/deployment/src/kayobe-config/tenks-network-on-boot.service
chmod +x ~/deployment/src/kayobe-config/tenks-network-setup

# Move Service and Script to correct directory
sudo mv ~/deployment/src/kayobe-config/tenks-network-on-boot.service /etc/systemd/system/
sudo mv ~/deployment/src/kayobe-config/tenks-network-setup /bin/
Comment on lines +164 to +170

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

There are a few improvements that can be made to this block to align with best practices for shell scripting and system administration:

  • Systemd unit files (.service) do not need to be executable. Standard permissions are 644.
  • Using the install command is preferable to chmod followed by mv. It can copy the file and set its permissions in a single, atomic operation. It also copies rather than moves, which can make the script more idempotent if it needs to be re-run.
  • For custom scripts, /usr/local/bin is a more appropriate directory than /bin, which is typically reserved for essential system binaries. This follows the Filesystem Hierarchy Standard (FHS).

Here is a suggestion that incorporates these improvements:

Suggested change
# Make sure unit service and script are executable
chmod +x ~/deployment/src/kayobe-config/tenks-network-on-boot.service
chmod +x ~/deployment/src/kayobe-config/tenks-network-setup
# Move Service and Script to correct directory
sudo mv ~/deployment/src/kayobe-config/tenks-network-on-boot.service /etc/systemd/system/
sudo mv ~/deployment/src/kayobe-config/tenks-network-setup /bin/
# Copy Service and Script to correct directory and set permissions
sudo install -m 644 ~/deployment/src/kayobe-config/tenks-network-on-boot.service /etc/systemd/system/
sudo install -m 755 ~/deployment/src/kayobe-config/tenks-network-setup /usr/local/bin/


# Enable Service
sudo systemctl enable tenks-network-on-boot.service
else
echo "This version of Kayobe doesn't support Tenks network persistance."
fi

# Duration
duration=$SECONDS
echo "[INFO] $(($duration / 60)) minutes and $(($duration % 60)) seconds elapsed."