Fedora Linux Support Community & Resources Center
  #1  
Old 22nd June 2012, 04:32 PM
liomry Offline
Registered User
 
Join Date: Jun 2012
Location: Ireland
Posts: 2
windows_7chrome
Launch an interactive bash script before logging in to Gnome

I'm trying to create a bash script that will either prompt for input during init or launch itself in a gnome terminal before a user is asked to log in.

The purpose of this script is to run as root, request a hostname from the user and write this to /etc/sysconfig/network before disabling itself and rebooting the system

The issue I'm trying to address is conflicting hostnames when deploying vmware templates.

Here's what I've done so far, as an init script it just runs past and fails, even with -i after /bin/bash and X-Interactive =true. As an interactive script when logged in it works fine. I'm happy to just launch it as a once off terminal over GDM if someone can suggest a way to do that.

I'm not set on doing it this way, if anyone can suggest an alternative that would be great too.


#!/bin/bash
### BEGIN INIT INFO
# Provides: sethostname
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Set hostname on first boot then disable this service
# Description: takes hostname as input and writes /etc/sysconfig/network
# X-Interactive: true
### END INIT INFO

case "$1" in
start)
domain=mydomain.com
read -p "Please enter hostname for the system (Only hostname,do not enter .mydomain.com) " HOSTNAME

while [ -z "${HOSTNAME}" ]; do
read -p "Hostname cannot be empty. Please enter hostname " HOSTNAME
done

echo -e "HOSTNAME=${HOSTNAME}\nNETWORKING=yes\nNISDOMAIN=$ {domain}\nNTPSERVERARGS=iburst" > /etc/sysconfig/network
chkconfig sethostname off
reboot
exit 0
;;
stop)
exit 0
;;
restart | reload | force-reload | status | condrestart | try-restart)
exit 0
;;
usage)
exit 0
;;
asec
Reply With Quote
  #2  
Old 25th June 2012, 03:26 PM
liomry Offline
Registered User
 
Join Date: Jun 2012
Location: Ireland
Posts: 2
windows_7ie
Re: Launch an interactive bash script before logging in to Gnome

I figured out a workaround for this. What I do is set the pc to boot into runlevel 1 and append my script name to /root/.bashrc (after turning it into an ordinary script instead of an init script)

I deploy the template, when it boots first it goes to single user mode, asks for a hostname, sets the hostname, sets runlevel to 5, deletes the last line in /root/.bashrc and reboots. Slightly messy but I got there in the end
Reply With Quote
Reply

Tags
bash, gnome, interactive, launch, logging, script

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Bash script logging. glennzo Programming & Packaging 40 31st January 2012 12:30 PM
How do I launch a bash script (game) with a shorcut? premudriy Using Fedora 4 11th June 2010 09:54 AM
script to extend timeout of interactive login prompt mekon Using Fedora 4 21st April 2006 02:16 PM
How do I make bash interactive? ramdisc Programming & Packaging 7 30th October 2005 06:57 PM


Current GMT-time: 17:09 (Tuesday, 21-05-2013)

TopSubscribe to XML RSS for all Threads in all ForumsFedoraForumDotOrg Archive
logo

All trademarks, and forum posts in this site are property of their respective owner(s).
FedoraForum.org is privately owned and is not directly sponsored by the Fedora Project or Red Hat, Inc.

Privacy Policy | Term of Use | Posting Guidelines | Archive | Contact Us | Founding Members

Powered by vBulletin® Copyright ©2000 - 2012, vBulletin Solutions, Inc.

FedoraForum is Powered by RedHat