#!/bin/sh #------------------------------------------------------------------------------ # /var/install/bin/shfs-removehost - remove hoste from shfs # # Copyright (c) 2004 Jens Vehlhaber # # Creation: 23.10.2004 jv # Last Update: $Id$ # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. #------------------------------------------------------------------------------ # include eislib # /var/install/include/eislib # Set defaults findHost="" host_name="" mntpoint="" ### --------------------------------------------------------------------------- ### make a copy from config file ### --------------------------------------------------------------------------- copy_config_file() { r_val1=$1 r_val2=$2 cat /etc/config.d/shfs | grep -v "$r_val1" | grep -v "$r_val2" > /tmp/shfs.tmp } ### --------------------------------------------------------------------------- ### remove host from config file ### --------------------------------------------------------------------------- remove_host_from_config_file() { idx=1 nfd=0 . /etc/config.d/shfs # get the idx number if [ $SHFS_MNT_N -gt 0 ] then while [ $idx -le $SHFS_MNT_N ] do eval r_host='$SHFS_MNT_'$idx'_REMOTE_HOST' if [ "$r_host" = "$host_name" ] then copy_config_file "^SHFS_MNT_N=" "^SHFS_MNT_${idx}" nfd=$idx eval mntpoint='$SHFS_MNT_'$idx'_LOCAL' eval r_port='$SHFS_MNT_'$idx'_REMOTE_PORT' # check if connect /usr/local/shfs/pscan "$host_name" -b $r_port -e $r_port -c 2 1>/dev/null if [ $? -gt 0 ] then shfsumount $mntpoint else colecho "Error with umount host" br x br fi fi # replace the old numbers if [ $nfd -gt 0 ] then nr_old=`expr $idx + 1` cat /tmp/shfs.tmp | sed "s/SHFS_MNT_${nr_old}/SHFS_MNT_${idx}/g" > /tmp/shfs1.tmp rm -f /tmp/shfs.tmp mv /tmp/shfs1.tmp /tmp/shfs.tmp fi idx=`expr $idx + 1` done idx=`expr $idx - 2` echo "SHFS_MNT_N='$idx'" >> /tmp/shfs.tmp fi # make new config file /var/install/config.d/shfs-update.sh /tmp/shfs.tmp # make new fstab /var/install/config.d/shfs.sh fstab # remove ssh - key cat /root/.ssh/known_hosts | grep -v "^$host_name" > /tmp/known_hosts.tmp rm -f /root/.ssh/known_hosts mv /tmp/known_hosts.tmp /root/.ssh/known_hosts } ### --------------------------------------------------------------------------- ### get hostname ### --------------------------------------------------------------------------- get_hostname() { clrhome colecho "Remove host from SSH filesystem" gn echo "" echo "" echo -n "Input Hostname or IP: " read host_name echo "" echo "" } ### --------------------------------------------------------------------------- ### check host ### --------------------------------------------------------------------------- check_host() { findHost=`grep "REMOTE_HOST='$host_name'" /etc/config.d/shfs` } ### --------------------------------------------------------------------------- ### main ### --------------------------------------------------------------------------- get_hostname while [ 1 ] do check_host if [ -z "$findHost" ] then colecho " Host not found" br x br echo echo echo echo echo echo " 1: Change Hostname" echo echo echo -e "Command (1-2, ENTER=Return) \c" read input_select case $input_select in 1) get_hostname ;; *) break;; esac else remove_host_from_config_file if [ -d $mntpoint ] then rmdir $mntpoint fi break fi done /var/install/bin/anykey