#!/usr/bin/perl -w # # mkissue # jms1 2002-12-08 (actually written long ago, who knows when...) # # generates a suitable /etc/issue file for a machine, the way i like it # assumes the console is 80 columns wide- maybe a future version could be # written to let the width be specified? (i.e. for sun consoles, which # are 128 characters wide) # # 2002-12-08 jms1 - wrote a little C program to return the width of the # screen. whatever script calls this program should supply this number # as a second command-line parameter. if not, we will default to 80. # # 2003-03-26 jms1 - changing it to work as a bootup script. Assumes the # filenames it needs. # # 2003-03-28 jms1 - switching to "stty" instead of the C program # # 2005-04-09 jms1 - changed copyright notice to indicate my intention # that this code is licensed under GPL version 2 only, rather than # GPL version 2 "or later". # ############################################################################### # # Copyright (C) 2002-2005 John Simpson. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License, version 2, as # published by the Free Software Foundation. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # or visit http://www.gnu.org/licenses/gpl.txt # ############################################################################### require 5.003 ; use strict ; my ( $stty , $rows , $cols , $hostname , $dp , $tp , $hp ) ; $stty = "" ; if ( open ( I , "stty -a |" ) ) { map { $stty .= $_ } ; close I ; $stty =~ /rows (\d+)/ ; $rows = $1 ; $stty =~ /columns (\d+)/ ; $cols = $1 ; } else { $rows = 25 ; $cols = 80 ; } $hostname = ( shift || `/bin/hostname -f` ) ; chomp $hostname ; $dp = $cols - 24 ; $tp = $cols - 7 ; $hp = int ( ( $cols - length ( $hostname ) ) / 2 ) ; open ( O , ">/etc/issue" ) or die "Can\'t create /etc/issue: $!\n" ; print O <