slitaz-vz rev 0

Add scripts fro OpenVZ, proxmox
author Eric Joseph-Alexandre <erjo@slitaz.org>
date Tue Nov 01 09:21:01 2011 +0100 (2011-11-01)
parents
children d7f371bbe726
files vz-scripts/openvz/slitaz-add_ip.sh vz-scripts/openvz/slitaz-del_ip.sh vz-scripts/openvz/slitaz-set_hostname.sh vz-scripts/proxmox-ovh/slitaz-add_ip.sh vz-scripts/proxmox-ovh/slitaz-del_ip.sh vz-scripts/proxmox-ovh/slitaz-set_dns.sh vz-scripts/proxmox-ovh/slitaz-set_hostname.sh vz-scripts/proxmox-ovh/slitaz.conf vz-scripts/proxmox/slitaz-add_ip.sh vz-scripts/proxmox/slitaz-del_ip.sh vz-scripts/proxmox/slitaz-set_dns.sh vz-scripts/proxmox/slitaz-set_hostname.sh vz-scripts/proxmox/slitaz.conf
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/vz-scripts/openvz/slitaz-add_ip.sh	Tue Nov 01 09:21:01 2011 +0100
     1.3 @@ -0,0 +1,46 @@
     1.4 +#!/bin/bash
     1.5 +# Adds IP address(es) in a container running Slitaz.
     1.6 +#
     1.7 +#  This program is free software; you can redistribute it and/or modify
     1.8 +#  it under the terms of the GNU General Public License as published by
     1.9 +#  the Free Software Foundation; either version 2 of the License, or
    1.10 +#  (at your option) any later version.
    1.11 +#
    1.12 +#  This program is distributed in the hope that it will be useful,
    1.13 +#  but WITHOUT ANY WARRANTY; without even the implied warranty of
    1.14 +#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    1.15 +#  GNU General Public License for more details.
    1.16 +#
    1.17 +#  You should have received a copy of the GNU General Public License
    1.18 +#  along with this program; if not, write to the Free Software
    1.19 +#  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    1.20 +#
    1.21 +#  Copyright (C) 2011 Eric Joseph-Alexandre <erjo@slitaz.org>
    1.22 +#
    1.23 +
    1.24 +VENET_DEV=venet0
    1.25 +CFGFILE=/etc/network.conf
    1.26 +
    1.27 +function add_ip()
    1.28 +{
    1.29 +	if ! grep -q venet0 ${CFGFILE}; then
    1.30 +		sed -i "s/^INTERFACE.*/INTERFACE=\"${VENET_DEV}\"/" ${CFGFILE}
    1.31 +	fi
    1.32 +	
    1.33 +	if [ ! -z ${IP_ADDR} ]; then
    1.34 +		sed -i 's/DHCP=.*/DHCP="no"/' ${CFGFILE}
    1.35 +		sed -i 's/STATIC=.*/STATIC="yes"/' ${CFGFILE}
    1.36 +		sed -i -e "s/IP=".*"/IP=\"${IP_ADDR}\"/" ${CFGFILE}
    1.37 +		sed -i -e "s/NETMASK=".*"/NETMASK=\"255.255.255.255\"/" ${CFGFILE}
    1.38 +	fi
    1.39 +	
    1.40 +	# Starting the network
    1.41 +	/etc/init.d/network.sh
    1.42 +	
    1.43 +	# Add default route
    1.44 +	/sbin/route add default ${VENET_DEV}
    1.45 +}
    1.46 +
    1.47 +add_ip
    1.48 +
    1.49 +exit 0
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/vz-scripts/openvz/slitaz-del_ip.sh	Tue Nov 01 09:21:01 2011 +0100
     2.3 @@ -0,0 +1,39 @@
     2.4 +#!/bin/bash
     2.5 +# Deletes IP address from a container running SliTaz distro.
     2.6 +#
     2.7 +#  This program is free software; you can redistribute it and/or modify
     2.8 +#  it under the terms of the GNU General Public License as published by
     2.9 +#  the Free Software Foundation; either version 2 of the License, or
    2.10 +#  (at your option) any later version.
    2.11 +#
    2.12 +#  This program is distributed in the hope that it will be useful,
    2.13 +#  but WITHOUT ANY WARRANTY; without even the implied warranty of
    2.14 +#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    2.15 +#  GNU General Public License for more details.
    2.16 +#
    2.17 +#  You should have received a copy of the GNU General Public License
    2.18 +#  along with this program; if not, write to the Free Software
    2.19 +#  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    2.20 +#
    2.21 +#  Copyright (C) 2011 Eric Joseph-Alexandre <erjo@slitaz.org>
    2.22 +
    2.23 +
    2.24 +VENET_DEV=venet0
    2.25 +CFGFILE=/etc/network.conf
    2.26 +
    2.27 +# Function to delete IP address
    2.28 +function del_ip()
    2.29 +{
    2.30 +	if grep -q ${IP_ADDR} ${CFGFILE}; then
    2.31 +		sed -i 's/^IP.*/IP=\"0\"/' ${CFGFILE}
    2.32 +	fi
    2.33 +	
    2.34 +	# Shutting down $VENET_DEV if CT is running.
    2.35 +	if [ "$VE_STATE" = "running" ]; then
    2.36 +		/sbin/ifconfig ${VENET_DEV} down
    2.37 +	fi
    2.38 +}
    2.39 +
    2.40 +del_ip
    2.41 +
    2.42 +exit 0
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/vz-scripts/openvz/slitaz-set_hostname.sh	Tue Nov 01 09:21:01 2011 +0100
     3.3 @@ -0,0 +1,39 @@
     3.4 +#!/bin/bash
     3.5 +#  Copyright (C) 2000-2009, Parallels, Inc. All rights reserved.
     3.6 +#  Copyright (C) 2011 Eric Joseph-Alexandre <erjo@slitaz.org>
     3.7 +#
     3.8 +#  This program is free software; you can redistribute it and/or modify
     3.9 +#  it under the terms of the GNU General Public License as published by
    3.10 +#  the Free Software Foundation; either version 2 of the License, or
    3.11 +#  (at your option) any later version.
    3.12 +#
    3.13 +#  This program is distributed in the hope that it will be useful,
    3.14 +#  but WITHOUT ANY WARRANTY; without even the implied warranty of
    3.15 +#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    3.16 +#  GNU General Public License for more details.
    3.17 +#
    3.18 +#  You should have received a copy of the GNU General Public License
    3.19 +#  along with this program; if not, write to the Free Software
    3.20 +#  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    3.21 +#
    3.22 +#
    3.23 +# Sets up hostname in a container running slitaz-like distro.
    3.24 +
    3.25 +function set_hostname()
    3.26 +{
    3.27 +	local cfgfile="$1"
    3.28 +	local hostname=$2
    3.29 +
    3.30 +	[ -z "${hostname}" ] && return 0
    3.31 +
    3.32 +	hostname=${hostname%%.*}
    3.33 +
    3.34 +	echo "${hostname}" > ${cfgfile}
    3.35 +
    3.36 +	hostname ${hostname}
    3.37 +}
    3.38 +
    3.39 +change_hostname /etc/hosts "${HOSTNM}" "${IP_ADDR}"
    3.40 +set_hostname /etc/hostname "${HOSTNM}"
    3.41 +
    3.42 +exit 0
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/vz-scripts/proxmox-ovh/slitaz-add_ip.sh	Tue Nov 01 09:21:01 2011 +0100
     4.3 @@ -0,0 +1,80 @@
     4.4 +#!/bin/bash
     4.5 +# Adds IP address(es) in a container running Slitaz.
     4.6 +#
     4.7 +#  This program is free software; you can redistribute it and/or modify
     4.8 +#  it under the terms of the GNU General Public License as published by
     4.9 +#  the Free Software Foundation; either version 2 of the License, or
    4.10 +#  (at your option) any later version.
    4.11 +#
    4.12 +#  This program is distributed in the hope that it will be useful,
    4.13 +#  but WITHOUT ANY WARRANTY; without even the implied warranty of
    4.14 +#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    4.15 +#  GNU General Public License for more details.
    4.16 +#
    4.17 +#  You should have received a copy of the GNU General Public License
    4.18 +#  along with this program; if not, write to the Free Software
    4.19 +#  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    4.20 +#
    4.21 +#  Copyright (C) 2011 Eric Joseph-Alexandre <erjo@slitaz.org>
    4.22 +#
    4.23 +
    4.24 +VENET_DEV=venet0
    4.25 +CFGFILE=/etc/network.conf
    4.26 +HOSTFILE=/etc/hosts
    4.27 +CFG_DIR=/etc/network
    4.28 +CFG_DEV_FILE=${CFG_DIR}/ifconfig-${VENET_DEV}
    4.29 +
    4.30 +function setup_network()
    4.31 +{
    4.32 +	# Set up /etc/hosts
    4.33 +	if [ ! -f ${HOSTFILE} ]; then
    4.34 +		echo "127.0.0.1 localhost.localdomain localhost" > $HOSTFILE
    4.35 +		echo "${IP_ADDR} localhost.localdomain localhost" >> $HOSTFILE
    4.36 +	fi
    4.37 +	
    4.38 +	# Make config directory
    4.39 +	[ -d $CFG_DIR ] || mkdir -p $CFG_DIR
    4.40 +
    4.41 +	# Set default venet0 for rc.network	
    4.42 +	echo "ONBOOT=yes"  > ${CFG_DEV_FILE}:0
    4.43 +	echo "MODE=static"  >> ${CFG_DEV_FILE}:0
    4.44 +	echo "IP=127.0.0.1"  >> ${CFG_DEV_FILE}:0
    4.45 +	echo "NETMASK=255.255.255.255" >> ${CFG_DEV_FILE}:0
    4.46 +	echo "BROADCAST=0.0.0.0" >> ${CFG_DEV_FILE}:0
    4.47 +}
    4.48 +
    4.49 +function add_ip()
    4.50 +{
    4.51 +	# In case we are starting CT
    4.52 +	if [ "x${VE_STATE}" = "xstarting" ]; then
    4.53 +		setup_network
    4.54 +	fi
    4.55 +	if ! grep -q venet0 ${CFGFILE}; then
    4.56 +		sed -i "s/^INTERFACE.*/INTERFACE=\"${VENET_DEV}\"/" ${CFGFILE}
    4.57 +	fi
    4.58 +	
    4.59 +	# Set default venet0 config
    4.60 +	sed -i 's/DHCP=.*/DHCP="no"/' ${CFGFILE}
    4.61 +	sed -i 's/STATIC=.*/STATIC="yes"/' ${CFGFILE}
    4.62 +	sed -i -e "s/IP=".*"/IP=\"127.0.0.1\"/" ${CFGFILE}
    4.63 +	sed -i -e "s/NETMASK=".*"/NETMASK=\"255.255.255.255\"/" ${CFGFILE}
    4.64 +	
    4.65 +	# Set config IP for venet0 alias.
    4.66 +	if [ ! -z ${IP_ADDR} ]; then
    4.67 +		echo "ONBOOT=yes"  > ${CFG_DEV_FILE}:0
    4.68 +		echo "MODE=static"  >> ${CFG_DEV_FILE}:0
    4.69 +		echo "IP=${IP_ADDR}"  >> ${CFG_DEV_FILE}:0
    4.70 +		echo "NETMASK=255.255.255.255" >> ${CFG_DEV_FILE}:0
    4.71 +		echo "BROADCAST=${IP_ADDR}" >> ${CFG_DEV_FILE}:0
    4.72 +	fi
    4.73 +	
    4.74 +	# Starting the network
    4.75 +	/etc/init.d/rc.network
    4.76 +	
    4.77 +	# Add default route
    4.78 +	/sbin/route add default ${VENET_DEV}
    4.79 +}
    4.80 +
    4.81 +add_ip
    4.82 +
    4.83 +exit 0
     5.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.2 +++ b/vz-scripts/proxmox-ovh/slitaz-del_ip.sh	Tue Nov 01 09:21:01 2011 +0100
     5.3 @@ -0,0 +1,39 @@
     5.4 +#!/bin/bash
     5.5 +# Deletes IP address from a container running SliTaz distro.
     5.6 +#
     5.7 +#  This program is free software; you can redistribute it and/or modify
     5.8 +#  it under the terms of the GNU General Public License as published by
     5.9 +#  the Free Software Foundation; either version 2 of the License, or
    5.10 +#  (at your option) any later version.
    5.11 +#
    5.12 +#  This program is distributed in the hope that it will be useful,
    5.13 +#  but WITHOUT ANY WARRANTY; without even the implied warranty of
    5.14 +#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    5.15 +#  GNU General Public License for more details.
    5.16 +#
    5.17 +#  You should have received a copy of the GNU General Public License
    5.18 +#  along with this program; if not, write to the Free Software
    5.19 +#  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    5.20 +#
    5.21 +#  Copyright (C) 2011 Eric Joseph-Alexandre <erjo@slitaz.org>
    5.22 +
    5.23 +
    5.24 +VENET_DEV=venet0
    5.25 +CFGFILE=/etc/network.conf
    5.26 +
    5.27 +# Function to delete IP address
    5.28 +function del_ip()
    5.29 +{
    5.30 +	if grep -q ${IP_ADDR} ${CFGFILE}; then
    5.31 +		sed -i 's/^IP.*/IP=\"0\"/' ${CFGFILE}
    5.32 +	fi
    5.33 +	
    5.34 +	# Shutting down $VENET_DEV if CT is running.
    5.35 +	if [ "$VE_STATE" = "running" ]; then
    5.36 +		/sbin/ifconfig ${VENET_DEV} down
    5.37 +	fi
    5.38 +}
    5.39 +
    5.40 +del_ip
    5.41 +
    5.42 +exit 0
     6.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.2 +++ b/vz-scripts/proxmox-ovh/slitaz-set_dns.sh	Tue Nov 01 09:21:01 2011 +0100
     6.3 @@ -0,0 +1,48 @@
     6.4 +#!/bin/sh 
     6.5 +#  Copyright (C) 2000-2011, Parallels, Inc. All rights reserved.
     6.6 +#
     6.7 +#  This program is free software; you can redistribute it and/or modify
     6.8 +#  it under the terms of the GNU General Public License as published by
     6.9 +#  the Free Software Foundation; either version 2 of the License, or
    6.10 +#  (at your option) any later version.
    6.11 +#
    6.12 +#  This program is distributed in the hope that it will be useful,
    6.13 +#  but WITHOUT ANY WARRANTY; without even the implied warranty of
    6.14 +#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    6.15 +#  GNU General Public License for more details.
    6.16 +#
    6.17 +#  You should have received a copy of the GNU General Public License
    6.18 +#  along with this program; if not, write to the Free Software
    6.19 +#  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    6.20 +#
    6.21 +#
    6.22 +# Sets up resolver (/etc/resolv.conf) in a container.
    6.23 +
    6.24 +set_dns()
    6.25 +{
    6.26 +	local cfgfile="$1"
    6.27 +	local server="$2"
    6.28 +	local search="$3"
    6.29 +	local srv
    6.30 +	
    6.31 +	[ -f $cfgfile ] || touch $cfgfile
    6.32 +
    6.33 +	if [ -n "${search}" ]; then
    6.34 +		put_param2 "${cfgfile}" search "${search}"
    6.35 +	fi
    6.36 +	if [ -n "${server}" ]; then
    6.37 +		[ -f ${cfgfile} ] || touch ${cfgfile}
    6.38 +		grep -v '^\s*nameserver\s' ${cfgfile} > ${cfgfile}.$$ &&
    6.39 +			mv -f ${cfgfile}.$$ ${cfgfile} ||
    6.40 +			error "Can't change file ${cfgfile}" ${VZ_FS_NO_DISK_SPACE}
    6.41 +		for srv in ${server}; do
    6.42 +			echo "nameserver ${srv}" >> ${cfgfile}
    6.43 +		done
    6.44 +	fi
    6.45 +	chmod 644 ${cfgfile}
    6.46 +}
    6.47 +
    6.48 +
    6.49 +set_dns /etc/resolv.conf "${NAMESERVER}" "${SEARCHDOMAIN}"
    6.50 +
    6.51 +exit 0
     7.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     7.2 +++ b/vz-scripts/proxmox-ovh/slitaz-set_hostname.sh	Tue Nov 01 09:21:01 2011 +0100
     7.3 @@ -0,0 +1,39 @@
     7.4 +#!/bin/bash
     7.5 +#  Copyright (C) 2000-2009, Parallels, Inc. All rights reserved.
     7.6 +#  Copyright (C) 2011 Eric Joseph-Alexandre <erjo@slitaz.org>
     7.7 +#
     7.8 +#  This program is free software; you can redistribute it and/or modify
     7.9 +#  it under the terms of the GNU General Public License as published by
    7.10 +#  the Free Software Foundation; either version 2 of the License, or
    7.11 +#  (at your option) any later version.
    7.12 +#
    7.13 +#  This program is distributed in the hope that it will be useful,
    7.14 +#  but WITHOUT ANY WARRANTY; without even the implied warranty of
    7.15 +#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    7.16 +#  GNU General Public License for more details.
    7.17 +#
    7.18 +#  You should have received a copy of the GNU General Public License
    7.19 +#  along with this program; if not, write to the Free Software
    7.20 +#  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    7.21 +#
    7.22 +#
    7.23 +# Sets up hostname in a container running slitaz-like distro.
    7.24 +
    7.25 +function set_hostname()
    7.26 +{
    7.27 +	local cfgfile="$1"
    7.28 +	local hostname=$2
    7.29 +
    7.30 +	[ -z "${hostname}" ] && return 0
    7.31 +
    7.32 +	hostname=${hostname%%.*}
    7.33 +
    7.34 +	echo "${hostname}" > ${cfgfile}
    7.35 +
    7.36 +	hostname ${hostname}
    7.37 +}
    7.38 +
    7.39 +change_hostname /etc/hosts "${HOSTNM}" "${IP_ADDR}"
    7.40 +set_hostname /etc/hostname "${HOSTNM}"
    7.41 +
    7.42 +exit 0
     8.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     8.2 +++ b/vz-scripts/proxmox-ovh/slitaz.conf	Tue Nov 01 09:21:01 2011 +0100
     8.3 @@ -0,0 +1,27 @@
     8.4 +#  Copyright (C) 2000-2008, Parallels, Inc. All rights reserved.
     8.5 +#
     8.6 +#  This program is free software; you can redistribute it and/or modify
     8.7 +#  it under the terms of the GNU General Public License as published by
     8.8 +#  the Free Software Foundation; either version 2 of the License, or
     8.9 +#  (at your option) any later version.
    8.10 +#
    8.11 +#  This program is distributed in the hope that it will be useful,
    8.12 +#  but WITHOUT ANY WARRANTY; without even the implied warranty of
    8.13 +#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    8.14 +#  GNU General Public License for more details.
    8.15 +#
    8.16 +#  You should have received a copy of the GNU General Public License
    8.17 +#  along with this program; if not, write to the Free Software
    8.18 +#  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    8.19 +#
    8.20 +# This configuration file is meant to be used with
    8.21 +# the Redhat, RHEL, CentOS distribution kit.
    8.22 +#
    8.23 +
    8.24 +ADD_IP=slitaz-add_ip.sh
    8.25 +DEL_IP=slitaz-del_ip.sh
    8.26 +SET_HOSTNAME=slitaz-set_hostname.sh
    8.27 +SET_DNS=set_dns.sh
    8.28 +SET_USERPASS=set_userpass.sh
    8.29 +#SET_UGID_QUOTA=set_ugid_quota.sh
    8.30 +POST_CREATE=postcreate.sh
     9.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     9.2 +++ b/vz-scripts/proxmox/slitaz-add_ip.sh	Tue Nov 01 09:21:01 2011 +0100
     9.3 @@ -0,0 +1,80 @@
     9.4 +#!/bin/bash
     9.5 +# Adds IP address(es) in a container running Slitaz.
     9.6 +#
     9.7 +#  This program is free software; you can redistribute it and/or modify
     9.8 +#  it under the terms of the GNU General Public License as published by
     9.9 +#  the Free Software Foundation; either version 2 of the License, or
    9.10 +#  (at your option) any later version.
    9.11 +#
    9.12 +#  This program is distributed in the hope that it will be useful,
    9.13 +#  but WITHOUT ANY WARRANTY; without even the implied warranty of
    9.14 +#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    9.15 +#  GNU General Public License for more details.
    9.16 +#
    9.17 +#  You should have received a copy of the GNU General Public License
    9.18 +#  along with this program; if not, write to the Free Software
    9.19 +#  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    9.20 +#
    9.21 +#  Copyright (C) 2011 Eric Joseph-Alexandre <erjo@slitaz.org>
    9.22 +#
    9.23 +
    9.24 +VENET_DEV=venet0
    9.25 +CFGFILE=/etc/network.conf
    9.26 +HOSTFILE=/etc/hosts
    9.27 +CFG_DIR=/etc/network
    9.28 +CFG_DEV_FILE=${CFG_DIR}/ifconfig-${VENET_DEV}
    9.29 +
    9.30 +function setup_network()
    9.31 +{
    9.32 +	# Set up /etc/hosts
    9.33 +	if [ ! -f ${HOSTFILE} ]; then
    9.34 +		echo "127.0.0.1 localhost.localdomain localhost" > $HOSTFILE
    9.35 +		echo "${IP_ADDR} localhost.localdomain localhost" >> $HOSTFILE
    9.36 +	fi
    9.37 +	
    9.38 +	# Make config directory
    9.39 +	[ -d $CFG_DIR ] || mkdir -p $CFG_DIR
    9.40 +
    9.41 +	# Set default venet0 for rc.network	
    9.42 +	echo "ONBOOT=yes"  > ${CFG_DEV_FILE}:0
    9.43 +	echo "MODE=static"  >> ${CFG_DEV_FILE}:0
    9.44 +	echo "IP=127.0.0.1"  >> ${CFG_DEV_FILE}:0
    9.45 +	echo "NETMASK=255.255.255.255" >> ${CFG_DEV_FILE}:0
    9.46 +	echo "BROADCAST=0.0.0.0" >> ${CFG_DEV_FILE}:0
    9.47 +}
    9.48 +
    9.49 +function add_ip()
    9.50 +{
    9.51 +	# In case we are starting CT
    9.52 +	if [ "x${VE_STATE}" = "xstarting" ]; then
    9.53 +		setup_network
    9.54 +	fi
    9.55 +	if ! grep -q venet0 ${CFGFILE}; then
    9.56 +		sed -i "s/^INTERFACE.*/INTERFACE=\"${VENET_DEV}\"/" ${CFGFILE}
    9.57 +	fi
    9.58 +	
    9.59 +	# Set default venet0 config
    9.60 +	sed -i 's/DHCP=.*/DHCP="no"/' ${CFGFILE}
    9.61 +	sed -i 's/STATIC=.*/STATIC="yes"/' ${CFGFILE}
    9.62 +	sed -i -e "s/IP=".*"/IP=\"127.0.0.1\"/" ${CFGFILE}
    9.63 +	sed -i -e "s/NETMASK=".*"/NETMASK=\"255.255.255.255\"/" ${CFGFILE}
    9.64 +	
    9.65 +	# Set config IP for venet0 alias.
    9.66 +	if [ ! -z ${IP_ADDR} ]; then
    9.67 +		echo "ONBOOT=yes"  > ${CFG_DEV_FILE}:0
    9.68 +		echo "MODE=static"  >> ${CFG_DEV_FILE}:0
    9.69 +		echo "IP=${IP_ADDR}"  >> ${CFG_DEV_FILE}:0
    9.70 +		echo "NETMASK=255.255.255.255" >> ${CFG_DEV_FILE}:0
    9.71 +		echo "BROADCAST=${IP_ADDR}" >> ${CFG_DEV_FILE}:0
    9.72 +	fi
    9.73 +	
    9.74 +	# Starting the network
    9.75 +	/etc/init.d/rc.network
    9.76 +	
    9.77 +	# Add default route
    9.78 +	/sbin/route add default ${VENET_DEV}
    9.79 +}
    9.80 +
    9.81 +add_ip
    9.82 +
    9.83 +exit 0
    10.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    10.2 +++ b/vz-scripts/proxmox/slitaz-del_ip.sh	Tue Nov 01 09:21:01 2011 +0100
    10.3 @@ -0,0 +1,39 @@
    10.4 +#!/bin/bash
    10.5 +# Deletes IP address from a container running SliTaz distro.
    10.6 +#
    10.7 +#  This program is free software; you can redistribute it and/or modify
    10.8 +#  it under the terms of the GNU General Public License as published by
    10.9 +#  the Free Software Foundation; either version 2 of the License, or
   10.10 +#  (at your option) any later version.
   10.11 +#
   10.12 +#  This program is distributed in the hope that it will be useful,
   10.13 +#  but WITHOUT ANY WARRANTY; without even the implied warranty of
   10.14 +#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   10.15 +#  GNU General Public License for more details.
   10.16 +#
   10.17 +#  You should have received a copy of the GNU General Public License
   10.18 +#  along with this program; if not, write to the Free Software
   10.19 +#  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   10.20 +#
   10.21 +#  Copyright (C) 2011 Eric Joseph-Alexandre <erjo@slitaz.org>
   10.22 +
   10.23 +
   10.24 +VENET_DEV=venet0
   10.25 +CFGFILE=/etc/network.conf
   10.26 +
   10.27 +# Function to delete IP address
   10.28 +function del_ip()
   10.29 +{
   10.30 +	if grep -q ${IP_ADDR} ${CFGFILE}; then
   10.31 +		sed -i 's/^IP.*/IP=\"0\"/' ${CFGFILE}
   10.32 +	fi
   10.33 +	
   10.34 +	# Shutting down $VENET_DEV if CT is running.
   10.35 +	if [ "$VE_STATE" = "running" ]; then
   10.36 +		/sbin/ifconfig ${VENET_DEV} down
   10.37 +	fi
   10.38 +}
   10.39 +
   10.40 +del_ip
   10.41 +
   10.42 +exit 0
    11.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    11.2 +++ b/vz-scripts/proxmox/slitaz-set_dns.sh	Tue Nov 01 09:21:01 2011 +0100
    11.3 @@ -0,0 +1,48 @@
    11.4 +#!/bin/sh 
    11.5 +#  Copyright (C) 2000-2011, Parallels, Inc. All rights reserved.
    11.6 +#
    11.7 +#  This program is free software; you can redistribute it and/or modify
    11.8 +#  it under the terms of the GNU General Public License as published by
    11.9 +#  the Free Software Foundation; either version 2 of the License, or
   11.10 +#  (at your option) any later version.
   11.11 +#
   11.12 +#  This program is distributed in the hope that it will be useful,
   11.13 +#  but WITHOUT ANY WARRANTY; without even the implied warranty of
   11.14 +#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   11.15 +#  GNU General Public License for more details.
   11.16 +#
   11.17 +#  You should have received a copy of the GNU General Public License
   11.18 +#  along with this program; if not, write to the Free Software
   11.19 +#  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   11.20 +#
   11.21 +#
   11.22 +# Sets up resolver (/etc/resolv.conf) in a container.
   11.23 +
   11.24 +set_dns()
   11.25 +{
   11.26 +	local cfgfile="$1"
   11.27 +	local server="$2"
   11.28 +	local search="$3"
   11.29 +	local srv
   11.30 +	
   11.31 +	[ -f $cfgfile ] || touch $cfgfile
   11.32 +
   11.33 +	if [ -n "${search}" ]; then
   11.34 +		put_param2 "${cfgfile}" search "${search}"
   11.35 +	fi
   11.36 +	if [ -n "${server}" ]; then
   11.37 +		[ -f ${cfgfile} ] || touch ${cfgfile}
   11.38 +		grep -v '^\s*nameserver\s' ${cfgfile} > ${cfgfile}.$$ &&
   11.39 +			mv -f ${cfgfile}.$$ ${cfgfile} ||
   11.40 +			error "Can't change file ${cfgfile}" ${VZ_FS_NO_DISK_SPACE}
   11.41 +		for srv in ${server}; do
   11.42 +			echo "nameserver ${srv}" >> ${cfgfile}
   11.43 +		done
   11.44 +	fi
   11.45 +	chmod 644 ${cfgfile}
   11.46 +}
   11.47 +
   11.48 +
   11.49 +set_dns /etc/resolv.conf "${NAMESERVER}" "${SEARCHDOMAIN}"
   11.50 +
   11.51 +exit 0
    12.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    12.2 +++ b/vz-scripts/proxmox/slitaz-set_hostname.sh	Tue Nov 01 09:21:01 2011 +0100
    12.3 @@ -0,0 +1,39 @@
    12.4 +#!/bin/bash
    12.5 +#  Copyright (C) 2000-2009, Parallels, Inc. All rights reserved.
    12.6 +#  Copyright (C) 2011 Eric Joseph-Alexandre <erjo@slitaz.org>
    12.7 +#
    12.8 +#  This program is free software; you can redistribute it and/or modify
    12.9 +#  it under the terms of the GNU General Public License as published by
   12.10 +#  the Free Software Foundation; either version 2 of the License, or
   12.11 +#  (at your option) any later version.
   12.12 +#
   12.13 +#  This program is distributed in the hope that it will be useful,
   12.14 +#  but WITHOUT ANY WARRANTY; without even the implied warranty of
   12.15 +#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   12.16 +#  GNU General Public License for more details.
   12.17 +#
   12.18 +#  You should have received a copy of the GNU General Public License
   12.19 +#  along with this program; if not, write to the Free Software
   12.20 +#  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   12.21 +#
   12.22 +#
   12.23 +# Sets up hostname in a container running slitaz-like distro.
   12.24 +
   12.25 +function set_hostname()
   12.26 +{
   12.27 +	local cfgfile="$1"
   12.28 +	local hostname=$2
   12.29 +
   12.30 +	[ -z "${hostname}" ] && return 0
   12.31 +
   12.32 +	hostname=${hostname%%.*}
   12.33 +
   12.34 +	echo "${hostname}" > ${cfgfile}
   12.35 +
   12.36 +	hostname ${hostname}
   12.37 +}
   12.38 +
   12.39 +change_hostname /etc/hosts "${HOSTNM}" "${IP_ADDR}"
   12.40 +set_hostname /etc/hostname "${HOSTNM}"
   12.41 +
   12.42 +exit 0
    13.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    13.2 +++ b/vz-scripts/proxmox/slitaz.conf	Tue Nov 01 09:21:01 2011 +0100
    13.3 @@ -0,0 +1,27 @@
    13.4 +#  Copyright (C) 2000-2008, Parallels, Inc. All rights reserved.
    13.5 +#
    13.6 +#  This program is free software; you can redistribute it and/or modify
    13.7 +#  it under the terms of the GNU General Public License as published by
    13.8 +#  the Free Software Foundation; either version 2 of the License, or
    13.9 +#  (at your option) any later version.
   13.10 +#
   13.11 +#  This program is distributed in the hope that it will be useful,
   13.12 +#  but WITHOUT ANY WARRANTY; without even the implied warranty of
   13.13 +#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   13.14 +#  GNU General Public License for more details.
   13.15 +#
   13.16 +#  You should have received a copy of the GNU General Public License
   13.17 +#  along with this program; if not, write to the Free Software
   13.18 +#  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   13.19 +#
   13.20 +# This configuration file is meant to be used with
   13.21 +# the Redhat, RHEL, CentOS distribution kit.
   13.22 +#
   13.23 +
   13.24 +ADD_IP=slitaz-add_ip.sh
   13.25 +DEL_IP=slitaz-del_ip.sh
   13.26 +SET_HOSTNAME=slitaz-set_hostname.sh
   13.27 +SET_DNS=set_dns.sh
   13.28 +SET_USERPASS=set_userpass.sh
   13.29 +#SET_UGID_QUOTA=set_ugid_quota.sh
   13.30 +POST_CREATE=postcreate.sh