Created
July 25, 2015 02:54
-
-
Save ilyaevseev/5fce998a42b91d192aae to your computer and use it in GitHub Desktop.
Convert Xen VM to Openvz CT
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
CTID="123" | |
NAME="mysite" | |
HOSTNAME="mysite.org" | |
IPADDR="1.2.3.4" | |
OLD_IPADDR="5.6.7.8" | |
SRCHOST="root@mysite.org::RootDir" | |
export RSYNC_PASSWORD="JustPassMe" | |
#-------------------------------- | |
mkdir -p /var/lib/vz/{root,private}/$CTID | |
cd /var/lib/vz/private/$CTID | |
: rsync -auxXH --numeric-ids --delete --stats "$XENHOST" . | |
: last sync = /var/lib/mysql | |
#-------------------------------- | |
conf="/etc/vz/conf/$CTID.conf" | |
if ! test -f "$conf" ; then | |
cp -p /etc/vz/conf/ve-basic.conf-sample > "$conf" | |
echo 'OSTEMPLATE="centos"' >> $conf | |
vzctl set "$CTID" --save --name "$NAME" --hostname "$HOSTNAME" --onboot "yes" \ | |
--ipadd "$IPADDR" --ipadd "192.0.2.$CTID" \ | |
--privvmpages "$[2 * 65536]:$[2 * 69632]" | |
fi | |
#-------------------------------- | |
rm "etc/mtab" | |
ln -sf "/proc/mounts" "etc/mtab" | |
#-------------------------------- | |
test -f "etc/init/tty.conf" && mv "etc/init/tty.conf" "etc/init/.tty.conf.OFF" | |
#-------------------------------- | |
sed -i'.old' -e '/^\/.*/d' "etc/fstab" | |
#-------------------------------- | |
mkdir -p "dev/pts" | |
cp -a /dev/ttyp* /dev/ptyp* /dev/null /dev/urandom "dev/" | |
#-------------------------------- | |
mkdir "proc" | |
#-------------------------------- | |
# Replace old IP to new IP.. | |
R() { sed -i.old -e "s,$OLD_IPADDR,$IPADDR," "$1" ; rm "$1.old" ; } | |
R etc/exim/exim.conf | |
R etc/httpd/conf.d/00-rpaf.conf | |
R etc/httpd/conf/httpd.conf | |
R etc/sysconfig/network-scripts/ifcfg-eth0 | |
R etc/nginx/conf.d/default.conf | |
R etc/nginx/nginx.conf | |
R etc/rc.d/rc.local | |
R usr/local/ispmgr/etc/ispmgr.inc | |
R usr/local/ispmgr/etc/ispmgr.conf | |
R usr/local/ispmgr/etc/nginx.inc |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment