Plan 9 from Bell Labs’s /usr/web/sources/contrib/boyd/sys/src/cmd/rename.html

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


<html>
<body>
<pre>
<tt>
#!/bin/rc

# rename old-hostname new-hostname

path=(/etc /usr/local/etc $path)

myname=`{basename $0}

fn usage {
	echo 'usage: '$myname^' old-hostname new-hostname' &gt;[2=1]
	exit 1
}

! ~ $#'*' 2 &amp;&amp; usage

echo $myname^: 'WARNING - this is not for the handyman,  professional installation only.' &gt;[2=1]

! ~ `hostname perle &amp;&amp; {
	echo $myname^: 'This needs to be run on perle.'
	exit 1
}

fn rsh {
	/usr/ucb/rsh $*
}

old=$1
new=$2

edcmd='1,$s/'$old^/$new^/gp'
w
q
'
rcscomment=$old^' renamed to be '$new^.

~ $new ???????* &amp;&amp; echo $myname^': Warning: "'$new'"''s name is too long for a DECnet node name.' &gt;[2=1]

# fix stuff in /etc

for (i in /etc/^(hosts hosts.equiv offered))
	echo $edcmd | /udir/boyd/hacks/edit $i $rcscomment || exit 1

# fix /prl/machines and bereski's database

for (i in /prl/machines /prl/distribute/DataBase/Clients) {
	@{ cd $i &amp;&amp; mv $old $new} || exit 1
}

wsField -n $new -f IpSName -v $new

if (! ~ `{wsField -n $new -f IpSName} $new) {
	echo $myname^': wsField database problem with "'$new^'".'
	exit 1
}

# fix /proj/pmaxes

mkdir /tmp/$old^.$pid &amp;&amp; @{ cd /tmp/$old^.$pid &amp;&amp; getpackage /proj/pmaxes/$old }

mkdir /tmp/$new^.$pid &amp;&amp; @{ cd /tmp/$new^.$pid &amp;&amp; ppa i $new &amp;&amp; getpackage /proj/pmaxes/$new }

cp /tmp/$old^.$pid^/* /tmp/$new.$pid || exit 1

@{cd /tmp/$old^.$pid &amp;&amp; unlockpackage /proj/pmaxes/$old }

@{cd /tmp/$new^.$pid &amp;&amp; shippackage /proj/pmaxes/$new &amp;&amp; unlockpackage /proj/pmaxes/$new }

# cd /tmp &amp;&amp; rm -fr $old^.$pid $new^.$pid

echo $edcmd | rsh $new 'rm -f /etc/RCS/rc.local,v ; /udir/boyd/hacks/edit /etc/rc.local'

# fix the DNS

rsh mother /udir/boyd/hacks/rename-dns $old $new

# fix the diskless root file-system's etc

#rsh mother 'test -d /dl/C/4.2A/'$old^' &amp;&amp; cd /dl/C/4.2A &amp;&amp; mv '$old^' '$new

#rsh mother 'test -d /dl/C/4.2A/'$new^' &amp;&amp; addnode '$new^' -s /dl/C/4.2A/'$new^'/etc/netblk.mother.o -t /dl/C/4.2A/'$new^'/vmunix -D /dl/C/4.2A/'$new^'/var/adm/vmcore'

# .rhosts on the dump servers

for (i in kate bucket) {
	echo $edcmd | rsh $i /udir/boyd/hacks/edit /.rhosts
}

# fix mountd braindamage

for (i in perle mother nacre prlp24 bucket)
	rsh $i 'test -r /etc/exports &amp;&amp; touch /etc/exports'

echo Replicating net to $new^. &gt;[1=2]

replicate net $new

echo Replicating net to all. &gt;[1=2]

replicate net all
</tt>
</pre>
<HR>
&copy 1998,
Boyd Roberts:
<A HREF="mailto:boyd@fr.inter.net">boyd@fr.inter.net</A>
</body>
</html>

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to webmaster@9p.io.