#!/bin/sh
# Maintainer : gogisnim (gogisnim@gmail.com)
# Last Modify : 2007.09.06
# Usage : vps_make.sh
# Note :
# This is tool OpenVZ create guest system on interactive.
# Check vzctl!. http://openvz.org
# This script must be installed dialog utility and root authority.
TEMPLATE="gentoo-2.6.18"
TMPFILE="/tmp/tmp.$$"
PRIVATE="/vz/private/"
FLAG=0
! which dialog > /dev/null 2>&1 && echo "ERROR: The dialog utility is required for vps_make.sh. Exiting!" && exit 1
if [ "$USER" != "root" ]; then
echo "ERROR: You must be root authority"
exit 1
fi
umask 177
trap 'rm -f $TMPFILE; exit 1' EXIT INT
number_check() {
if [ -z "$1" ]; then
echo "usage: number_check num"
exit 1
fi
echo $1 | grep ^[[:digit:]]*$ > /dev/null 2>&1
return $?
}
for no in `ls $PRIVATE`; do
test "${num:-0}" -lt "$no" && num=$no
done
new_num=`expr $num + 1`
# VEID input and check
until false; do
dialog --title "VEID" --inputbox "Please enter new VEID : " 20 60 $new_num 2> $TMPFILE
VEID=`cat $TMPFILE`
test -z "$VEID" && FLAG=1 && continue
for no in `ls $PRIVATE`; do
FLAG=0
test "$VEID" -eq "$no" && FLAG=1 && break
done
number_check $VEID || FLAG=1
test "$FLAG" = "0" && break
done
# hostname input
dialog --title "hostname" --inputbox "Please enter new hostname : " 20 60 "vps$VEID" 2> $TMPFILE
HOSTNAME=`cat $TMPFILE`
# IP address input
dialog --title "IP Address" --inputbox "Please enter IP : " 20 60 "192.168.0.1" 2> $TMPFILE
IP=`cat $TMPFILE`
# nameserver input
dialog --title "nameserver" --inputbox "Please enter nameserver : " 20 60 "168.126.63.1" 2> $TMPFILE
NAMESERVER=`cat $TMPFILE`
# onboot yes/no
dialog --title "onbook option" --menu "VEID $VEID active on boot time" 20 60 2 yes "Yes, I'll be active vps on boot" no "No, unactive" 2> $TMPFILE
ONBOOT=`cat $TMPFILE`
dialog --title "Information" --msgbox "System is ready to make VPS $VEID...\n\nVEID : $VEID\nHostname : $HOSTNAME\nIP Address : $IP\nNameserver : $NAMESERVER\nOn Boot : $ONBOOT" 20 60
vzctl create $VEID --ostemplate $TEMPLATE &&
vzctl set $VEID --save --onboot=$ONBOOT --ipadd $IP --nameserver $NAMESERVER --hostname $HOSTNAME
exit 0
# Maintainer : gogisnim (gogisnim@gmail.com)
# Last Modify : 2007.09.06
# Usage : vps_make.sh
# Note :
# This is tool OpenVZ create guest system on interactive.
# Check vzctl!. http://openvz.org
# This script must be installed dialog utility and root authority.
TEMPLATE="gentoo-2.6.18"
TMPFILE="/tmp/tmp.$$"
PRIVATE="/vz/private/"
FLAG=0
! which dialog > /dev/null 2>&1 && echo "ERROR: The dialog utility is required for vps_make.sh. Exiting!" && exit 1
if [ "$USER" != "root" ]; then
echo "ERROR: You must be root authority"
exit 1
fi
umask 177
trap 'rm -f $TMPFILE; exit 1' EXIT INT
number_check() {
if [ -z "$1" ]; then
echo "usage: number_check num"
exit 1
fi
echo $1 | grep ^[[:digit:]]*$ > /dev/null 2>&1
return $?
}
for no in `ls $PRIVATE`; do
test "${num:-0}" -lt "$no" && num=$no
done
new_num=`expr $num + 1`
# VEID input and check
until false; do
dialog --title "VEID" --inputbox "Please enter new VEID : " 20 60 $new_num 2> $TMPFILE
VEID=`cat $TMPFILE`
test -z "$VEID" && FLAG=1 && continue
for no in `ls $PRIVATE`; do
FLAG=0
test "$VEID" -eq "$no" && FLAG=1 && break
done
number_check $VEID || FLAG=1
test "$FLAG" = "0" && break
done
# hostname input
dialog --title "hostname" --inputbox "Please enter new hostname : " 20 60 "vps$VEID" 2> $TMPFILE
HOSTNAME=`cat $TMPFILE`
# IP address input
dialog --title "IP Address" --inputbox "Please enter IP : " 20 60 "192.168.0.1" 2> $TMPFILE
IP=`cat $TMPFILE`
# nameserver input
dialog --title "nameserver" --inputbox "Please enter nameserver : " 20 60 "168.126.63.1" 2> $TMPFILE
NAMESERVER=`cat $TMPFILE`
# onboot yes/no
dialog --title "onbook option" --menu "VEID $VEID active on boot time" 20 60 2 yes "Yes, I'll be active vps on boot" no "No, unactive" 2> $TMPFILE
ONBOOT=`cat $TMPFILE`
dialog --title "Information" --msgbox "System is ready to make VPS $VEID...\n\nVEID : $VEID\nHostname : $HOSTNAME\nIP Address : $IP\nNameserver : $NAMESERVER\nOn Boot : $ONBOOT" 20 60
vzctl create $VEID --ostemplate $TEMPLATE &&
vzctl set $VEID --save --onboot=$ONBOOT --ipadd $IP --nameserver $NAMESERVER --hostname $HOSTNAME
exit 0


댓글을 달아 주세요