1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81
|
#!/bin/bash
#
# ConVirt - Copyright (c) 2008 Convirture Corp.
# ======
#
# ConVirt is a Virtualization management tool with a graphical user
# interface that allows for performing the standard set of VM operations
# (start, stop, pause, kill, shutdown, reboot, snapshot, etc...). It
# also attempts to simplify various aspects of VM lifecycle management.
#
#
# This software is subject to the GNU General Public License, Version 2 (GPLv2)
# and for details, please consult it at:
#
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt
#
#
# author : Jd <jd_jedi@users.sourceforge.net>
#
# Distribution and version specific code can go here.
# Assume that common functions are included
# Assme the DIST and the VER to be set here.
# open firewall port and make the change persistent.
# For SUSE/SLES : The /etc/sysconfig/SuSEfirewall2 files has a
# variable that needs to be changed.
# OpenSuse 11 : Seems to have a .d directory where each service fragment can be
# specified.
open_ports()
{
ports="$*"
ret=0
firewall_file="/etc/sysconfig/SuSEfirewall2"
service_name="SuSEfirewall2_setup"
if [ ! -w $firewall_file ]; then
echo "$firewall_file is not writable."
return 1
fi
open_ports=`grep ^FW_SERVICES_EXT_TCP= $firewall_file| sed s/^FW_SERVICES_EXT_TCP=//`
# donot add our ports twice
for p in $open_ports
do
p=`echo $p | sed 's/"//g'` # remove quote
p=`echo $p | sed 's/,//g'` # remove comma
exists_in_list $p $ports
if [ $? == 0 ]; then
continue
fi
new_ports="$new_ports $p"
done
new_ports="$new_ports $ports"
new_ports=`echo $new_ports | sed "s/^ //"` # remove leading space
sed -i -e "s/^FW_SERVICES_EXT_TCP=.*/FW_SERVICES_EXT_TCP=\"${new_ports}\"/" $firewall_file
save_output=`service $service_name reload`
if [ "$?" != "0" ]; then
echo "Error saving firwall rules. ($save_output)"
ret=1
else
echo "$save_output"
echo "Firewall rules saved successfully."
fi
return $ret
}
# update the network service
setup_nw_svc()
{
chkconfig --add convirt-nw
chkconfig convirt-nw on
return 0
}
|