Project

General

Profile

Feature #911

Updated by Daniel Curtis over 6 years ago

I recently wanted to add the IP address of my development FreeBSD VMs to the console pre-login prompt, sparing me the time of logging in just to @ifconfig@ once so I can @ssh@ into the VM. Unfortunately FreeBSD does not use @/etc/issues@ like its Linux counterparts, but relies on /etc/gettytab and uses /etc/issue as a shim for text without the use of any macros. /etc/gettytab. 

 This is how I added the IP address of my machine to the pre-login console prompt on FreeBSD 11. 

 h2. update-issue script Add IP Address to /etc/gettytab 

 * Create an update-issue script: Edit /etc/gettytab: 
 <pre> 
 vi /usr/local/etc/rc.d/update-issue /etc/gettytab 
 </pre> 
 #* And add modify the following: 
 <pre> 
 #!/bin/sh 

 # PROVIDE: update-issue 
 # REQUIRE: NETWORKING syslogd 
 # KEYWORD: 

 . /etc/rc.subr 

 IPADDRESSESV4=$(ifconfig em0 | grep inet | awk '{print $2}') 

 for IPADDRESS in $IPADDRESSESV4; default:\ 
         do 
                 printf "IP: $IPADDRESS" > /etc/issue :cb:ce:ck:lc:fd#1000:im=\r\n%s/%m (%h) (%4) (%t)\r\n\r\n:sp#1200:\ 
         done; 

 echo "" >> /etc/issue :if=/etc/issue: 
 </pre> 

 * Make the script executable: 
 <pre> 
 chmod +x /usr/local/etc/rc.d/update-issue 
 </pre> 

 * Start and enable the script at boot: 
 <pre> 
 echo 'update_issue_enable="YES"' >> /etc/rc.conf 
 service update-issue start 
 </pre> 

 h2. Resources 

 * http://www.freebsddiary.org/prelogin.php 
 * https://forums.freebsd.org/threads/61798/ http://man7.org/linux/man-pages/man8/agetty.8.html 
 *

Back