ttys (252995) | ttys (263791) |
---|---|
1#!/bin/sh 2#- 3# Copyright (c) 2012-2013 Devin Teske 4# All rights reserved. 5# 6# Redistribution and use in source and binary forms, with or without 7# modification, are permitted provided that the following conditions 8# are met: --- 10 unchanged lines hidden (view full) --- 19# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 21# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25# SUCH DAMAGE. 26# | 1#!/bin/sh 2#- 3# Copyright (c) 2012-2013 Devin Teske 4# All rights reserved. 5# 6# Redistribution and use in source and binary forms, with or without 7# modification, are permitted provided that the following conditions 8# are met: --- 10 unchanged lines hidden (view full) --- 19# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 21# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25# SUCH DAMAGE. 26# |
27# $FreeBSD: stable/9/usr.sbin/bsdconfig/console/ttys 252995 2013-07-07 19:13:34Z dteske $ | 27# $FreeBSD: stable/9/usr.sbin/bsdconfig/console/ttys 263791 2014-03-27 03:20:47Z dteske $ |
28# 29############################################################ INCLUDES 30 31BSDCFG_SHARE="/usr/share/bsdconfig" 32. $BSDCFG_SHARE/common.subr || exit 1 33f_dprintf "%s: loading includes..." "$0" 34f_include $BSDCFG_SHARE/dialog.subr 35f_include $BSDCFG_SHARE/mustberoot.subr 36f_include $BSDCFG_SHARE/sysrc.subr 37 38BSDCFG_LIBE="/usr/libexec/bsdconfig" APP_DIR="080.console" 39f_include_lang $BSDCFG_LIBE/$APP_DIR/include/messages.subr 40 | 28# 29############################################################ INCLUDES 30 31BSDCFG_SHARE="/usr/share/bsdconfig" 32. $BSDCFG_SHARE/common.subr || exit 1 33f_dprintf "%s: loading includes..." "$0" 34f_include $BSDCFG_SHARE/dialog.subr 35f_include $BSDCFG_SHARE/mustberoot.subr 36f_include $BSDCFG_SHARE/sysrc.subr 37 38BSDCFG_LIBE="/usr/libexec/bsdconfig" APP_DIR="080.console" 39f_include_lang $BSDCFG_LIBE/$APP_DIR/include/messages.subr 40 |
41ipgm=$( f_index_menusel_keyword $BSDCFG_LIBE/$APP_DIR/INDEX "$pgm" ) 42[ $? -eq $SUCCESS -a "$ipgm" ] && pgm="$ipgm" | 41f_index_menusel_keyword $BSDCFG_LIBE/$APP_DIR/INDEX "$pgm" ipgm && 42 pgm="${ipgm:-$pgm}" |
43 44############################################################ CONFIGURATION 45 46# 47# Location of ttys(5) 48# 49ETC_TTYS=/etc/ttys 50 --- 36 unchanged lines hidden (view full) --- 87 --menu \"\$prompt\" \ 88 $height $width $rows \ 89 $menu_list \ 90 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD 91 ) 92 local retval=$? 93 f_dialog_menutag_store -s "$menu_choice" 94 | 43 44############################################################ CONFIGURATION 45 46# 47# Location of ttys(5) 48# 49ETC_TTYS=/etc/ttys 50 --- 36 unchanged lines hidden (view full) --- 87 --menu \"\$prompt\" \ 88 $height $width $rows \ 89 $menu_list \ 90 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD 91 ) 92 local retval=$? 93 f_dialog_menutag_store -s "$menu_choice" 94 |
95 if [ $retval -eq $SUCCESS ]; then | 95 if [ $retval -eq $DIALOG_OK ]; then |
96 local item 97 item=$( eval f_dialog_menutag2item \ 98 \"\$menu_choice\" $menu_list ) 99 f_dialog_menuitem_store "$item" 100 fi 101 102 return $retval 103} 104 105# ttys_set_type $consterm 106# 107# Set terminal type of `ttyv*' and `cons[0-9]' entries in ttys(5) to $consterm. 108# 109ttys_set_type() 110{ | 96 local item 97 item=$( eval f_dialog_menutag2item \ 98 \"\$menu_choice\" $menu_list ) 99 f_dialog_menuitem_store "$item" 100 fi 101 102 return $retval 103} 104 105# ttys_set_type $consterm 106# 107# Set terminal type of `ttyv*' and `cons[0-9]' entries in ttys(5) to $consterm. 108# 109ttys_set_type() 110{ |
111 local funcname=ttys_set_type |
|
111 local consterm="$1" err 112 113 # 114 # Create new temporary file to write our ttys(5) update with new types. 115 # | 112 local consterm="$1" err 113 114 # 115 # Create new temporary file to write our ttys(5) update with new types. 116 # |
116 local tmpfile="$( mktemp -t "pgm" )" 117 [ "$tmpfile" ] || return $FAILURE | 117 local tmpfile 118 f_eval_catch -k tmpfile $funcname mktemp 'mktemp -t "%s"' "$pgm" || 119 return $FAILURE |
118 119 # 120 # Fixup permissions and ownership (mktemp(1) creates the temporary file 121 # with 0600 permissions -- change the permissions and ownership to 122 # match ttys(5) before we write it out and mv(1) it into place). 123 # | 120 121 # 122 # Fixup permissions and ownership (mktemp(1) creates the temporary file 123 # with 0600 permissions -- change the permissions and ownership to 124 # match ttys(5) before we write it out and mv(1) it into place). 125 # |
124 local mode="$( stat -f '%#Lp' "$ETC_TTYS" 2> /dev/null )" 125 local owner="$( stat -f '%u:%g' "$ETC_TTYS" 2> /dev/null )" 126 f_quietly chmod "${mode:-0644}" "$tmpfile" 127 f_quietly chown "${owner:-root:wheel}" "$tmpfile" | 126 local mode owner 127 f_eval_catch -dk mode $funcname stat \ 128 'stat -f "%%#Lp" "%s"' "$ETC_TTYS" || mode=0644 129 f_eval_catch -dk owner $funcname stat \ 130 'stat -f "%%u:%%g" "%s"' "$ETC_TTYS" || owner="root:wheel" 131 f_eval_catch -d $funcname chmod 'chmod "%s" "%s"' "$mode" "$tmpfile" 132 f_eval_catch -d $funcname chown 'chown "%s" "%s"' "$owner" "$tmpfile" |
128 129 # 130 # Operate on ttys(5), replacing only the types of `ttyv*' and 131 # `cons[0-9]' terminals with the new type. 132 # 133 if ! err=$( awk -v consterm="$consterm" ' 134 BEGIN { 135 } --- 15 unchanged lines hidden (view full) --- 151 match($0, /[[:space:]]+(on|off).*$/) 152 right = substr($0, RSTART) 153 printf "%s%s%s\n", left, consterm, right 154 } 155 ' "$ETC_TTYS" > "$tmpfile" 2>&1 ); then 156 f_dialog_msgbox "$err" 157 return $FAILURE 158 fi | 133 134 # 135 # Operate on ttys(5), replacing only the types of `ttyv*' and 136 # `cons[0-9]' terminals with the new type. 137 # 138 if ! err=$( awk -v consterm="$consterm" ' 139 BEGIN { 140 } --- 15 unchanged lines hidden (view full) --- 156 match($0, /[[:space:]]+(on|off).*$/) 157 right = substr($0, RSTART) 158 printf "%s%s%s\n", left, consterm, right 159 } 160 ' "$ETC_TTYS" > "$tmpfile" 2>&1 ); then 161 f_dialog_msgbox "$err" 162 return $FAILURE 163 fi |
159 if ! err=$( mv -f "$tmpfile" "$ETC_TTYS" 2>&1 ); then 160 f_dialog_msgbox "$err" | 164 f_eval_catch $funcname mv 'mv -f "%s" "%s"' "$tmpfile" "$ETC_TTYS" || |
161 return $FAILURE | 165 return $FAILURE |
162 fi | |
163 164 return $SUCCESS 165} 166 167############################################################ MAIN 168 169# Incorporate rc-file if it exists 170[ -f "$HOME/.bsdconfigrc" ] && f_include "$HOME/.bsdconfigrc" --- 34 unchanged lines hidden --- | 166 167 return $SUCCESS 168} 169 170############################################################ MAIN 171 172# Incorporate rc-file if it exists 173[ -f "$HOME/.bsdconfigrc" ] && f_include "$HOME/.bsdconfigrc" --- 34 unchanged lines hidden --- |