diff --git a/package-manifest.toml b/package-manifest.toml index 1eca2004f8..6bd40c320d 100644 --- a/package-manifest.toml +++ b/package-manifest.toml @@ -69,6 +69,7 @@ service_name = "overlay" source.type = "composite" source.packages = [ "logadm.tar.gz", + "profile.tar.gz", ] output.type = "zone" @@ -83,6 +84,18 @@ source.paths = [ ] output.type = "zone" output.intermediate_only = true +# +# The profile package is an overlay for all non-global zones to configure +# root's bash environment. +[package.profile] +service_name = "profile" +source.type = "local" +source.paths = [ + { from = "smf/profile/profile", to = "/root/.profile" }, + { from = "smf/profile/bashrc", to = "/root/.bashrc" }, +] +output.type = "zone" +output.intermediate_only = true [package.omicron-nexus] service_name = "nexus" @@ -335,7 +348,6 @@ source.paths = [ { from = "smf/switch_zone_setup/manifest.xml", to = "/var/svc/manifest/site/switch_zone_setup/manifest.xml" }, { from = "smf/switch_zone_setup/switch_zone_setup", to = "/opt/oxide/bin/switch_zone_setup" }, { from = "smf/switch_zone_setup/support_authorized_keys", to = "/opt/oxide/support/authorized_keys" }, - { from = "smf/switch_zone_setup/root.profile", to = "/root/.profile" }, ] output.type = "zone" output.intermediate_only = true diff --git a/smf/profile/bashrc b/smf/profile/bashrc new file mode 100644 index 0000000000..d19e41e5f7 --- /dev/null +++ b/smf/profile/bashrc @@ -0,0 +1,42 @@ + +C_RED='\[\033[01;31m\]' +C_GREEN='\[\033[01;32m\]' +C_CYAN='\[\033[01;36m\]' +C_BLD='\[\033[1m\]' +C_NUL='\[\033[00m\]' + +typeset _hst="$HOSTNAME" +typeset _hstc="$C_RED$HOSTNAME" +case "$_hst" in + oxz_switch) + # Try to determine which switch zone we are + _switchid=$(curl -s http://localhost:12225/local/switch-id \ + | /opt/ooce/bin/jq -r .slot) + if (( $? == 0 )) && [[ -n "$_switchid" ]]; then + _hst+="$_switchid" + _hstc+="$C_CYAN$_switchid" + fi + ;; + oxz_*-*) + # Shorten the hostname by truncating the UUID so that the prompt + # doesn't take up an excessive amount of width + _hst="${HOSTNAME%%-*}" + _hstc="$C_RED${HOSTNAME%%-*}" + ;; +esac + +if [[ -n $SSH_CLIENT ]]; then + echo -ne "\033]0;${_hst} \007" + export PROMPT_COMMAND='history -a' +fi + +case "$TERM" in +xterm*|rxvt*|screen*|sun-color) + PS1="$C_GREEN\\u$C_NUL@$_hstc$C_NUL:$C_RED\\w$C_NUL$C_BLD\\\$$C_NUL " + ;; +*) + PS1="\\u@$_hst:\\w\\$ " +esac + +export PS1 + diff --git a/smf/profile/profile b/smf/profile/profile new file mode 100644 index 0000000000..8f613d4d56 --- /dev/null +++ b/smf/profile/profile @@ -0,0 +1,24 @@ + +PATH+=:/opt/ooce/bin + +case "$HOSTNAME" in + oxz_switch) + # Add tools like xcvradm, swadm & ddmadm to the PATH by default + PATH+=:/opt/oxide/bin:/opt/oxide/dendrite/bin:/opt/oxide/mg-ddm/bin + ;; + oxz_cockroachdb*) + PATH+=:/opt/oxide/cockroachdb/bin + ;; + oxz_crucible*) + PATH+=:/opt/oxide/crucible/bin + ;; + oxz_clockhouse*) + PATH+=:/opt/oxide/clickhouse + ;; + oxz_external_dns*|oxz_internal_dns*) + PATH+=:/opt/oxide/dns-server/bin + ;; +esac + +[ -f ~/.bashrc ] && . ~/.bashrc + diff --git a/smf/switch_zone_setup/root.profile b/smf/switch_zone_setup/root.profile deleted file mode 100644 index b62b9e5403..0000000000 --- a/smf/switch_zone_setup/root.profile +++ /dev/null @@ -1,3 +0,0 @@ -# Add tools like xcvradm, swadm & ddmadm to the PATH by default -export PATH=$PATH:/opt/oxide/bin:/opt/oxide/dendrite/bin:/opt/oxide/mg-ddm/bin -