From cff39031f390fb4137d236ad63ec539bb16db84e Mon Sep 17 00:00:00 2001 From: root Date: Wed, 30 May 2018 08:53:40 -0400 Subject: [PATCH 1/3] interface_status.sh to add entry for each sessions --- files/build_templates/sonic_debian_extension.j2 | 1 + files/image_config/interfaces/interface_mode.sh | 14 ++++++++++++++ 2 files changed, 15 insertions(+) create mode 100644 files/image_config/interfaces/interface_mode.sh diff --git a/files/build_templates/sonic_debian_extension.j2 b/files/build_templates/sonic_debian_extension.j2 index 3d46f09aa67..7a221be104d 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/interfaces/interface_mode.sh b/files/image_config/interfaces/interface_mode.sh new file mode 100644 index 00000000000..a9c6ced58c5 --- /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 From b789d8128d590273b27eff8a2bdc2d59e82a024e Mon Sep 17 00:00:00 2001 From: root Date: Tue, 3 Jul 2018 05:55:02 -0400 Subject: [PATCH 2/3] export IFMODE environment variable in environment and sudoers file --- files/image_config/environment/environment | 1 + files/image_config/sudoers/sudoers | 1 + 2 files changed, 2 insertions(+) diff --git a/files/image_config/environment/environment b/files/image_config/environment/environment index 6c85276371b..b57385f872c 100644 --- a/files/image_config/environment/environment +++ b/files/image_config/environment/environment @@ -1 +1,2 @@ VTYSH_PAGER=more +IFMODE=default diff --git a/files/image_config/sudoers/sudoers b/files/image_config/sudoers/sudoers index 4d651957afe..f20f0cf97db 100644 --- a/files/image_config/sudoers/sudoers +++ b/files/image_config/sudoers/sudoers @@ -10,6 +10,7 @@ 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 env_keep += "IFMODE" # Host alias specification From bfb31857d53b67b5c53e7b189128e0f53583a54a Mon Sep 17 00:00:00 2001 From: root Date: Mon, 16 Jul 2018 07:59:43 -0400 Subject: [PATCH 3/3] Renaming env variable IFMODE to SONIC_CLI_IFACE_MODE --- files/image_config/environment/environment | 2 +- files/image_config/sudoers/sudoers | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/files/image_config/environment/environment b/files/image_config/environment/environment index b57385f872c..3825856bcd7 100644 --- a/files/image_config/environment/environment +++ b/files/image_config/environment/environment @@ -1,2 +1,2 @@ VTYSH_PAGER=more -IFMODE=default +SONIC_CLI_IFACE_MODE=default diff --git a/files/image_config/sudoers/sudoers b/files/image_config/sudoers/sudoers index f20f0cf97db..677a136b75b 100644 --- a/files/image_config/sudoers/sudoers +++ b/files/image_config/sudoers/sudoers @@ -10,7 +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 env_keep += "IFMODE" +Defaults lecture_file = /etc/sudoers.lecture +Defaults env_keep += "SONIC_CLI_IFACE_MODE" # Host alias specification