> sys-unconfig has not been opensourced, and will not be.
Based on the man page from Solaris 10 it hardly looks like rocket science :
# man sys-unconfig
Reformatting page. Please Wait... done
System Administration Commands sys-unconfig(1M)
NAME
sys-unconfig - undo a system's configuration
SYNOPSIS
/usr/sbin/sys-unconfig
DESCRIPTION
The sys-unconfig command is used to restore a system's con-
figuration to an "as-manufactured" state, ready to be recon-
figured again. The system's configuration consists of host-
name, Network Information Service (NIS) domain name,
timezone, IP address, IP subnet mask, and root password.
This operation is the inverse of those performed by the
sysidnet(1M), sysidns(1M), and sysidsys(1M) programs run at
boot. See sysidtool(1M).
sys-unconfig does the following:
o Saves current /etc/inet/hosts file information in
/etc/inet/hosts.saved.
o If the current /etc/vfstab file contains NFS mount
entries, saves the /etc/vfstab file to
/etc/vfstab.orig.
o Restores the default /etc/inet/hosts file.
o Removes the default hostname in
/etc/hostname.interface files for all interfaces
configured when this command is run. To determine
which interfaces are configured, run the command
'ifconfig-a'. The /etc/hostname.interface files
corresponding to all of the interfaces listed in
the resulting output, with the exception of the
loopback interface (lo0), will be removed.
o Removes the default domainname in
/etc/defaultdomain.
o Restores the timezone to PST8PDT in /etc/TIMEZONE.
o Disables the Network Information Service (NIS) and
Network Information Service Plus (NIS+) if either
NIS or NIS+ was configured.
o Removes the file /etc/inet/netmasks.
o Removes the file /etc/defaultrouter.
o Removes the password set for root in /etc/shadow.
SunOS 5.10 Last change: 19 Jul 2007 1
System Administration Commands sys-unconfig(1M)
o Removes the file /etc/.rootkey.
o Executes all system configuration applications.
These applications are defined by prior executions
of a sysidconfig -a application. (See
sysidconfig(1M)). When sys-unconfig is run, all
system configuration applications are passed one
argument, -u.
o Removes the file /etc/resolv.conf.
o Removes the file /etc/sysidcfg.
o Disables LDAP by removing
/var/ldap/ldap_client_cache,
/var/ldap/ldap_client_file,
/var/ldap/ldap_client_cred, and
/var/ldap/cachemgr.log.
o Regenerates keys for sshd(1M).
When sys-unconfig is finished, it performs a system shut-
down. sys-unconfig is a potentially dangerous utility and
can only be run by the super user.
FILES
/etc/default/init
process control initialization
/etc/defaultdomain
determines host's domain name
/etc/defaultrouter
specifies an IPv4 host's default router
/etc/hostname.interface
identifies symbolic host name associated with network
interface interface
/etc/inet/hosts
host name database
SunOS 5.10 Last change: 19 Jul 2007 2
System Administration Commands sys-unconfig(1M)
/etc/inet/netmasks
network mask database
/etc/nodename
local source for system name
/etc/.rootkey
super-user's secret key
/etc/shadow
shadow password file
/etc/sysidcfg
system identification configuration file for diskless
booting
/etc/vfstab
virtual file system table
/var/nis/NIS_COLD_START
list of NIS+ servers that serve a host's default domain
/var/yp/binding/*/ypservers
identifies NIS servers to which the client is allowed to
bind
ATTRIBUTES
See attributes(5) for descriptions of the following attri-
butes:
SunOS 5.10 Last change: 19 Jul 2007 3
System Administration Commands sys-unconfig(1M)
____________________________________________________________
| ATTRIBUTE TYPE | ATTRIBUTE VALUE |
|_____________________________|_____________________________|
| Availability | SUNWadmap |
|_____________________________|_____________________________|
SEE ALSO
init(1M), kdmconfig(1M), sshd(1M), sysidconfig(1M),
sysidtool(1M), hosts(4), netmasks(4), shadow(4),
sysidcfg(4), attributes(5)
NOTES
sys-unconfig is not available on diskless clients.
SunOS 5.10 Last change: 19 Jul 2007 4
-----------------
So a first hack prototype that would do those things would be :
1) determine if I am in init 2 or 3 or S. This thing should run
in init S in my opinion and issue a warning and politely
EXIT otherwise.
2) go looking for all those files to see if they exist and build
an array of files to backup or otherwise touch.
3) process them from top to bottom :
3.1) if file does not exist then create it with some defaults
3.2) if file exists then determine if it is sane. By this I
mean that it is not a binary blob where an ASCII file is
expected. If insane .. bail out in a nasty fashion and
tell the user you no longer like them. Or similar. :-)
If we get this far on any given file then have some rules
to follow to hack that file back into default shape.
That may mean, back it up, rename it, kill it, create a
new one. Just be verbose about it and tell the user
what we just did.
4) Do we reboot the box at the end of this ? Probably exec init 5
or init 0 or similar.
These are just my thoughts.
Dennis
_______________________________________________
distribution-discuss mailing list
[email protected]
http://mail.opensolaris.org/mailman/listinfo/distribution-discuss