unixwz0r

hostname dialog input box

Jan 26th, 2015
336
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.92 KB | None | 0 0
  1. #--------------{ Hostname Setup }----------------#
  2. #configure_hostname(){
  3. #read -p "Hostname [ex: tuxhatlinux]: " host_name
  4. #echo "$host_name" > /mnt/etc/hostname
  5. #}
  6. configure_hostname(){
  7. DIALOGRC=${DIALOGRC}
  8. DISTNAME='Tux Hat Linux '
  9. DISTVER='v3.4'
  10. DASH='-'
  11. SCRIPTNAME='Setup Hostname'
  12.  
  13. CONFIGFILE=/home/gary/Test/setup-tuxhat.conf
  14. if [[ -f $CONFIGFILE ]]; then
  15.   source $CONFIGFILE
  16. else
  17.   echo "Error missing file: setup-tuxhat.conf - Required by program"
  18.   exit 1
  19. fi
  20.  
  21. ### Program for making the UI
  22.  
  23. DIALOG=${DIALOG=dialog}
  24. #DIALOG=${DIALOG=Xdialog}
  25.  
  26. # Temp files
  27.  
  28. tmpfile=`tmpfile 2> /dev/null` || tmpfile=/tmp/tmpfile$$
  29. trap "rm  -f $tmpfile" 0 1 2 5 15
  30.  
  31. DIALOGRC="$DIALOGRC" $DIALOG --backtitle "$DISTNAME$DISTVER $DASH $SCRIPTNAME " --no-shadow \
  32. --inputbox "Please enter new Hostname [ex: tuxhatlinux]" 8 48 0> $tmpfile
  33.  
  34. retval=$?
  35.  
  36. case $retval in
  37. 0)
  38. `cat $tmpfile` > /mnt/etc/hostname
  39. ;;
  40. esac
  41.  
  42. }
Advertisement
Add Comment
Please, Sign In to add comment