diff --git a/files/build_templates/sonic_debian_extension.j2 b/files/build_templates/sonic_debian_extension.j2 index 3d46f09aa67a..7a221be104df 100644 --- a/files/build_templates/sonic_debian_extension.j2 +++ b/files/build_templates/sonic_debian_extension.j2 @@ -136,6 +136,7 @@ sudo cp $IMAGE_CONFIGS/interfaces/interfaces-config.service $FILESYSTEM_ROOT/et sudo LANG=C chroot $FILESYSTEM_ROOT systemctl enable interfaces-config.service sudo cp $IMAGE_CONFIGS/interfaces/interfaces-config.sh $FILESYSTEM_ROOT/usr/bin/ sudo cp $IMAGE_CONFIGS/interfaces/*.j2 $FILESYSTEM_ROOT_USR_SHARE_SONIC_TEMPLATES/ +sudo cp $IMAGE_CONFIGS/interfaces/interface_mode.sh $FILESYSTEM_ROOT/etc/profile.d/ # Copy initial interfaces configuration file, will be overwritten on first boot sudo cp $IMAGE_CONFIGS/interfaces/init_interfaces $FILESYSTEM_ROOT/etc/network diff --git a/files/image_config/environment/environment b/files/image_config/environment/environment index 6c85276371bf..3825856bcd72 100644 --- a/files/image_config/environment/environment +++ b/files/image_config/environment/environment @@ -1 +1,2 @@ VTYSH_PAGER=more +SONIC_CLI_IFACE_MODE=default diff --git a/files/image_config/interfaces/interface_mode.sh b/files/image_config/interfaces/interface_mode.sh new file mode 100644 index 000000000000..a9c6ced58c52 --- /dev/null +++ b/files/image_config/interfaces/interface_mode.sh @@ -0,0 +1,14 @@ +pts=$(tty | cut -d '/' -f4) + +#For console session +if [ -z "$pts" ]; then + pts=$(tty | cut -d '/' -f3 | cut -d 'S' -f2) +fi + +filename="pts"$pts".cfg" + +#remove stale entries +rm -rf /tmp/pts$pts.cfg + +#Create unique file entry for each tty +echo "interface_mode=DEFAULT" > /tmp/$filename diff --git a/files/image_config/sudoers/sudoers b/files/image_config/sudoers/sudoers index 4d651957afe2..677a136b75b6 100644 --- a/files/image_config/sudoers/sudoers +++ b/files/image_config/sudoers/sudoers @@ -10,6 +10,8 @@ Defaults env_reset #Defaults mail_badpass Defaults secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" Defaults env_keep += "VTYSH_PAGER" +Defaults lecture_file = /etc/sudoers.lecture +Defaults env_keep += "SONIC_CLI_IFACE_MODE" # Host alias specification