#!/bin/csh

### Upgrade openssh package on a structbio IRIX system     ###
### Brandon D. Valentine <bandix@structbio.vanderbilt.edu> ###

# IMPORTANT: to use this script untar the .tardist file into a directory
# and set openssh_pkg to the location you untarred it in

set openssh_pkg = /sb/irix/sb_pkg/sb_openssh
set passwd = /etc/passwd
set tmppass = /tmp/tmppass
set grp = /etc/group
set tmpgrp = /tmp/tmpgrp

# Stop the old sshd process
if (-x /etc/init.d/sshd) /etc/init.d/sshd stop

# Remove old host keys
if (-x /etc/ssh/ssh_host_key) rm /etc/ssh/ssh_host_*

# Install package
inst -a -f $openssh_pkg

# Add privsep user
grep -v '^+' $passwd > $tmppass
echo "sshd:*:9999:9999:sshd privsep:/var/empty:/bin/false" >> $tmppass
grep '^+' $passwd >> $tmppass
cp $tmppass $passwd
rm $tmppass

# Add privsep group
grep -v '^+' $grp > $tmpgrp
echo "sshd:*:9999:sshd" >> $tmpgrp
grep '^+' $grp >> $tmpgrp
cp $tmpgrp $grp
rm $tmpgrp

# Restart sshd
/etc/init.d/sshd start

echo "OpenSSH Upgraded."
