Network Configuration Script
#1
Network Configuration Script
Hey guys,

Worked today on an IRIX configuration script that uses ksh and is usable on a base install. It'll allow you to setup a network moreorless automatically given hostname, resolvers, gateway, etc.

Code:
#!/bin/ksh

# Functions of this script

function sysid {

echo -ne 'I need a hostname: '
read h
printf $h > /etc/sys_id

}

function resolv {

echo -ne 'Give me a primary DNS resolver IP: '
read r1
echo -ne 'Give me a secondary DNS resolver IP: '
read r2

printf "nameserver $r1\nnameserver $r2\n" > /etc/resolv.conf

}

function set_ip {

echo -ne 'Give me your IP address: '
read ip
printf "$ip   $h\n" >> /etc/hosts


printf 'Disabling network services...\n'
chkconfig autoconfig_ipaddress off
chkconfig routed off

echo -ne 'Now I need your default gateway: '
read dg

printf "\$ROUTE \$QUIET add -net default $dg\n" >> /etc/config/static-route.options

}

function zone {

echo -ne 'Finally, lets get your timezone. You need to use the format, EST5EDT4. When ready, enter it: '
read tz

printf "TZ=$tz" > /etc/TIMEZONE

ntpdate us.pool.ntp.org
}

case $1 in

        -hn)
        sysid ;;

    -rs)
        resolv ;;

        -ip)
        set_ip ;;

        -a)
        printf "Performing normal setup...\n"
        sysid
        resolv
        set_ip
        zone ;;

    -nt)
        printf "Networking setup...\n"
        sysid
        resolv
        set_ip
        ;;

        *)
        printf 'netsetup - convenient script for quick IRIX networking setup\n
usage: netsetup <option>\n\n -hn: hostname setup\n\n -rs: DNS resolver\n\n -ip: Configure static IP\n\n -a: normal setup, does all tasks include timezone
\n -nt just networking tasks (no timezone)\n'
        ;;
esac


Suggestions, testing etc. are welcomed. If you use it, I'm not responsible for nuking a functional config.

I'm the system admin of this site. Private security technician, licensed locksmith, hack of a c developer and vintage computer enthusiast. 

https://contrib.irixnet.org/raion/ -- contributions and pieces that I'm working on currently. 

https://codeberg.org/SolusRaion -- Code repos I control

Technical problems should be sent my way.
Raion
Chief IRIX Officer

Trade Count: (9)
Posts: 4,264
Threads: 537
Joined: Nov 2017
Location: Eastern Virginia
Website Find Reply
02-07-2020, 02:29 AM


Messages In This Thread
Network Configuration Script - by Raion - 02-07-2020, 02:29 AM
RE: Network Configuration Script - by Raion - 02-07-2020, 06:35 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)