dtc-xen-0.5.17/0000755000175000017500000000000011736663756011674 5ustar zigozigodtc-xen-0.5.17/3rdparty/0000755000175000017500000000000011736663746013443 5ustar zigozigodtc-xen-0.5.17/3rdparty/Properties.py0000644000175000017500000002171111736663746016153 0ustar zigozigo#! /usr/bin/env python """ A Python replacement for java.util.Properties class This is modelled as closely as possible to the Java original. Created - Anand B Pillai """ import sys,os import re import time class IllegalArgumentException(Exception): def __init__(self, lineno, msg): self.lineno = lineno self.msg = msg def __str__(self): s='Exception at line number %d => %s' % (self.lineno, self.msg) return s class Properties(object): def __init__(self, props=None): # Note: We don't take a default properties object # as argument yet # Dictionary of properties. self._props = {} # Dictionary of properties with 'pristine' keys # This is used for dumping the properties to a file # using the 'store' method self._origprops = {} self.othercharre = re.compile(r'(?',line # Means we need to split by space. first, last = m2.span() sepidx = first elif m: # print 'Other match=>',line # No matching wspace char found, need # to split by either '=' or ':' first, last = m.span() sepidx = last - 1 # print line[sepidx] # If the last character is a backslash # it has to be preceded by a space in which # case the next line is read as part of the # same property while line[-1] == '\\': # Read next line nextline = i.next() nextline = nextline.strip() lineno += 1 # This line will become part of the value line = line[:-1] + nextline # Now split to key,value according to separation char if sepidx != -1: key, value = line[:sepidx], line[sepidx+1:] else: key,value = line,'' # This is for storing the pristine keys and values oldkey = key oldvalue = value # Create key intelligently keyparts = self.bspacere.split(key) # print keyparts strippable = False lastpart = keyparts[-1] if lastpart.find('\\ ') != -1: keyparts[-1] = lastpart.replace('\\','') # If no backspace is found at the end, but empty # space is found, strip it elif lastpart and lastpart[-1] == ' ': strippable = True key = ''.join(keyparts) if strippable: key = key.strip() oldkey = oldkey.strip() # print oldkey self._props[key] = value.strip() # Java escapes the '=' and ':' in the value # string with backslashes in the store method. # So let us do the same. oldvalue = oldvalue.replace(':','\:') oldvalue = oldvalue.replace('=','\=') self._origprops[oldkey] = oldvalue.strip() def load(self, stream): """ Load properties from an open file stream """ # For the time being only accept file input streams if type(stream) is not file: raise TypeError,'Argument should be a file object!' # Check for the opened mode if stream.mode != 'r': raise ValueError,'Stream should be opened in read-only mode!' try: lines = stream.readlines() self.__parse(lines) except IOError, e: raise def getProperty(self, key): """ Return a property for the given key """ return self._props.get(key,'') def setProperty(self, key, value): """ Set the property for the given key """ if type(key) is str and type(value) is str: self._props[key] = value else: raise TypeError,'both key and value should be strings!' def propertyNames(self): """ Return an iterator over all the keys of the property dictionary, i.e the names of the properties """ return self._props.keys() def list(self, out=sys.stdout): """ Prints a listing of the properties to the stream 'out' which defaults to the standard output """ out.write('-- listing properties --\n') for key,value in self._props.items(): out.write(''.join((key,'=',value,'\n'))) def store(self, out, header=""): """ Write the properties list to the stream 'out' along with the optional 'header' """ if out.mode[0] != 'w': raise ValueError,'Steam should be opened in write mode!' try: out.write(''.join(('#',header,'\n'))) # Write timestamp tstamp = time.strftime('%a %b %d %H:%M:%S %Z %Y', time.localtime()) out.write(''.join(('#',tstamp,'\n'))) # Write properties from the pristine dictionary for prop, val in self._origprops.items(): out.write(''.join((prop,'=',val,'\n'))) out.close() except IOError, e: raise def getPropertyDict(self): return self._props def __getattr__(self, name): """ For attributes not found in self, redirect to the properties dictionary """ try: return self.__dict__[name] except KeyError: if hasattr(self._props,name): return getattr(self._props, name) if __name__=="__main__": p = Properties() p.load(open('test.properties')) p.list() print p print p.items() p.store(open('test2.properties','w')) dtc-xen-0.5.17/3rdparty/daemon.py0000644000175000017500000001612311736663746015263 0ustar zigozigo#!/usr/bin/env python # # $Id: daemon.py 7274 2008-03-05 01:00:09Z bmc $ # NOTE: Documentation is intended to be processed by epydoc and contains # epydoc markup. """ Overview ======== Convert the calling process to a daemon. To make the current Python process into a daemon process, you need two lines of code:: import daemon daemon.daemonize() If C{daemonize()} fails for any reason, it throws an exception. It also logs debug messages, using the standard Python 'logging' package, to channel 'daemon'. Adapted from: - U{http://www.clapper.org/software/daemonize/} See Also ======== Stevens, W. Richard. I{Unix Network Programming} (Addison-Wesley, 1990). """ __version__ = "1.0.1" __author__ = "Brian Clapper, bmc@clapper.org" __url__ = "http://www.clapper.org/software/python/daemon/" __copyright__ = "(c) 2008 Brian M. Clapper" __license__ = "BSD-style license" __all__ = ['daemonize', 'DaemonError'] # --------------------------------------------------------------------------- # Imports # --------------------------------------------------------------------------- import logging import os import sys # --------------------------------------------------------------------------- # Constants # --------------------------------------------------------------------------- # Default daemon parameters. # File mode creation mask of the daemon. UMASK = 0 # Default working directory for the daemon. WORKDIR = "/" # Default maximum for the number of available file descriptors. MAXFD = 1024 # The standard I/O file descriptors are redirected to /dev/null by default. if (hasattr(os, "devnull")): NULL_DEVICE = os.devnull else: NULL_DEVICE = "/dev/null" # --------------------------------------------------------------------------- # Logging # --------------------------------------------------------------------------- log = logging.getLogger('daemonize') # --------------------------------------------------------------------------- # Public classes # --------------------------------------------------------------------------- class DaemonError(Exception): """ Thrown by C{daemonize()} when an error occurs while attempting to create a daemon. A C{DaemonException} object always contains a single string value that contains an error message describing the problem. """ def __init__(self, errorMessage): """ Create a new C{DaemonException}. @type errorMessage: string @param errorMessage: the error message """ self.errorMessage = errorMessage def __str__(self): """ Get a string version of the exception. @return: a string representing the exception """ return self.errorMessage # --------------------------------------------------------------------------- # Public functions # --------------------------------------------------------------------------- def daemonize(noClose=False): """ Convert the calling process into a daemon. @type noClose: boolean @param noClose: If True, don't close the file descriptors. Useful if the calling process has already redirected file descriptors to an output file. WARNING: Only set this parameter to True if you're SURE there are no open file descriptors to the calling terminal. Otherwise, you'll risk having the daemon re-acquire a control terminal, which can cause it to be killed if someone logs off that terminal. @raise DaemonException: Error during daemonizing """ global log if os.name != 'posix': log.warn('Daemon is only supported on Posix-compliant systems.') return try: # Fork once to go into the background. log.debug('Forking first child.') pid = _fork() if pid != 0: # Parent. Exit using os._exit(), which doesn't fire any atexit # functions. os._exit(0) # First child. Create a new session. os.setsid() creates the session # and makes this (child) process the process group leader. The process # is guaranteed not to have a control terminal. log.debug('Creating new session') os.setsid() # Fork a second child to ensure that the daemon never reacquires # a control terminal. log.debug('Forking second child.') pid = _fork() if pid != 0: # Original child. Exit. os._exit(0) # This is the second child. Set the umask. log.debug('Setting umask') os.umask(UMASK) # Go to a neutral corner (i.e., the primary file system, so # the daemon doesn't prevent some other file system from being # unmounted). log.debug('Changing working directory to "%s"' % WORKDIR) os.chdir(WORKDIR) # Unless noClose was specified, close all file descriptors. if not noClose: log.debug('Redirecting file descriptors') _redirectFileDescriptors() except DaemonException: raise except OSError, e: raise DaemonException('Error during daemonizing: %s [%d]' %\ (e.strerror, e.errno)) # --------------------------------------------------------------------------- # Private functions # --------------------------------------------------------------------------- def _fork(): try: return os.fork() except OSError, e: raise DaemonException, 'Cannot fork: %s [%d]' % (e.strerror, e.errno) def _redirectFileDescriptors(): import resource # POSIX resource information maxfd = resource.getrlimit(resource.RLIMIT_NOFILE)[1] if maxfd == resource.RLIM_INFINITY: maxfd = MAXFD # Close all file descriptors. for fd in range(0, maxfd): # Only close TTYs. try: os.ttyname(fd) except: continue try: os.close(fd) except OSError: # File descriptor wasn't open. Ignore. pass # Redirect standard input, output and error to something safe. # os.open() is guaranteed to return the lowest available file # descriptor (0, or standard input). Then, we can dup that descriptor # for standard output and standard error. os.open(NULL_DEVICE, os.O_RDWR) os.dup2(0, 1) os.dup2(0, 2) # --------------------------------------------------------------------------- # Main program (for testing) # --------------------------------------------------------------------------- if __name__ == '__main__': log = logging.getLogger('daemon') hdlr = logging.StreamHandler(sys.stdout) formatter = logging.Formatter('%(asctime)s %(levelname)s %(message)s', '%T') hdlr.setFormatter(formatter) log.addHandler(hdlr) log.setLevel(logging.DEBUG) log.debug('Before daemonizing, PID=%d' % os.getpid()) daemonize(noClose=True) log.debug('After daemonizing, PID=%d' % os.getpid()) log.debug('Daemon is sleeping for 10 seconds') import time time.sleep(10) log.debug('Daemon exiting') sys.exit(0) dtc-xen-0.5.17/Makefile0000644000175000017500000001251511736663746013337 0ustar zigozigo#!/usr/bin/make -f # Set to something else if you want to install elsewhere than / # DESTDIR="" # Set DISTRO=centos if you want to build for CentOS or other # RPM based distributions # Some default values that can be overrided SHARE_DIR?=/usr/share VARLIB_DIR?=/var/lib SYSCONFIG_DIR?=/etc SHARE_DOC_DIR?=/usr/share/doc MAN_DIR?=/usr/share/man USRSBIN_DIR?=/usr/sbin USRBIN_DIR?=/usr/bin INITRD_DIR?=/etc/init.d SHARE_DIR?=/usr/share INSTALL?=install -D INSTALL_DIR?=install -d DISTRO?=debian MAN8_PAGES=dtc-soap-server.8 xm_info_free_memory.8 dtc_change_bsd_kernel.8 dtc_reinstall_os.8 \ dtc_setup_vps_disk.8 dtc-xen_finish_install.8 dtc_install_centos.8 dtc_kill_vps_disk.8 dtc_write_xenhvm_conf.8 \ dtc-xen_domUconf_network_debian.8 dtc-xen_domUconf_network_redhat.8 dtc-xen_domUconf_standard.8 dtc-xen-volgroup.8 \ dtc-xen-client.8 dtc-xen_domU_gen_xen_conf.8 dtc-xen_migrate.8 SBIN_SH_SCRIPTS=dtc_kill_vps_disk xm_info_free_memory dtc_setup_vps_disk dtc_reinstall_os \ dtc_change_bsd_kernel dtc_write_xenhvm_conf dtc_install_centos dtc-xen_domUconf_standard dtc-xen_domUconf_network_debian \ dtc-xen_domUconf_network_redhat dtc-xen_finish_install dtc-soap-server dtc-xen-volgroup dtc-xen_domU_gen_xen_conf \ dtc-xen_migrate BIN_SH_SCRIPTS=dtc-xen-client VARLIB_FOLDERS=states perfdata mnt THIRD_PARTY=daemon.py Properties.py default: @-echo "Building... not..." clean: rm $(DESTDIR)$(USRSBIN_DIR)/dtc-soap-server for i in $(THIRD_PARTY) ; do rm $(DESTDIR)$(SHARE_DIR)/dtc-xen/$$i ; done rm $(DESTDIR)$(USRSBIN_DIR)/dtc-xen_finish_install # The utilities used by the soap server rm $(DESTDIR)/usr/bin/dtc-xen_userconsole for i in $(SBIN_SH_SCRIPTS) ; do rm $(DESTDIR)$(USRSBIN_DIR)/$$i ; done for i in $(BIN_SH_SCRIPTS) ; do rm $(DESTDIR)$(USRBIN_DIR)/$$i ; done # DTC autodeploy script rm $(DESTDIR)$(SHARE_DIR)/dtc-xen/dtc-panel_autodeploy.sh rm $(DESTDIR)$(SHARE_DIR)/dtc-xen/selection_config_file # man pages for i in $(MAN8_PAGES) ; do rm $(DESTDIR)$(MAN_DIR)/man8/$$i.gz ; done rm $(DESTDIR)$(MAN_DIR)/man1/dtc-xen_userconsole.1.gz install_dtc-xen-firewall: $(INSTALL) -m 0640 etc/dtc-xen/dtc-xen-firewall-config $(DESTDIR)$(SYSCONFIG_DIR)/dtc-xen/dtc-xen-firewall-config if [ ! $(DISTRO) = "debian" ] ; then \ $(INSTALL) -m 0755 etc/init.d/dtc-xen-firewall.rh $(DESTDIR)$(INITRD_DIR)/dtc-xen-firewall ; fi install: # Sysconfig stuffs $(INSTALL) -m 0644 etc/logrotate.d/dtc-xen $(DESTDIR)$(SYSCONFIG_DIR)/logrotate.d/dtc-xen # We do a cp for debian, so it will be used by dh_installinit in debian/rules, so we don't really care about the Unix rights if [ ! $(DISTRO) = "debian" ] ; then \ $(INSTALL) -m 0755 etc/init.d/dtc-xen.rh $(DESTDIR)$(INITRD_DIR)/dtc-xen ; fi # The soap server for i in $(SBIN_SH_SCRIPTS) ; do $(INSTALL) -m 0755 src/$$i $(DESTDIR)$(USRSBIN_DIR)/$$i ; done for i in $(BIN_SH_SCRIPTS) ; do $(INSTALL) -m 0755 src/$$i $(DESTDIR)$(USRBIN_DIR)/$$i ; done for i in $(THIRD_PARTY) ; do $(INSTALL) -m 0755 3rdparty/$$i $(DESTDIR)$(SHARE_DIR)/dtc-xen/$$i ; done # The utilities used by the soap server $(INSTALL) -m 0755 src/dtc-xen_userconsole $(DESTDIR)/usr/bin/dtc-xen_userconsole # DTC autodeploy script $(INSTALL) -m 0755 src/dtc-panel_autodeploy.sh $(DESTDIR)$(SHARE_DIR)/dtc-xen/dtc-panel_autodeploy.sh $(INSTALL) -m 0644 src/selection_config_file $(DESTDIR)$(SHARE_DIR)/dtc-xen/selection_config_file # The parameter parser $(INSTALL) -m 0755 src/dtc-xen-parse-param $(DESTDIR)$(SHARE_DIR)/dtc-xen/dtc-xen-parse-param # Some configuration files $(INSTALL) -m 0644 src/bashrc $(DESTDIR)$(SYSCONFIG_DIR)/dtc-xen/bashrc $(INSTALL) -m 0644 src/motd $(DESTDIR)$(SYSCONFIG_DIR)/dtc-xen/motd # man pages $(INSTALL_DIR) -m 0775 $(DESTDIR)$(MAN_DIR)/man8 $(INSTALL_DIR) -m 0775 $(DESTDIR)$(MAN_DIR)/man1 for i in $(MAN8_PAGES) ; do cp doc/$$i $(DESTDIR)$(MAN_DIR)/man8/ ; gzip -9 $(DESTDIR)$(MAN_DIR)/man8/$$i ; chmod 0644 $(DESTDIR)$(MAN_DIR)/man8/$$i.gz ; done cp doc/dtc-xen_userconsole.1 $(DESTDIR)$(MAN_DIR)/man1/ ; gzip -9 $(DESTDIR)$(MAN_DIR)/man1/dtc-xen_userconsole.1 ; chmod 0644 $(DESTDIR)$(MAN_DIR)/man1/dtc-xen_userconsole.1.gz # A bit of doc # if [ $(DISTRO) = "centos" ] ; then \ # $(INSTALL) -m 0640 doc/README.RPM $(DESTDIR)$(SHARE_DOC_DIR)/dtc-xen/README.RPM ; fi # Our default configuration file if [ ! $(DISTRO) = "debian" ] ; then \ $(INSTALL) -m 0600 etc/dtc-xen/dtc-xen.conf $(DESTDIR)$(SYSCONFIG_DIR)/dtc-xen/dtc-xen.conf ; fi # Make also a copy in the share folder, to be able to pick it up by the postinst if [ $(DISTRO) = "debian" ] ; then \ $(INSTALL) -m 0600 etc/dtc-xen/dtc-xen.conf $(DESTDIR)$(SHARE_DIR)/dtc-xen/dtc-xen.conf ; fi if [ ! $(DISTRO) = "debian" ] ; then \ $(INSTALL) -m 0644 etc/dtc-xen/sources.list $(DESTDIR)$(SYSCONFIG_DIR)/dtc-xen/sources.list ;\ $(INSTALL) -m 0644 etc/dtc-xen/inittab $(DESTDIR)$(SYSCONFIG_DIR)/dtc-xen/inittab ; fi # the runtime directories for i in $(VARLIB_FOLDERS) ; do $(INSTALL_DIR) -m 0750 $(DESTDIR)$(VARLIB_DIR)/dtc-xen/$$i ; done $(INSTALL_DIR) -m 0757 $(DESTDIR)$(VARLIB_DIR)/dtc-xen/ttyssh_home dist: ./dist deb: if [ -z $(SIGN)"" ] ; then \ ./deb ; \ else \ ./deb --sign ; \ fi rpm: $(MAKE) dist VERS=`head -n 1 debian/changelog | cut -d'(' -f2 | cut -d')' -f1 | cut -d'-' -f1` ; \ PKGNAME=`head -n 1 debian/changelog | cut -d' ' -f1` ; \ cd .. ; rpmbuild -ta $${PKGNAME}-$${VERS}.tar.gz .PHONY: dist deb rpm install install_dtc-xen-firewall clean default dtc-xen-0.5.17/etc/0000755000175000017500000000000011736663746012446 5ustar zigozigodtc-xen-0.5.17/etc/logrotate.d/0000755000175000017500000000000011736663746014670 5ustar zigozigodtc-xen-0.5.17/etc/logrotate.d/dtc-xen0000644000175000017500000000034711736663746016161 0ustar zigozigo/var/log/dtc-xen.log { weekly missingok rotate 10 compress delaycompress create 640 root adm sharedscripts postrotate if [ -f /var/run/dtc-xen.pid ] ; then /etc/init.d/dtc-xen reload > /dev/null 2>&1 fi endscript } dtc-xen-0.5.17/etc/dtc-xen/0000755000175000017500000000000011736663746014010 5ustar zigozigodtc-xen-0.5.17/etc/dtc-xen/sources.list0000644000175000017500000000027211736663746016371 0ustar zigozigodeb http://ftp.us.debian.org/debian/ stable main deb http://security.debian.org/debian-security/ stable/updates main deb http://volatile.debian.org/debian-volatile/ stable/volatile main dtc-xen-0.5.17/etc/dtc-xen/dtc-xen-firewall-config0000644000175000017500000000235411736663746020347 0ustar zigozigo# This is the configuration files for the default rules of the # dtc-xen-firewall script. Feel free to customize as you wish. Note that all # rules have default values in the script, and that you don't need to have # variables defined unless you wish to override the default value. # ACCEPTING_RATE is how much connection per ACCEPTING_TIME you want to accept # in the INPUT chain, which means in fact how much connections to your dom0 # FORWARDING_RATE is the same but for the forward chain (which means: # connections to your domUs globaly) # Time is always in seconds, rate is in number of connections during this # the defined time. # Connection rate to the dtc-xen SOAP server #SOAP_ACCEPTING_RATE=20 #SOAP_ACCEPTING_TIME=5 # Rate limits for ssh connections (prevents brute force, dictionnary and DoS) #SSH_ACCEPTING_RATE=10 #SSH_ACCEPTING_TIME=300 #SSH_FORWARDING_RATE=5 #SSH_FORWARDING_TIME=10 # Ping flood limits (prevents DoS and data center broadcast hell) # Rate here is per seconds #PING_ACCEPTING_RATE=5 #PING_FORWARDING_RATE=50 # Syn flood limits (prevents DoS and data center broadcast hell) #SYN_ACCEPTING_RATE=10 #SYN_FORWARDING_RATE=100 # SYN,ACK,FIN,RST global limits #GLOB_CONNECT_ACCEPTING_RATE=10 #GLOB_CONNECT_FORWARDING_RATE=1000 dtc-xen-0.5.17/etc/dtc-xen/dtc-xen.conf0000644000175000017500000001213111736663746016217 0ustar zigozigo# These are in most cases not to be edited: listen_address=0.0.0.0 listen_port=8089 admin_user=dtc-xen # cert_passphrase is to be used if the certificate you created has a passphrase # in most case, do not edit. #cert_passphrase= # provisioning_volgroup lets you choose which volume group to provision disk # space from if left empty, it picks the last volume group on the output listed # by vgdisplay -c which means you need to edit this only if you have more than # one volume group in your system, and you want to avoid DTC-Xen to be confused provisioning_volgroup= provisioning_mount_point=/var/lib/dtc-xen/mnt # Setting this value is VERY important if you have more than one DTC-Xen # server in production in the same LAN. # Previously, DTC-Xen was using the node number (which doesn't exist in this # version of DTC-Xen) to calculate this number, this is not the case anymore, # you HAVE to edit it to avoid MAC addresses conflicts, otherwise Xen will # pickup a random MAC for you, which could be very problematic. Note that this # is a prefix, the DTC-Xen VPS number will be added at the end of the string, # making something like: mac=00:00:20:00:00:XX where XX is the VPS number. #vps_mac_prefix=00:00:20:00:00 # Bridge # Specify your bridge interface here. #bridge=eth0 # If left commented, dtc-xen will use /boot/vmlinuz-RUNNING_KERNEL_RELEASE # and /boot/initrd.img-RUNNING_KERNEL_RELEASE to find the kernel image to use # using a uname -r command. If your domU kernel release name is different # from the one in your dom0, then you need to uncomment. Lease by default # otherwise. # CentOS users might want to run: # mkinitrd -v --with=xenblk --omit-scsi-modules --omit-raid-modules /boot/my-initrd `uname -r` # and replace INITRDPATH with /boot/my-initrd, as by default, the CentOS # init ramdisk image does NOT work: scsi has to be removed, and xennet has # to be added. #KERNEL_RELEASE=2.6.32-5-xen-amd64 #KMOD_PATH=/lib/modules/2.6.32-5-xen-amd64 #KERNELPATH=/boot/vmlinuz-2.6.32-5-amd64-amd64 #INITRDPATH=/boot/initrd.img-2.6.32-5-xen-amd64 # Needed by dtc_reinstall_os to install NetBSD VPSes bsd_kernel_path=/boot/netbsd-XENU bsd_install_kernel_path=/boot/netbsd-INSTALL_XENU # Repo used by dtc_reinstall_os to install Debian VPSes with debootstrap # the commented value is the default value -- uncomment to customize #debian_repo=http://ftp.us.debian.org/debian/ # debian_release defaults to lenny, which is the latest Debian release # installable with debootstrap. The commented value is the default, # which is subject to change as later versions of debootstrap gain the # capabiilty to install later releases of Debian. #debian_release=lenny # This is a list of Debian packages that will be installed with debootstrap, # on top of the distribution. I can't even work without joe and screen, so # it's there by default. Feel free to add some more. This is a list of debian # packages, separated by a "," (eg: coma). #debian_added_debs=module-init-tools,locales,udev,joe,screen # Same, but for CentOS this time. Note that packages are separated by a space # here, as this is what yum is expected. #centos_added_rpms="joe screen" # Default values if you don't want to use them as parameters when using # dtc_reinstall_os from the shell. #GATEWAY=192.168.2.1 #NETMASK=255.255.255.0 #BROADCAST=12.168.2.255 #DNS=192.168.2.1 # This will be used as extra= parameter in the domU startup configuration # file. Edit it if your kernel needs additional parameters, otherwise, leave # as default. # The default for a CentOS dom0 "4", the default for a Debian dom0 has what is # need for console: "4 TERM=xterm xencons=tty console=tty1" # which will produce: # extra = "4 TERM=xterm xencons=tty console=tty1" # Take care, since v0.5.11, DO NOT type extra =, just what is AFTER it. XENU_EXTRA_PARM="4" # If this variable is set, then a custom script is launch after the VM is fully # setup, but not unmounted yet. This way, you can customize as you like, # without breaking any existing dtc-xen code. Default is to not run anything. # This script will receive parameters just like any other dtc-xen scripts, # which shall be parsed by dtc-xen-parse-param. We STRONGLY suggest that your # custom script sources the dtc-xen-parse-param in order to do the parameter # parsing, as they could evolve (while there's a big chance that the variable # names will remain). To do this, simply start your script as follow: # # #!/bin/sh # set -e # . /usr/share/dtc-xen/dtc-xen-parse-param # [ ... your custom script starts here ... ] # # The below example shows a script in /usr/sbin, which is the normaly place # to put root user scripts in. # custom_postinstall_script=/usr/sbin/my-funny-script # Device type for the PV guests. Values can be: # - xvd # - sda # The value of xvd should be best in all cases, as it's working for Xen 4.x, # but also for 3.x, while device names with sdaX will not work with Xen 4.x. XEN_DOMU_HDD_DEV_TYPE=xvd # If running VZ, and if you don't want to use one LVM partition per container, # you can uncomment the below option, and dtc-xen will not mount a partition # for each of the containers. # This will also prevent formating of a partition. #VZ_NO_MOUNT=yes dtc-xen-0.5.17/etc/dtc-xen/inittab0000644000175000017500000000325711736663746015374 0ustar zigozigo# # inittab This file describes how the INIT process should set up # the system in a certain run-level. # # Author: Miquel van Smoorenburg, # Modified for RHS Linux by Marc Ewing and Donnie Barnes # # Default runlevel. The runlevels used by RHS are: # 0 - halt (Do NOT set initdefault to this) # 1 - Single user mode # 2 - Multiuser, without NFS (The same as 3, if you do not have networking) # 3 - Full multiuser mode # 4 - unused # 5 - X11 # 6 - reboot (Do NOT set initdefault to this) # id:3:initdefault: # System initialization. si::sysinit:/etc/rc.d/rc.sysinit l0:0:wait:/etc/rc.d/rc 0 l1:1:wait:/etc/rc.d/rc 1 l2:2:wait:/etc/rc.d/rc 2 l3:3:wait:/etc/rc.d/rc 3 l4:4:wait:/etc/rc.d/rc 4 l5:5:wait:/etc/rc.d/rc 5 l6:6:wait:/etc/rc.d/rc 6 # Trap CTRL-ALT-DELETE ca::ctrlaltdel:/sbin/shutdown -t3 -r now # When our UPS tells us power has failed, assume we have a few minutes # of power left. Schedule a shutdown for 2 minutes from now. # This does, of course, assume you have powerd installed and your # UPS connected and working correctly. pf::powerfail:/sbin/shutdown -f -h +2 "Power Failure; System Shutting Down" # If power was restored before the shutdown kicked in, cancel it. pr:12345:powerokwait:/sbin/shutdown -c "Power Restored; Shutdown Cancelled" # Run gettys in standard runlevels co:2345:respawn:/sbin/mingetty console #1:2345:respawn:/sbin/mingetty tty1 #2:2345:respawn:/sbin/mingetty tty2 #3:2345:respawn:/sbin/mingetty tty3 #4:2345:respawn:/sbin/mingetty tty4 #5:2345:respawn:/sbin/mingetty tty5 #6:2345:respawn:/sbin/mingetty tty6 # Run xdm in runlevel 5 x:5:respawn:/etc/X11/prefdm -nodaemon dtc-xen-0.5.17/etc/init.d/0000755000175000017500000000000011736663746013633 5ustar zigozigodtc-xen-0.5.17/etc/init.d/dtc-xen-firewall0000644000175000017500000001424711736663746016733 0ustar zigozigo#!/bin/sh ### BEGIN INIT INFO # Provides: dtc-xen-firewall # Required-Start: $all # Required-Stop: # Should-Start: $local_fs # Should-Stop: $local_fs # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: A small firewall script for your dom0 # Description: If running in a production environment, you might want # to have a basic firewall running on your dom0 to avoid # having DoS attack. This is not the state-of-the-art, but # just another attempt to make things a bit more smooth. ### END INIT INFO # To maintainers of this script: # NEVER a dtc-xen-fw should have an ACCEPT statement, as this would disable the # Xen anti-spoof rules. Instead, use RETURN to exit the chain. IPTABLES=/sbin/iptables if [ -f /etc/dtc-xen/dtc-xen-firewall.sh ] ; then . /etc/dtc-xen/dtc-xen-firewall.sh fi if [ -e /etc/dtc-xen/dtc-xen-firewall-config ] ; then . /etc/dtc-xen/dtc-xen-firewall-config fi if [ -z ${soap_server_allowed_ip} ] ; then soap_server_allowed_ip=0.0.0.0 fi flush_input_chain () { ${IPTABLES} -F dtc-xen-input } create_dtc_xen_forward_chain () { # Create the chain (if it doesn't exists, then it should be inserted in the INPUT or FORWARD chain) if ${IPTABLES} --new-chain dtc-xen-in ; then ${IPTABLES} -I INPUT -j dtc-xen-in fi if ${IPTABLES} --new-chain dtc-xen-fw ; then ${IPTABLES} -I FORWARD -j dtc-xen-fw fi # If the chains already existed, flush them ${IPTABLES} -F dtc-xen-fw ${IPTABLES} -F dtc-xen-in } accept_localhost_traffic () { ${IPTABLES} -A dtc-xen-in -i lo -j ACCEPT } soap_server_limit () { # Allow only our management server to connect if ! [ ${soap_server_allowed_ip} = "0.0.0.0" ] ; then ${IPTABLES} -A dtc-xen-in -p tcp --dport 8089 -s ! ${soap_server_allowed_ip} -j LOGREJECT fi if [ -z "${SOAP_ACCEPTING_RATE}" ] ; then SOAP_ACCEPTING_RATE=20 fi if [ -z "${SOAP_ACCEPTING_TIME}" ] ; then SOAP_ACCEPTING_TIME=5 fi # Rate limit connections to our SOAP server (20 connections per minutes should be more than enough...) ${IPTABLES} -A dtc-xen-in -p tcp --dport 8089 -m state --state NEW -m recent --set ${IPTABLES} -A dtc-xen-in -p tcp --dport 8089 -m state --state NEW -m recent --update --seconds ${SOAP_ACCEPTING_TIME} --hitcount ${SOAP_ACCEPTING_RATE} -j LOGREJECT } port25_reject () { ${IPTABLES} -A dtc-xen-in -p tcp --dport 25 -j LOGREJECT } call_add_custom_rules () { if [ -e /etc/dtc-xen/dtc-xen-firewall-custom-rules ] ; then . /etc/dtc-xen/dtc-xen-firewall-custom-rules add_custom_rules fi } limit_ssh_login_rate () { if [ -z "${SSH_ACCEPTING_RATE}" ] ; then SSH_ACCEPTING_RATE=10 fi if [ -z "${SSH_ACCEPTING_TIME}" ] ; then SSH_ACCEPTING_TIME=300 fi if [ -z "${SSH_FORWARDING_RATE}" ] ; then SSH_FORWARDING_RATE=5 fi if [ -z "${SSH_FORWARDING_TIME}" ] ; then SSH_FORWARDING_TIME=10 fi # Anti DoS SSH : deny ssh for 300 seconds after 4 attempts # This can't be too low because of the use of scp # For the dom0 first: ${IPTABLES} -A dtc-xen-in -p tcp --dport 22 -m state --state NEW -m recent --set ${IPTABLES} -A dtc-xen-in -p tcp --dport 22 -m state --state NEW -m recent --update --seconds ${SSH_ACCEPTING_TIME} --hitcount ${SSH_ACCEPTING_RATE} -j LOGREJECT # The for the domUs: ${IPTABLES} -A dtc-xen-fw -p tcp --dport 22 -m state --state NEW -m recent --set ${IPTABLES} -A dtc-xen-fw -p tcp --dport 22 -m state --state NEW -m recent --update --seconds ${SSH_FORWARDING_TIME} --hitcount ${SSH_FORWARDING_RATE} -j LOGREJECT } ping_flood_protect () { if [ -z "${PING_ACCEPTING_RATE}" ] ; then PING_ACCEPTING_RATE=5 fi if [ -z "${PING_FORWARDING_RATE}" ] ; then PING_FORWARDING_RATE=50 fi # Limit for dom0 ${IPTABLES} -A dtc-xen-in -p icmp --icmp-type echo-request -m limit --limit ${PING_ACCEPTING_RATE}/s -j RETURN ${IPTABLES} -A dtc-xen-in -p icmp --icmp-type echo-request -j LOGDROP # There is no reason why a 20 VPS would be ping more than 50 times per seconds ${IPTABLES} -A dtc-xen-fw -p icmp --icmp-type echo-request -m limit --limit ${PING_FORWARDING_RATE}/s -j RETURN ${IPTABLES} -A dtc-xen-fw -p icmp --icmp-type echo-request -j LOGDROP } syn_flood_protect () { if [ -z "${SYN_ACCEPTING_RATE}" ] ; then SYN_ACCEPTING_RATE=10 fi if [ -z "${SYN_FORWARDING_RATE}" ] ; then SYN_FORWARDING_RATE=100 fi # For dom0 ${IPTABLES} -A dtc-xen-in -p tcp --syn -m limit --limit ${SYN_ACCEPTING_RATE}/s -j RETURN ${IPTABLES} -A dtc-xen-in -p tcp --syn -j LOGDROP # For VPS ${IPTABLES} -A dtc-xen-fw -p tcp --syn -m limit --limit ${SYN_FORWARDING_RATE}/s -j RETURN ${IPTABLES} -A dtc-xen-fw -p tcp --syn -j LOGDROP } port_scanner_limitation () { if [ -z "${GLOB_CONNECT_ACCEPTING_RATE}" ] ; then GLOB_CONNECT_ACCEPTING_RATE=10 fi if [ -z "${GLOB_CONNECT_FORWARDING_RATE}" ] ; then GLOB_CONNECT_FORWARDING_RATE=1000 fi #Furtive port scanner a bit more annoying... ${IPTABLES} -A dtc-xen-in -p tcp --tcp-flags SYN,ACK,FIN,RST RST -m limit --limit ${GLOB_CONNECT_ACCEPTING_RATE}/s -j RETURN ${IPTABLES} -A dtc-xen-in -p tcp --tcp-flags SYN,ACK,FIN,RST RST -j LOGDROP ${IPTABLES} -A dtc-xen-fw -p tcp --tcp-flags SYN,ACK,FIN,RST RST -m limit --limit ${GLOB_CONNECT_FORWARDING_RATE}/s -j RETURN ${IPTABLES} -A dtc-xen-fw -p tcp --tcp-flags SYN,ACK,FIN,RST RST -j LOGDROP } setup_log_chain () { ${IPTABLES} -N LOGDROP > /dev/null 2> /dev/null ${IPTABLES} -F LOGDROP ${IPTABLES} -A LOGDROP -m limit --limit 1/s -j LOG --log-prefix "LOGDROP: " ${IPTABLES} -A LOGDROP -j DROP ${IPTABLES} -N LOGREJECT > /dev/null 2> /dev/null ${IPTABLES} -F LOGREJECT ${IPTABLES} -A LOGREJECT -m limit --limit 1/s -j LOG --log-prefix "LOGREJECT: " ${IPTABLES} -A LOGREJECT -j REJECT } case "${1}" in start) # flush-input-chain setup_log_chain create_dtc_xen_forward_chain accept_localhost_traffic port25_reject soap_server_limit call_add_custom_rules limit_ssh_login_rate ping_flood_protect syn_flood_protect port_scanner_limitation ;; stop) while iptables -D dtc-xen-fw 1 ; do echo -n "" ; done while iptables -D dtc-xen-in 1 ; do echo -n "" ; done ;; restart|reload|force-reload) ${0} stop sleep 1 ${0} start ;; *) echo "Usage: ${0} "'{start|stop|restart|reload}' exit 1 esac exit 0 dtc-xen-0.5.17/etc/init.d/dtc-xen0000644000175000017500000000240511736663746015121 0ustar zigozigo#!/bin/sh ### BEGIN INIT INFO # Provides: dtc-xen # Required-Start: $all # Required-Stop: # Should-Start: $local_fs # Should-Stop: $local_fs # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: Provide a SOAP server facility for managing your Xen VMs # Description: dtc-xen is a SOAP server running over HTTPS with auth, # so a web GUI tool can manage, create and destroy your # domU under Xen. This package is to be run in the dom0 # of your Xen server. It's written to integrate within DTC # web hosting control panel. ### END INIT INFO . /lib/lsb/init-functions PYTHON=/usr/bin/python case "$1" in start) log_daemon_msg "Starting python SOAP server" "dtc-soap-server" start-stop-daemon --start -b --quiet --pidfile /var/run/dtc-xen-soap-server.pid --make-pidfile --exec $PYTHON /usr/sbin/dtc-soap-server log_end_msg $? ;; stop) log_daemon_msg "Stoping python SOAP server" "dtc-soap-server" start-stop-daemon --stop --oknodo --pidfile /var/run/dtc-xen-soap-server.pid log_end_msg $? ;; restart|reload|force-reload) $0 stop sleep 1 $0 start ;; *) echo 'Usage: $0 {start|stop|restart|reload}' exit 1 esac exit 0 dtc-xen-0.5.17/etc/init.d/dtc-xen.rh0000644000175000017500000000273711736663746015541 0ustar zigozigo#!/bin/sh # dtc-xen DTC Xen VPS remote management suite # # chkconfig: 345 99 00 # description: DTC-Xen lets you create and manage Xen VPS instances remotely, monitor # their status and shut them down. You can use any SOAP client to # interface with DTC-Xen, but you might want to use DTC to easily # manage an entire farm of Xen VPSes. # processname: dtc-xen # pidfile: /var/run/dtc-xen.pid # config: /etc/dtc-xen/soap.conf # # Based on Postfix startup script distributed in Fedora . /etc/rc.d/init.d/functions . /etc/sysconfig/network pidfile=/var/run/dtc-xen.pid status -p $pidfile dtc-xen >/dev/null 2>&1 running=$? confpath=/etc/dtc-xen start() { # Check that networking is up. [ ${NETWORKING} = "no" ] && exit 1 # Start daemons. echo -n $"Starting DTC-Xen: " daemon /usr/sbin/dtc-soap-server -D RETVAL=$? [ $RETVAL -eq 0 ] && touch /var/lock/subsys/dtc-xen echo return $RETVAL } stop() { # Stop daemons. echo -n $"Shutting down DTC-Xen: " killproc -p $pidfile dtc-xen && success || failure $"$prog stop" RETVAL=$? [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/dtc-xen echo return $RETVAL } # See how we were called. case "$1" in start) [ $running -eq 0 ] && exit 0 start ;; stop) [ $running -eq 0 ] || exit 0 stop ;; restart) stop start ;; status) status -p $pidfile dtc-xen ;; condrestart) [ $running -eq 0 ] || exit 0 stop start ;; *) echo $"Usage: $0 {start|stop|restart|status|condrestart}" exit 2 esac exit $?dtc-xen-0.5.17/etc/init.d/dtc-xen-firewall.rh0000644000175000017500000001516411736663746017342 0ustar zigozigo#!/bin/sh # dtc-xen-firewall DTC Xen VPS firewall # # chkconfig: 345 99 00 # description: DTC-Xen firewall is a rate-limiting firewall script that you can use on your # servers using DTC-Xen. # config: /etc/dtc-xen/dtc-xen-firewall-config # # Based on Postfix startup script distributed in Fedora . /etc/rc.d/init.d/functions . /etc/sysconfig/network IPTABLES=/sbin/iptables if [ -f /etc/dtc-xen/dtc-xen-firewall.sh ] ; then . /etc/dtc-xen/dtc-xen-firewall.sh fi if [ -e /etc/dtc-xen/dtc-xen-firewall-config ] ; then . /etc/dtc-xen/dtc-xen-firewall-config fi if [ -z ${soap_server_allowed_ip} ] ; then soap_server_allowed_ip=0.0.0.0 fi flush_input_chain () { ${IPTABLES} -F dtc-xen-input } create_dtc_xen_forward_chain () { # Create the chain (if it doesn't exists, then it should be inserted in the INPUT or FORWARD chain) if ${IPTABLES} --new-chain dtc-xen-in ; then ${IPTABLES} -I INPUT -j dtc-xen-in fi if ${IPTABLES} --new-chain dtc-xen-fw ; then ${IPTABLES} -I FORWARD -j dtc-xen-fw fi # If the chains already existed, flush them ${IPTABLES} -F dtc-xen-fw ${IPTABLES} -F dtc-xen-in } accept_localhost_traffic () { ${IPTABLES} -A dtc-xen-in -i lo -j ACCEPT } soap_server_limit () { # Allow only our management server to connect if ! [ ${soap_server_allowed_ip} = "0.0.0.0" ] ; then ${IPTABLES} -A dtc-xen-in -p tcp --dport 8089 -s ! ${soap_server_allowed_ip} -j LOGREJECT fi if [ -z "${SOAP_ACCEPTING_RATE}" ] ; then SOAP_ACCEPTING_RATE=10 fi if [ -z "${SOAP_ACCEPTING_TIME}" ] ; then SOAP_ACCEPTING_TIME=5 fi # Rate limit connections to our SOAP server (20 connections per minutes should be more than enough...) ${IPTABLES} -A dtc-xen-in -p tcp --dport 8089 -m state --state NEW -m recent --set ${IPTABLES} -A dtc-xen-in -p tcp --dport 8089 -m state --state NEW -m recent --update --seconds ${SOAP_ACCEPTING_TIME} --hitcount ${SOAP_ACCEPTING_RATE} -j LOGREJECT } port25_reject () { ${IPTABLES} -A dtc-xen-in -p tcp --dport 25 -j LOGREJECT } call_add_custom_rules () { if [ -e /etc/dtc-xen/dtc-xen-firewall-custom-rules ] ; then . /etc/dtc-xen/dtc-xen-firewall-custom-rules add_custom_rules fi } limit_ssh_login_rate () { if [ -z "${SSH_ACCEPTING_RATE}" ] ; then SSH_ACCEPTING_RATE=10 fi if [ -z "${SSH_ACCEPTING_TIME}" ] ; then SSH_ACCEPTING_TIME=300 fi if [ -z "${SSH_FORWARDING_RATE}" ] ; then SSH_FORWARDING_RATE=5 fi if [ -z "${SSH_FORWARDING_TIME}" ] ; then SSH_FORWARDING_TIME=10 fi # Anti DoS SSH : deny ssh for 300 seconds after 4 attempts # This can't be too low because of the use of scp # For the dom0 first: ${IPTABLES} -A dtc-xen-in -p tcp --dport 22 -m state --state NEW -m recent --set ${IPTABLES} -A dtc-xen-in -p tcp --dport 22 -m state --state NEW -m recent --update --seconds ${SSH_ACCEPTING_TIME} --hitcount ${SSH_ACCEPTING_RATE} -j LOGREJECT # The for the domUs: ${IPTABLES} -A dtc-xen-fw -p tcp --dport 22 -m state --state NEW -m recent --set ${IPTABLES} -A dtc-xen-fw -p tcp --dport 22 -m state --state NEW -m recent --update --seconds ${SSH_FORWARDING_TIME} --hitcount ${SSH_FORWARDING_RATE} -j LOGREJECT } ping_flood_protect () { if [ -z "${PING_ACCEPTING_RATE}" ] ; then PING_ACCEPTING_RATE=5 fi if [ -z "${PING_FORWARDING_RATE}" ] ; then PING_FORWARDING_RATE=50 fi # Limit for dom0 ${IPTABLES} -A dtc-xen-in -p icmp --icmp-type echo-request -m limit --limit ${PING_ACCEPTING_RATE}/s -j RETURN ${IPTABLES} -A dtc-xen-in -p icmp --icmp-type echo-request -j LOGDROP # There is no reason why a 20 VPS would be ping more than 50 times per seconds ${IPTABLES} -A dtc-xen-fw -p icmp --icmp-type echo-request -m limit --limit ${PING_FORWARDING_RATE}/s -j RETURN ${IPTABLES} -A dtc-xen-fw -p icmp --icmp-type echo-request -j LOGDROP } syn_flood_protect () { if [ -z "${SYN_ACCEPTING_RATE}" ] ; then SYN_ACCEPTING_RATE=10 fi if [ -z "${SYN_FORWARDING_RATE}" ] ; then SYN_FORWARDING_RATE=100 fi # For dom0 ${IPTABLES} -A dtc-xen-in -p tcp --syn -m limit --limit ${SYN_ACCEPTING_RATE}/s -j RETURN ${IPTABLES} -A dtc-xen-in -p tcp --syn -j LOGDROP # For VPS ${IPTABLES} -A dtc-xen-fw -p tcp --syn -m limit --limit ${SYN_FORWARDING_RATE}/s -j RETURN ${IPTABLES} -A dtc-xen-fw -p tcp --syn -j LOGDROP } port_scanner_limitation () { if [ -z "${GLOB_CONNECT_ACCEPTING_RATE}" ] ; then GLOB_CONNECT_ACCEPTING_RATE=10 fi if [ -z "${GLOB_CONNECT_FORWARDING_RATE}" ] ; then GLOB_CONNECT_FORWARDING_RATE=1000 fi #Furtive port scanner a bit more annoying... ${IPTABLES} -A dtc-xen-in -p tcp --tcp-flags SYN,ACK,FIN,RST RST -m limit --limit ${GLOB_CONNECT_ACCEPTING_RATE}/s -j RETURN ${IPTABLES} -A dtc-xen-in -p tcp --tcp-flags SYN,ACK,FIN,RST RST -j LOGDROP ${IPTABLES} -A dtc-xen-fw -p tcp --tcp-flags SYN,ACK,FIN,RST RST -m limit --limit ${GLOB_CONNECT_FORWARDING_RATE}/s -j RETURN ${IPTABLES} -A dtc-xen-fw -p tcp --tcp-flags SYN,ACK,FIN,RST RST -j LOGDROP } setup_log_chain() { ${IPTABLES} -N LOGDROP > /dev/null 2> /dev/null ${IPTABLES} -F LOGDROP ${IPTABLES} -A LOGDROP -m limit --limit 1/s -j LOG --log-prefix "LOGDROP: " ${IPTABLES} -A LOGDROP -j DROP ${IPTABLES} -N LOGREJECT > /dev/null 2> /dev/null ${IPTABLES} -F LOGREJECT ${IPTABLES} -A LOGREJECT -m limit --limit 1/s -j LOG --log-prefix "LOGREJECT: " ${IPTABLES} -A LOGREJECT -j REJECT } start() { echo -n $"Starting DTC-Xen firewall: " setup_log_chain create_dtc_xen_forward_chain accept_localhost_traffic port25_reject soap_server_limit call_add_custom_rules limit_ssh_login_rate ping_flood_protect syn_flood_protect port_scanner_limitation RETVAL=$? [ $RETVAL -eq 0 ] && touch /var/lock/subsys/dtc-xen-firewall [ $RETVAL -eq 0 ] && success || failure echo return $RETVAL } stop() { echo -n $"Shutting down DTC-Xen firewall: " while ${IPTABLES} -D dtc-xen-in 1 2> /dev/null ; do true ; done while ${IPTABLES} -D dtc-xen-fw 1 2> /dev/null ; do true ; done rulenum=$(( `$IPTABLES -L INPUT -n | nl | grep dtc-xen-in | awk '{ print $1 }'` - 2 )) ${IPTABLES} -D INPUT $rulenum rulenum=$(( `$IPTABLES -L FORWARD -n | nl | grep dtc-xen-fw | awk '{ print $1 }'` - 2 )) ${IPTABLES} -D FORWARD $rulenum ${IPTABLES} -X dtc-xen-in ${IPTABLES} -X dtc-xen-fw RETVAL=$? [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/dtc-xen-firewall [ $RETVAL -eq 0 ] && success || failure echo return $RETVAL } # See how we were called. case "$1" in start) [ -f /var/lock/subsys/dtc-xen-firewall ] && exit 0 start ;; stop) [ -f /var/lock/subsys/dtc-xen-firewall ] || exit 0 stop ;; condrestart) [ -f /var/lock/subsys/dtc-xen-firewall ] || exit 0 stop start ;; restart) stop start ;; *) echo $"Usage: $0 {start|stop|restart|condrestart}" exit 2 esac exit $? dtc-xen-0.5.17/doc/0000755000175000017500000000000011736663746012440 5ustar zigozigodtc-xen-0.5.17/doc/dtc-xen_userconsole.10000644000175000017500000000142211736663746016504 0ustar zigozigo.TH dtc-xen_userconsole 1 .SH NAME dtc-xen_userconsole \- Helps to have a user connect to a xen physical console .SH SYNOPSIS .B dtc-xen_userconsole .I XEN_USERNAME .SH DESCRIPTION .B dtc-xen_userconsole This shell script is a part of the dtc-xen package that is to be used by the dtc panel to manage a Xen VPS server. This script will be used each time a user will connect to the physical console of his VPS. Look in it, it's VERY short. In fact, the goal of this script is to restrict any user that would ssh as xenXX@nodeYYYY to use "xm console xenXX" as default "shell" so they can administer their VPS using it's physical console. .SH "VERSION" This documentation describes .B dtc-xen_userconsole version 0.3.16. See .B http://www.gplhost.com/software-dtc-xen.html for updates. dtc-xen-0.5.17/doc/dtc-xen_migrate.80000644000175000017500000000230111736663746015577 0ustar zigozigo.TH dtc-xen_migrate 8 .SH NAME dtc-xen_migrate \- migrate a VPS to another Xen server .SH SYNOPSIS .B LOCAL_VPS_ID .I DESTINATION_HOSTNAME [ .I DEST_VPS_ID ] .SH DESCRIPTION .B dtc-xen_migrate This shell script is a part of the dtc-xen package that is to be used by the dtc panel to manage a Xen VPS server. Note that you need rsync in both the source and the destination dom0. This script is used to move the content of a Xen virtual machine (VM) managed with dtc-xen to another Xen server of the same type. The VM destination will first be prepared, then the local VM will be shut down, then it's content will be transfered over using rsync. Note that this is NOT a live migration, and down time of approximatively the time needed for the rsync will occure. .SH PARAMETERS .B LOCAL_VPS_ID The DTC-Xen id of the VM, from 00 to 99. .B DESTINATION_HOSTNAME Destination Xen server hostname to migrate to. .B DEST_VPS_ID Destination DTC-Xen id of the VM, from 00 to 99. .SH EXAMPLE .B dtc-xen_migrate 19 alpha.example.com 21 This will migrate the content of xen19 on the local machine to the destination server alpha.example.com using xen21 as VM name. .SH "SEE ALSO" dtc_reinstall_os(8), dtc_kill_vps_disk(8) dtc-xen-0.5.17/doc/wsdl.xml0000644000175000017500000005744711736663746014154 0ustar zigozigo dtc-xen-0.5.17/doc/dtc-xen_domUconf_network_redhat.80000644000175000017500000000130111736663746021020 0ustar zigozigo.TH dtc-xen_domUconf_network_redhat 8 .SH NAME dtc-xen_domUconf_network_redhat \- configure a redhat VPS for using network .SH SYNOPSIS .B dtc-xen_domUconf_network_redhat .I VPS_PATH .I IP_ADDR .I NETMASK .I NETWORK .I BROADCAST .I GATEWAY .SH DESCRIPTION .B dtc-xen_domUconf_network_redhat This shell script is a part of the dtc-xen package that is to be used by the dtc panel to manage a Xen VPS server. When doing it's VPS install, dtc_reinstall_os will call a script to do the setup of the network. dtc-xen_domUconf_network_redhat does the job when the VPS type is RedHat (that is: works also for CentOS and Fedora core based VPS). See .B http://www.gplhost.com/software-dtc-xen.html for updates. dtc-xen-0.5.17/doc/examples/0000755000175000017500000000000011736663746014256 5ustar zigozigodtc-xen-0.5.17/doc/examples/dtc_create_vps.conf.sh0000644000175000017500000000064111736663746020524 0ustar zigozigo#!/bin/sh # This the configuration file for dtc-xen setup scripts (called uppon VM reinstallation) NODE_NUM=99999 NODE_DOMAIN_NAME=example.com DEBIAN_REPOS="ftp://ftp.us.debian.org/debian" NETMASK=255.255.255.0 NETWORK=192.168.0.0 BROADCAST=192.168.0.255 GATEWAY=192.168.0.1 LVMNAME=vg0 VPS_MOUNTPOINT=/var/lib/dtc-xen/mnt DEBIAN_RELEASE=lenny KERNELNAME=2.6.26-2-xen-amd64 INITRDNAME=initrd.img-2.6.26-2-xen-amd64 dtc-xen-0.5.17/doc/examples/soap.conf0000644000175000017500000000065011736663746016070 0ustar zigozigo# This is the configuration file for the DTC soap server dtc-xen # Please make soap_server_host correspond to NODE_NUM and NODE_DOMAIN_NAME in # dtc_create_vps.conf.sh as the postinst of dtc-xen might overwrite the value # this way soap_server_host=node99999.example.com soap_server_port=8089 soap_server_pass_phrase=12345 soap_server_dtcxen_user=dtc-xen soap_server_lvmname=vg0 soap_server_mount_point=/var/lib/dtc-xen/mnt dtc-xen-0.5.17/doc/dtc-xen-volgroup.80000644000175000017500000000127511736663746015753 0ustar zigozigo.TH dtc-xen-volgroup 8 .SH NAME dtc-xen-volgroup \- This script is a part of the SOAP server of dtc-xen running over HTTPS with Auth. .SH SYNOPSIS .B dtc-xen-volgroup .SH DESCRIPTION .B dtc-xen-volgroup This shell script is a part of the dtc-xen package that is to be used by the dtc panel to manage a Xen VPS server. It determines the name of the last volume group seen in the list of active volume groups, in order to create partitions for your VPS and avoid a painful configuration of your server. If you do not want that dtc-xen auto-determines the volume group for your VPS, as you have more than one in your system, then you can edit /etc/dtc-xen/dtc-xen.conf in order to override this script. dtc-xen-0.5.17/doc/dtc_write_xenhvm_conf.80000644000175000017500000000561511736663746017116 0ustar zigozigo.TH dtc_write_xenhvm_conf 8 .SH NAME dtc_write_xenhvm_conf \- rewrites the xen startup script with selected params .SH SYNOPSIS .B dtc_write_xenhvm_conf .I VPS_NUMBER .I MEMORY_SIZE .I ALL_IP_ADDRESSES .I VNC_CONSOLE_PASSWORD .I HOW_TO_BOOT .SH DESCRIPTION .B dtc_write_xenhvm_conf This shell script is a part of the dtc\-xen package that is to be used by the dtc panel to manage a Xen VPS server. This script generate a Xen startup file with the parameters given to the script. .SH PARAMETERS Note that ALL parameters are mendatory. .B VPS_NUMBER has to be a number between 01 and 29 .B MEMORY_SIZE is the amount of memory in mega bytes that you want to have setup in the Xen startup file for this VPS .B ALL_IP_ADDRESSES is a list of IPs that you want to be set in the VM's startup file and in the VM's configuration. Note that the IPs have to be separated by spaces, and thus you might want to use single quotes like this: '1.2.3.4 1.2.3.5'. Note that only the first IP will be set in the VM's configuration, but the list will be set in the Xen startup file so you can use the anti\-spoofing facilities of Xen if you need it (with untrusted users / unknown customers for example). .B VNC_CONSOLE_PASSWORD This is the VNC console password that you want to have set\-up in the Xen domU configuration file, so that you can connect using VNC to the the setup. Note that special value .I no_vnc can be used to declare that you do not want the VNC console to be used at all. .B HOW_TO_BOOT This controls what the VPS will use to boot. A special value of .I hdd can be used to tell dtc_write_xenhvm_conf that you want to boot on the hard drive of the domU. Any other parameters will be used as a .iso file located in /var/lib/dtc\-xen/ttyssh_home/xenXX where xenXX equals to the VPS number set in the .I VPS_NUMBER parameter (see above). Note that whatever is set in this parameter, dtc_write_xenhvm_conf will add as many cdrom devices as it finds .iso files in the /var/lib/dtc\-xen/ttyssh_home/xenXX folder. .SH EXAMPLE The following command: dtc_write_xenhvm_conf 14 512 '1.2.3.4 1.2.3.5' mYvNcPaSs boot.iso will produce this config file in /etc/xen/xen14: kernel = "/usr/lib/xen/boot/hvmloader" .br builder = 'hvm' .br memory = 512 .br name = "xen14${VPSNAME}" .br vcpus=1 .br pae=0 .br acpi=0 .br apic=0 .br vif = [ 'type=ioemu, mac=00:00:00:00:00:00, ip=1.2.3.4 1.2.3.5' ] .br disk=[ 'phy:/dev/mapper/lvm1-xen14,ioemu:hda,w', 'file:/var/lib/dtc-xen/ttyssh_home/xen14/boot.iso,hdb:cdrom,r', 'file:/var/lib/dtc-xen/ttyssh_home/xen14/cd2.iso,hdc:cdrom,r' ] .br cdrom="/var/lib/dtc-xen/ttyssh_home/xen14/boot.iso" .br boot="d" .br vfb = [ "type=vnc,vncdisplay=21,vncpasswd=mYvNcPaSs" ] .br nographic=0 .br vnc=1 .br stdvga=1 .br serial='pty' Note that the above mac address will be calculated and depend on your node name: it will NOT be like the above example. .SH UPDATES See .B http://www.gplhost.com/software\-dtc\-xen.html for updates. dtc-xen-0.5.17/doc/README.RPM0000644000175000017500000000333111736663746013755 0ustar zigozigoNOTES FOR THE RPM EDITION ===================================== After installation, you need to set the management password: htpasswd -b /etc/dtc-xen/htpasswd This is the super user name and password that DTC-Xen will require when trying to connect to it with any SOAP client or DTC. The name of the admin user can be changed in /etc/dtc-xen/soap.conf with the configuration key soap_server_dtcxen_user. It defaults to dtc-xen. DTC-Xen will not let any function be called while this password has not been set. On startup and SSL certificate generation ===================================== This package automatically creates and configures the required SSL certificate. You don't have to do anything except set the management password. It also starts automatically once installed, and sets itself up on levels 3, 4 and 5 (check the init script named dtc-xen to verify this). If you want to generate another certificate, check the files in /etc/pki/tls: - private/dtc-xen.key: private key - certs/dtc-xen.cert: certificate A good starting point for the generation of the certificate can be found in the certificate generation scriptlet: rpm -q dtc-xen --scripts It is highly recommended that you set up a proper fully-qualified domain name before regenerating the certificate. Security ============================== After installing DTC-Xen, disable port forwarding in your SSH server configuration. Otherwise a nasty user could use it to get access to the telnet port of a VPS they don't own. To do so, consult the sshd_config manual page. Thanks for choosing us! ================================= On the behalf of all GPLHost staff, dtc-xen contributors and authors, Manuel Amador (Rudd-O) dtc-xen-0.5.17/doc/dtc-xen_finish_install.80000644000175000017500000000122311736663746017157 0ustar zigozigo.TH dtc-xen_finish_install 8 .SH NAME dtc-xen_finish_install.8 \- configure your server after the package dtc-xen is installed .SH SYNOPSIS .B dtc-xen_finish_install .SH DESCRIPTION This shell script is a part of the dtc-xen package that is to be used by the dtc panel to manage a Xen VPS server. This script has no parameter and will first add an entry in your /etc/sudoers like this: %xenusers ALL= NOPASSWD: /usr/sbin/xm console xen* Then it will set the following in your sshd_config: AllowTcpForwarding no .SH "VERSION" This documentation describes .B dtc-xen_finish_install See .B http://www.gplhost.com/software-dtc-xen.html for updates. dtc-xen-0.5.17/doc/changelog0000644000175000017500000000401311736663746014310 0ustar zigozigodtc-xen (0.2.7) unstable; urgency=low * Write RPM version including initscripts, specfile, autoconfiguration, SSL cert gen * Included daemon.py from http://www.clapper.org/software/python/daemon/ (BSD license) * Added the ability to self-daemonize * Added the respective documentation in the man pages -- Manuel Amador (Rudd-O) Fri, 12 Jun 2006 18:40 -0500 dtc-xen (0.2.6) unstable; urgency=low * Make it debian standard -- Thomas Goirand Fri, 10 Nov 2006 21:12:00 +0800 dtc-xen (0.2.5) unstable; urgency=low * Add getNetworkUsage for each VPS -- Damien Mascord Wed, 25 Oct 2006 13:50:00 +0800 dtc-xen (0.2.4) unstable; urgency=low * Bugfixed the changeBSDKernel function to setup the xen startup -- Thomas GOIRAND Sun, 17 Sep 2006 13:21:00 +0800 dtc-xen (0.2.3) unstable; urgency=low * Added anti-spoofing facility (IP addresses in the vif=) -- Thomas GOIRAND Mon, 14 Sep 2006 13:21:00 +0800 dtc-xen (0.2.2) unstable; urgency=low * Added a physical console check to be sure nobody sends a param -- Thomas GOIRAND Mon, 30 Aug 2006 11:21:00 +0800 dtc-xen (0.2.1) unstable; urgency=low * Added Xen version checking so getVPSState() always work -- Thomas GOIRAND Mon, 28 Aug 2006 13:21:00 +0800 dtc-xen (0.2.0) unstable; urgency=low * Now all the functions we needed are working for the fist time -- Thomas GOIRAND Tue, 15 Aug 2006 15:21:00 +0200 dtc-xen (0.1.2) unstable; urgency=low * Added packaging of the soap server -- Thomas GOIRAND Sat, 22 Jul 2006 15:21:00 +0200 dtc-xen (0.1.1) unstable; urgency=low * Added the dtc_create_vps.sh script in /usr/sbin -- Thomas GOIRAND Sat, 8 Jul 2006 16:06:38 +0200 dtc-xen (0.1.0) unstable; urgency=low * Debian users can now do dpkg-buildpackage -rfakeroot -us -uc -- Thomas GOIRAND Tue, 28 Jun 2005 16:06:38 +0200 dtc-xen-0.5.17/doc/dtc_kill_vps_disk.80000644000175000017500000000266611736663746016232 0ustar zigozigo.TH dtc_kill_vps_disk 8 .SH NAME dtc_kill_vps_disk \- destroy LVM disks for freeing space .SH SYNOPSIS .B dtc_kill_vps_disk .I VPS_NUMBER [ .I lvm|loopback ] .SH DESCRIPTION .B dtc_kill_vps_disk This shell script is a part of the dtc-xen package that is to be used by the dtc panel to manage a Xen VPS server. This script is used to delete a partitions that was used by a VPS. It will delete the normal partition that was used as a root disk, and the swap partition. dtc_kill_vps_disk is to be used by the dtc-xen SOAP server, but can also be used as a standalone userland tool. .SH OPTIONS .B VPS_NUMBER has to be a number between 01 and 19. Let's say the number is 16, and that dtc-xen is configured to use the volume group called lvm1, then this script will create /dev/lvm1/xen16 and /dev/lvm1/xen16swap. .B IMAGE_TYPE This parameter can have 2 values: either lvm or loopback. If ommited, then lvm is used. If lvm is used, then this script will create a partition using lvmcreate, otherwise it will create an image file. Both will later be used for the VPS. .SH EXAMPLE .B dtc_setup_vps_disk 04 lvm This will delete the 2 LVM partitions that were used by the VPS named xen04, the first one being the root partition, and the second one being the swap partition. .SH "VERSION" This documentation describes .B dtc_kill_vps_disk See .B http://www.gplhost.com/software-dtc-xen.html for updates. .SH "SEE ALSO" dtc_reinstall_os(8), dtc_setup_vps_disk(8) dtc-xen-0.5.17/doc/dtc_change_bsd_kernel.80000644000175000017500000000110411736663746016774 0ustar zigozigo.TH dtc_change_bsd_kernel 8 .SH NAME dtc_change_bsd_kernel \- rewrites the xen startup script with selected kernel .SH SYNOPSIS .B dtc_change_bsd_kernel .I VPS_NUMBER .I MEMORY_SIZE .I normal|install .SH DESCRIPTION .B dtc_change_bsd_kernel.sh This shell script is a part of the dtc-xen package that is to be used by the dtc panel to manage a Xen VPS server. This script generate a Xen startup file with the parameters given to the script. .SH "VERSION" This documentation describes .B dtc_change_bsd_kernel.sh See .B http://www.gplhost.com/software-dtc-xen.html for updates. dtc-xen-0.5.17/doc/dtc_reinstall_os.80000644000175000017500000002262211736663746016065 0ustar zigozigo.TH dtc_reinstall_os 8 .SH NAME dtc_reinstall_os \- reinstall an operating system in a VM .SH SYNOPSIS .B dtc_reinstall_os [ .B -v ] [ OPTIONS ] .B \-vpsid .B \-ram .B \-nic [,[,]] .B \-pass .B \-os [ \-gw ] [ \-dns [,] ] .SH DESCRIPTION .LP .I dtc-reinstall_os This shell script is a part of the dtc-xen package that is to be used by the dtc panel to manage a Xen VPS server. dtc_reinstall_os will bootstrap an operating system for you, so you can later use it in a virtual machine (a VM), otherwise called a virtual private server (a VPS). This script will be called by dtc-xen when you order it to install a VPS through the SOAP server of dtc-xen. You can as well use it directly on the shell if you don't have a DTC control panel server already setup. .LP .I Additional configuration files .IP When doing it's setup, dtc_reinstall_os will copy the file /etc/dtc-xen/authorized_keys2 into the VPS's /root/.ssh/authorized_keys2 and /root/.ssh/authorized_key, so the administrator has access to the VPS without the need of shutting it down. So it's a good idea to copy your shh public key in /etc/dtc-xen/authorized_keys2. dtc_reinstall_os will also copy /etc/dtc-xen/motd into the /etc/motd of the VPS (and /etc/motd.tail if a Debian operating system is installed), and /etc/dtc-xen/bashrc into the /root/.bashrc. Another very important configuration file is /etc/dtc-xen/dtc-xen.conf, that will hold the configuration for both this script, and the SOAP server of dtc-xen itself. .SH PARAMETERS .LP .I Parameters and options conventions .IP All parameters described here are mandatory. dtc_reinstall_os will exit if one of the parameters is missing from both the configuration file /etc/dtc-xen/dtc-xen.conf and the command line. If a parameter is on both the configuration file and the command line, then the command line has priority. The parameters not marked like [ this ] are not mandatory in the command line, if and only if, they are defined in the configuration file. If a parameter is defined in the configuration file, then it can be omitted from the command line. The parameters defined above \-like are mandatory. Options are always defined with a double minus sign, while mandatory parameters have only a single minus sign. All the parameters defined in this section (eg: PARAMETERS) are the mandatory on the command line. .LP .B -vpsid .IP ID has to be a number between 01 and 99. Each time a new VPS is created, an associated user xen will be created on the system, using /usr/bin/dtc-xen_userconsole so your users can login into the system. When they login, "xm console xen" will in fact be their shell, so they can access the physical console of the VPS using ssh. .LP .B -ram .IP This is the amount of memory in mega bytes that you want to have setup in the Xen startup file for this virtual machine. .LP .B -nic [,[,]] .IP This parameter defines the network configuration of the virtual machine, together with the \-gw option (see below). There can be as many \-nic parameter as you need. If there is more than one, then dtc_reinstall_os will setup a physical NIC configuration, and as many eth0:X virtual alias as needed to match the number of \-nic parameters on the command line. If the or parameter is missing, then the values will be taken from /etc/dtc-xen/dtc-xen.conf. It is mandatory to have at least the netmask and broadcast defined in either the command line or in the configuration file. These variables are called NETMASK and BROADCAST in /etc/dtc-xen/dtc-xen.conf. Note that each IP address will be added to the Xen startup configuration file of the virtual machine, so that you can use the anti-spoof facility of the Xen firewall (highly recommended, if you are reselling VPS). See Xen documentation on how to activate the anti-spoof feature of xend, but in short, you should use something like this: (network-script 'network-bridge antispoof=yes') while network-bridge can be replaced by the network scheme that you need. DTC-Xen will NOT touch the /etc/xen/xend-config.sxp file, it's up to you to customize it to your needs before using dtc-xen. .LP .B -gw .IP You can then specify lvm or loopback. Currently the only value the script compares to is lvm (or anything else), but this might change in the future. If omitted, then lvm loopback is used. .LP .B [ -dns [,] ] .IP This defines the default DNS to be setup in /etc/resolv.conf in the VPS that will be setup. If not present, then dtc-xen will use the file in /etc/resolv.conf of your dom0 to find the DNS to use. .LP .B -pass .IP This is the root password you wish to have setup inside the VPS. Not all operating system setup will support it, but it's still a mandatory parameter. If this parameter is not used, then the VPS will be setup without a root password, which is, as opposed to many people think, very fine. The user will just need to log into his VPS and setup the root password using the passwd utility. .LP .B -os .IP This parameter that can be debian, centos, or netbsd for a default setup of dtc-xen. It can also be set to any of the folder names present in /usr/share/dtc-xen-os, so that dtc-xen will use the setup script of the dtc-xen-os module to initialize a partition. This parameter can also be the name of any folder present in /usr/share/dtc-xen-app. These are appliances that will be installed automatically at the first boot of the VPS. They depend on the support of the unix distribution that is supported by dtc-xen, or any of the dtc-xen-os module installed in the system. .SH "OPTION" .LP If you don't set these options, then they may have to be set in /etc/dtc-xen/dtc-xen.conf. Some options can be omitted completely. .LP .B -v .IP Without \-v, dtc_reinstall_os normally outputs everything in /var/lib/dtc-xen/mnt/XX.stderr and /var/lib/dtc-xen/mnt/XX.stdout (or wherever you have set the vps mountpoint to be), to keep a log of the installation. With \-v, the redirection of standard output and error is not done. .LP .B --vnc-pass .IP VNC password for the physical console of your HVM VPS. See the Xen documentation if you don't know what is HVM or full virtualization. If this parameter is omitted, then the VPS will be setup to NOT use the VNC server (recommended when in production). .LP .B --boot-iso .IP Name of the ISO file stored in /var/lib/dtc-xen/ttyssh_home/xenXX/ folder so the VPS can be set to boot on it. If this parameter is omitted, then the VPS will boot on the hard drive. Note that your users would, in a normal scheme, upload the ISO file using FTP and the ssh physical console password they have set using DTC. The list of uploaded ISO files will then be presented in the user interface. Because these ISO files can be sometimes big, it is advised to protect your /var filesystem by using a dedicated partition for /var/lib/dtc-xen/ttyssh_home, in order to avoid that your users fill up the /var space with ISO files. .LP .B --initrd .IP Full path to the init ram disk image to setup in the startup configuration file for this VPS. This parameter is normally to be defined in /etc/dtc-xen/dtc-xen.conf as it should normally not be changed often. .LP .B --kernel .IP Full path to the kernel boot image to setup in the startup configuration file for this VPS. This parameter is normally to be defined in /etc/dtc-xen/dtc-xen.conf as it should normally not be changed often. .LP .B --kernel-release .IP Kernel release number that will be used when setting-up this VPS. To be used only if you are using the \-\-initrd and \-\-kernel options, and if the release number is different from the one of your dom0. This will be used to run a depmod \-a in the VPS partition. .LP .B --kmod-path .IP Full path to the kernel modules to be used when copying the kernel modules in the VPS. .SH "EXAMPLES" .LP .B .I Example1: .IP dtc_reinstall_os \-v \-vpsid 01 \-ram 512 \-nic 192.168.2.176,255.255.255.0,192.168.2.255 \-pass MyRootPass \-os debian \-gw 192.168.2.1 \-dns 192.168.2.1 .LP This will setup the VM called xen01, build it's startup file in /etc/xen/xen01 with a vif containing ip=192.168.2.176 and 512 MB of RAM, setting-up a debian operating system with the /etc/network/interfaces using 192.168.2.176 as IP, 255.255.255.0 as netmask, 192.168.2.255 as broadcast, 192.168.2.1 as gateway, and 192.168.2.1 as DNS. .LP .B .I Example2: .IP dtc_reinstall_os \-vpsid 02 \-ram 1024 \-nic 192.168.9.2 \-nic 192.168.9.3 \-gw 192.168.9.1 \-pass MyRootPass \-os kde-nx-server-3.3.0 .LP This will setup the VM called xen02, build it's startup file in /etc/xen/xen02 with a vif containing ip=192.168.9.2 and 192.168.9.3 and 1 GB of RAM, setting-up a debian operating system with the /etc/network/interfaces using 192.168.2.176 as IP for eth0, and eth0:1 with 192.168.9.3. The gateway 192.168.9.1 will be used for eth0, the broadcast, network, and netmask addresses will be used from the default in /etc/dtc-xen/dtc-xen.conf (as they are omitted here, it's mandatory that this config file has been edited to match your network and in order to use dtc_reinstall_os this way). The dom0 /etc/resolv.conf will be used to set the VPS's /etc/resolv.conf. .SH "SEE ALSO" dtc_setup_vps_disk(8), dtc_kill_vps_disk(8) .SH "VERSION" This documentation describes .B dtc_reinstall_os version 0.3.15. See .B http://www.gplhost.com/software-dtc-xen.html for updates. dtc-xen-0.5.17/doc/dtc_create_vps.80000644000175000017500000000074011736663746015517 0ustar zigozigo.TH dtc_create_vps.sh 8 .SH NAME dtc_create_vps.sh \- creates a virtual server .SH SYNOPSIS .B dtc_create_vps.sh .I VPS_NUMBER .I MEMORY_SIZE .I HDD_SIZE .I IP_ADDRESS [ .I DISTRO ] .SH DESCRIPTION .B dtc_create_vps.sh This shell script is a part of the dtc-xen package that is to be used by the dtc panel to manage a Xen VPS server. .SH "VERSION" This documentation describes .B dtc_create_vps.sh version 0.1.2. See .B http://www.gplhost.com/software-dtc-xen.html for updates. dtc-xen-0.5.17/doc/xm_info_free_memory.80000644000175000017500000000073611736663746016567 0ustar zigozigo.TH xm_info_free_memory 8 .SH NAME xm_info_free_memory \- This script is a part of the SOAP server of dtc-xen running over HTTPS with Auth. .SH SYNOPSIS .B xm_info_free_memory .SH DESCRIPTION .B xm_info_free_memory This shell script is a part of the dtc-xen package that is to be used by the dtc panel to manage a Xen VPS server. .SH "VERSION" This documentation describes .B xm_info_free_memory version 0.1.2. See .B http://www.gplhost.com/software-dtc-xen.html for updates. dtc-xen-0.5.17/doc/dtc-soap-server.80000644000175000017500000000213211736663746015545 0ustar zigozigo.TH dtc-soap-server 8 .SH NAME dtc-soap-server \- This is a SOAP server running over HTTPS with Auth to remotly start/stop/reinstall/fsck a VPS under Xen .SH SYNOPSIS .B dtc-soap-server [\fI-D\fR] [\fI-v\fR] .SH DESCRIPTION .B dtc-soap-server This soap server script is a part of the dtc-xen package that is to be used by the DTC control panel to manage a Xen VPS server. It will bind a soap server with auth using SSL on the port defined in /etc/dtc-xen/soap.conf. It's auth users are also defined in the /etc/dtc-xen/htpasswd, use the htpasswd utility from apache / apache2 to edit it. If you're using this server in CentOS, you can replace the SSL certificate this program uses by replacing the files named dtc-xen.* inside /etc/pki/tls. Check the README.RPM file distributed with the package for expedited instructions on how to set up an administrative password. The \-D command line option daemonizes the server. The \-v command line option elevates logging level to debug. .SH "VERSION" This documentation describes .B dtc-soap-server See .B http://www.gplhost.com/software-dtc-xen.html for updates. dtc-xen-0.5.17/doc/dtc_setup_vps_disk.80000644000175000017500000000347111736663746016432 0ustar zigozigo.TH dtc_setup_vps_disks 8 .SH NAME dtc_setup_disk \- setup LVM disks for using it as a VM .SH SYNOPSIS .B dtc_setup_vps_disk.sh .I VPS_NUMBER .I HDD_SIZE .I SWAP_SIZE [ .I lvm|loopback ] .SH DESCRIPTION .B dtc_setup_vps_disk.sh This shell script is a part of the dtc-xen package that is to be used by the dtc panel to manage a Xen VPS server. This script is used to create partitions to be used by a VPS later on. It will create a normal partition that will be used as a root disk, and a swap partition. dtc_setup_disk is to be used by the dtc-xen SOAP server, but can also be used as a standalone userland tool. If the partition(s) exists, then this script will delete it/them first. .SH OPTIONS .B VPS_NUMBER has to be a number between 01 and 19. Let's say the number is 16, and that dtc-xen is configured to use the volume group called lvm1, then this script will create /dev/lvm1/xen16 and /dev/lvm1/xen16swap. .B HDD_SIZE Size in MB of the VPS partition to create. .B SWAP_SIZE Size in MB of the VPS swap partition to create. If the dtc-xen SOAP server is used to create the VPS, then it will create a swap partition of the exact same size as the memory. .B IMAGE_TYPE This parameter can have 2 values: either lvm or loopback. If ommited, then lvm is used. If lvm is used, then this script will create a partition using lvmcreate, otherwise it will create an image file. Both will later be used for the VPS. .SH EXAMPLE .B dtc_setup_vps_disk 04 15360 256 lvm This will create 2 LVM partition to be used by the VPS named xen04, the first one being a root partition of 15 GB, and the second one being a swap partition of 256 MB. .SH "VERSION" This documentation describes .B dtc_setup_vps_disk version 0.3.15. See .B http://www.gplhost.com/software-dtc-xen.html for updates. .SH "SEE ALSO" dtc_reinstall_os(8), dtc_kill_vps_disk(8) dtc-xen-0.5.17/doc/vgdisplay_free_size.80000644000175000017500000000073611736663746016574 0ustar zigozigo.TH vgdisplay_free_size 8 .SH NAME vgdisplay_free_size \- This script is a part of the SOAP server of dtc-xen running over HTTPS with Auth. .SH SYNOPSIS .B vgdisplay_free_size .SH DESCRIPTION .B vgdisplay_free_size This shell script is a part of the dtc-xen package that is to be used by the dtc panel to manage a Xen VPS server. .SH "VERSION" This documentation describes .B vgdisplay_free_size version 0.1.2. See .B http://www.gplhost.com/software-dtc-xen.html for updates. dtc-xen-0.5.17/doc/dtc-xen-client.80000644000175000017500000000111511736663746015345 0ustar zigozigo.TH dtc-xen-client 8 .SH NAME dtc-xen-client \- tests the dtc-xen soap daemon .SH SYNOPSIS .B dtc-xen-client .SH DESCRIPTION This shell script is part of the dtc-xen package, generally to be used by the dtc panel to install a new a Xen VPS server. This script is used only to be able to test the SOAP server of DTC-Xen. .SH EXAMPLE The below will start the VPS called xen01 using the command "xm create xen01" dtc-xen-client https://dtc-xen:mypass@dtcxenserver.example.com:8089/ startVPS xen01 See .B http://www.gplhost.com/software-dtc-xen.html for updates. dtc-xen-0.5.17/doc/dtc-xen_domU_gen_xen_conf.80000644000175000017500000000071211736663746017567 0ustar zigozigo.TH dtc-xen_domU_gen_xen_conf 8 .SH NAME dtc-xen_domU_gen_xen_conf \- configure the Xen startup file of a VPS .SH DESCRIPTION .B dtc-xen_domU_gen_xen_conf This shell script is a part of the dtc-xen package that is to be used by the dtc panel to manage a Xen VPS server. When doing it's VPS install, dtc_reinstall_os will call a script to do the setup of the xen startup configuration file. See .B http://www.gplhost.com/software-dtc-xen.html for updates. dtc-xen-0.5.17/doc/dtc_install_centos.80000644000175000017500000000377211736663746016415 0ustar zigozigo.TH dtc_install_centos 8 .SH NAME dtc_install_centos \- bootstrap a CentOS install to use in a chroot or VM .SH SYNOPSIS .B dtc_install_centos .SH DESCRIPTION This shell script is part of the dtc-xen package, generally to be used by the dtc panel to install a new a Xen VPS server. This script is called by dtc_reinstall_os when the user chooses to install the CentOS operating system. How it works: it generates a temporary yum configuration in the yum environment directory, that directs yum to act inside the install root instead of in the base system; then it kindly requests yum to install the basesystem, centos-release and yum packages onto it. Yum then uses the configuration to download the required (usually, security-updated) packages and then perform the RPM installation process under the install root. It requires both RPM and yum. It does work under Debian (it was developed in Ubuntu first). It should also work on RPM-based systems without destroying the system-wide RPM and yum configurations. .SH "OPTION" .B Target directory where CentOS will be deployed. Must exist beforehand. .B Directory where yum will store the repository manifests and configuration. Will be automatically created. Cached RPMs and manifests will be left, as usual, in a directory var/cache/yum inside the install root. .SH "EXAMPLE" .B dtc_install_centos /root/yum /xen/13 This will setup the operating system in /xen/13, with the CentOS configuration folder in /root/yum. .SH "BUGS" It's limited to CentOS 5 at the moment. It must be run as root. Under some circumstances, the installation process itself may kill processes running on the host machine. The chroot yum does should be sufficient to avoid this, but we haven't been able, yet, to ascertain why this fails sometimes. .SH "SEE ALSO" dtc_reinstall_os(8) .SH "VERSION" This documentation describes .B dtc_install_os version 0.3.1. See .B http://www.gplhost.com/software-dtc-xen.html for updates. dtc-xen-0.5.17/doc/dtc-xen_domUconf_standard.80000644000175000017500000000155011736663746017606 0ustar zigozigo.TH dtc-xen_domUconf_standard 8 .SH NAME dtc-xen_domUconf_standard \- configure a debian VPS for using network .SH SYNOPSIS .B dtc-xen_domUconf_standard .I VPS_PATH .I VPSHOSTNAME .I NODE_DOMAIN_NAME .I KERNELNAME .I IPADDR .SH DESCRIPTION .B dtc-xen_domUconf_standard This shell script is a part of the dtc-xen package that is to be used by the dtc panel to manage a Xen VPS server. When doing it's VPS install, dtc_reinstall_os will call a script to do the setup of the standard things like hostname, /etc/hosts, etc. dtc-xen_domUconf_standard does the job when the VPS type is more or less standard, this can be overridden whenever needed for other types of OS. This does NOT include the setup of the network address(es) or the bootstrap of the operating system. Such tasks are performed elsewhere. See .B http://www.gplhost.com/software-dtc-xen.html for updates. dtc-xen-0.5.17/doc/dtc-xen_domUconf_network_debian.80000644000175000017500000000126111736663746021000 0ustar zigozigo.TH dtc-xen_domUconf_network_debian 8 .SH NAME dtc-xen_domUconf_network_debian \- configure a debian VPS for using network .SH SYNOPSIS .B dtc-xen_domUconf_network_debian .I VPS_PATH .I IP_ADDR .I NETMASK .I NETWORK .I BROADCAST .I GATEWAY .SH DESCRIPTION .B dtc-xen_domUconf_network_debian This shell script is a part of the dtc-xen package that is to be used by the dtc panel to manage a Xen VPS server. When doing it's VPS install, dtc_reinstall_os will call a script to do the setup of the network. dtc-xen_domUconf_network_debian does the job when the VPS type is Debian (that is: works also for Ubuntu based VPS). See .B http://www.gplhost.com/software-dtc-xen.html for updates. dtc-xen-0.5.17/deb0000755000175000017500000000210111736663746012345 0ustar zigozigo#!/bin/sh set -e set -x VERS=`head -n 1 debian/changelog | cut -d'(' -f2 | cut -d')' -f1 | cut -d'-' -f1` REL=`head -n 1 debian/changelog | cut -d'(' -f2 | cut -d')' -f1 | cut -d'-' -f2` PKGNAME=`head -n 1 debian/changelog | cut -d' ' -f1` if [ -e /etc/redhat-release ] ; then MKTEMP="mktemp -d -p /tmp" else MKTEMP="mktemp -d -t" fi TMPDIR=`${MKTEMP} ${PKGNAME}.XXXXXX` DIRNAME=${PKGNAME}-${VERS} MYCWD=`pwd` mkdir -p ${TMPDIR}/${DIRNAME} cp -auxf * ${TMPDIR}/${DIRNAME} sed -i "s/__VERSION__/${VERS}/" ${TMPDIR}/${DIRNAME}/${PKGNAME}.spec mv ${TMPDIR}/${DIRNAME}/debian ${TMPDIR} rm -rf ${TMPDIR}/${DIRNAME}/.git cd ${TMPDIR} tar -czf ${PKGNAME}_${VERS}.orig.tar.gz ${DIRNAME} mv debian ${TMPDIR}/${DIRNAME} cd ${DIRNAME} if [ "${1}" = "--sign" ] ; then dpkg-buildpackage else dpkg-buildpackage -uc -us fi cd ${MYCWD} mv ${TMPDIR}/${PKGNAME}_${VERS}.orig.tar.gz .. mv ${TMPDIR}/${PKGNAME}_${VERS}-${REL}.dsc .. mv ${TMPDIR}/${PKGNAME}_${VERS}-${REL}.diff.gz .. mv ${TMPDIR}/${PKGNAME}*_${VERS}-${REL}*.deb .. mv ${TMPDIR}/${PKGNAME}*_${VERS}-${REL}*.changes .. rm -rf ${TMPDIR} dtc-xen-0.5.17/dist0000755000175000017500000000121111736663746012557 0ustar zigozigo#!/bin/sh set -e set -x VERS=`head -n 1 debian/changelog | cut -d'(' -f2 | cut -d')' -f1 | cut -d'-' -f1` PKGNAME=`head -n 1 debian/changelog | cut -d' ' -f1` if [ -e /etc/redhat-release ] ; then MKTEMP="mktemp -d -p /tmp" else MKTEMP="mktemp -d -t" fi TMPDIR=`${MKTEMP} ${PKGNAME}.XXXXXX` DIRNAME=${PKGNAME}-${VERS} MYCWD=`pwd` mkdir -p ${TMPDIR}/${DIRNAME} cp -auxf * ${TMPDIR}/${DIRNAME} sed -i "s/__VERSION__/${VERS}/" ${TMPDIR}/${DIRNAME}/${PKGNAME}.spec rm -rf ${TMPDIR}/${DIRNAME}/debian rm -rf ${TMPDIR}/${DIRNAME}/.git cd ${TMPDIR} tar -czf ${DIRNAME}.tar.gz ${DIRNAME} cd ${MYCWD} mv ${TMPDIR}/${DIRNAME}.tar.gz .. rm -rf ${TMPDIR} dtc-xen-0.5.17/src/0000755000175000017500000000000011736663746012462 5ustar zigozigodtc-xen-0.5.17/src/xm_info_free_memory0000755000175000017500000000010611736663746016435 0ustar zigozigo#!/bin/sh xm info | grep free_memory | cut -d':' -f2 | cut -d' ' -f2 dtc-xen-0.5.17/src/dtc-soap-server0000755000175000017500000007502211736663746015434 0ustar zigozigo#!/usr/bin/env python import sys, traceback sys.path.append("/usr/lib/xen/lib/python/") sys.path.append( '/usr/lib/python' ) #Required to import from /usr/lib/python for FC4 sys.path.append( '/usr/share/dtc-xen' ) import os import SOAPpy import commands from StringIO import StringIO from SOAPpy import * import logging from logging.handlers import SysLogHandler import threading import glob import signal try: import subprocess # FIXME maybe this wont work on older pythons? except ImportError: subprocess = False from M2Crypto import SSL import crypt from Properties import * from threading import Thread,RLock from subprocess import Popen,PIPE import re import time import pickle # some global variables run_as_daemon = None last_signal = None SOAPpy.Config.debug=1 server_host = None server_port = None cert_passphrase = None dtcxen_user = None server_lvmname = None vpsimage_mount_point = None perfdata_dir = None tabsplitter = None tabcolonsplitter = None data_collection_lock = None keepRunning = 1 # Detect the virtualization environment virt_type = None if os.path.isdir('/proc/xen') == True: virt_type = 'xen' if os.path.isdir('/proc/vz') == True: virt_type = 'vz' def sighandler(signum,frame): global last_signal last_signal = signum if last_signal == signal.SIGHUP: try: logging.info("Logging restarting...") logging.shutdown() setup_logging() except Exception,e: logging.exception("Trapped exception in function call. Thread: %s",threading.currentThread()) raise if last_signal == signal.SIGTERM: shutdown() if last_signal == signal.SIGINT: shutdown() def shutdown(error=0): global run_as_daemon global last_signal logging.info("Shutting down due to signal %s..."%last_signal) if run_as_daemon: try: os.unlink("/var/run/dtc-xen.pid") except: pass for a in [sys.stdout,sys.stderr]: if a: try: a.flush() except: pass logging.info("DTC SOAP server shut down") logging.shutdown() sys.exit(error) # A generalized decorator for logging exceptions def log_exceptions(f): def func(*args,**kwargs): try: logging.debug("Calling function %s(%s,%s)",f.func_name,args,kwargs) ret = f(*args,**kwargs) logging.debug("Function returned %s",ret) return ret except Exception,e: logging.exception("Trapped exception in function call %s. Thread: %s",f,threading.currentThread()) raise func.func_name = f.func_name return func def firstexisting(list): for m in list: if os.path.exists(m): return m def firsttrue(list): for m in list: if m: return m def provisioning_volgroup(): return subprocess.Popen(["dtc-xen-volgroup"], stdin=None,stdout=subprocess.PIPE, stderr=None,close_fds=True).communicate()[0].strip() # ---------------- daemon starts here ---------------------- run_as_daemon = len(sys.argv) > 1 and "-D" in sys.argv[1:] debug_logging = len(sys.argv) > 1 and "-v" in sys.argv[1:] def setup_logging(): global debug_logging global run_as_daemon if debug_logging: log_level = logging.DEBUG else: log_level = logging.INFO # nuke the old handlers -- they cause problems if kept registered after daemonization del logging.getLogger().handlers[:] if run_as_daemon: oldumask = os.umask(31) try: logging.basicConfig(filename="/var/log/dtc-xen.log",level=log_level,format='%(asctime)s %(levelname)s %(message)s') h = logging.StreamHandler() h.setLevel(logging.WARN) logging.getLogger().addHandler(h) except IOError: # oops, the log file could not be opened # just log everything to stderr logging.basicConfig(level=log_level) os.umask(oldumask) else: logging.basicConfig(level=log_level) # debug because started foreground def startup(): setup_logging() logging.info("Starting DTC SOAP server...") #if not os.path.exists("/proc/xen/privcmd"): # logging.error("/proc/xen/privcmd is not accessible, cannot start dtc-xen") # shutdown(1) # import xm stuff #import xen.xm.main # read config file config_file = firstexisting(['/etc/dtc-xen/dtc-xen.conf','/etc/dtc-xen/soap.conf']) p=Properties() p.load(open(config_file)) gp = p.getProperty global server_host,server_port,cert_passphrase,dtcxen_user,server_lvmname,vpsimage_mount_point server_host= firsttrue([ gp(x) for x in ["soap_server_host","listen_address"] ]) server_port= int(firsttrue([ gp(x) for x in ["soap_server_port","listen_port"] ])) cert_passphrase= firsttrue([ gp(x) for x in ["soap_server_pass_phrase","cert_passphrase"] ]) dtcxen_user=firsttrue([ gp(x) for x in ["soap_server_dtcxen_user","admin_user"] ]) server_lvmname=provisioning_volgroup() vpsimage_mount_point=firsttrue([ gp(x) for x in [ "soap_server_mount_point", "provisioning_mount_point"] ]) del gp logging.info("Server using this configuration:") logging.info(" Configuration file: %s"%config_file) logging.info(" Listen address: %s"%server_host) logging.info(" Listen port: %s"%server_port) if cert_passphrase: logging.info(" Certificate passphrase: present") else: logging.info(" Certificate passphrase: not configured") logging.info(" Administrator user: %s"%dtcxen_user) logging.info(" Provisioning from LVM volume group: %s"%server_lvmname) logging.info(" Provisioning mount point: %s"%vpsimage_mount_point) # --------------------- now we define the functions the daemon serves ------ logging.info("Start to define functions...") def testVPSServer(*varargs): if not varargs: return "OK" else: return varargs def startVPS(vpsname): username = getUser() if username == dtcxen_user or username == vpsname: if virt_type == 'xen': # Lookup the database to see if we are running a process (mkfs/fsck/etc...) on the VM instance... xmargs=['foo', 'create', vpsname] logging.info("Starting VPS %s",vpsname) localsyserr = '' localsysout = '' try: localsysout,localsyserr = subprocess.Popen(["/usr/sbin/xm","create",vpsname],stdin=None,stdout=subprocess.PIPE,stderr=subprocess.PIPE,close_fds=True).communicate() logging.info("VPS %s started",vpsname) return "OK","Started %s" % vpsname except: # this is a HACK. It should also not capture BaseException. returnString = "NOTOK - %s %s" % (localsyserr, localsysout) logging.exception("VPS %s failed to start",vpsname) return returnString elif virt_type == 'vz': vzname = '1%s' % vpsname[3,5] vzctlargs=['foo', 'create', vpsname] try: localsysout,localsyserr = subprocess.Popen(["/usr/sbin/vzctl","start",vzname],stdin=None,stdout=subprocess.PIPE,stderr=subprocess.PIPE,close_fds=True).communicate() logging.info("VPS %s started",vpsname) return "OK","Started %s" % vpsname except: returnString = "NOTOK - %s %s" % (localsyserr, localsysout) logging.exception("VPS %s failed to start",vpsname) return returnString else: return "NOTOK" else: return "NOTOK" def destroyVPS(vpsname): username = getUser() if username == dtcxen_user or username == vpsname: xmargs=['foo','destroy',vpsname] logging.info("Destroying VPS %s", vpsname) localsyserr = '' localsysout = '' try: localsysout,localsyserr = subprocess.Popen(["/usr/sbin/xm","destroy",vpsname],stdin=None,stdout=subprocess.PIPE,stderr=subprocess.PIPE,close_fds=True).communicate() logging.info("VPS %s destroyed",vpsname) return "OK","Destroyed %s" % vpsname except: returnString = "NOTOK - %s %s" % (localsyserr, localsysout) logging.exception("VPS %s failed to be destroyed",vpsname) return returnString else: return "NOTOK" def killVPS(vpsname,imagetype='lvm'): username = getUser() if username == dtcxen_user or username == vpsname: logging.info("Destroying vps xen%s VPS partitions", vpsname) cmd = "/usr/sbin/dtc_kill_vps_disk %s %s" % (vpsname, imagetype) output = commands.getstatusoutput(cmd) logging.debug("Command stdout: %s",cmd) else: return "NOTOK" def shutdownVPS(vpsname): username = getUser() if username == dtcxen_user or username == vpsname: xmargs=['foo','shutdown',vpsname] logging.info("Shutting VPS %s down", vpsname) localsyserr = '' localsysout = '' try: localsysout,localsyserr = subprocess.Popen(["/usr/sbin/xm","shutdown",vpsname],stdin=None,stdout=subprocess.PIPE,stderr=subprocess.PIPE,close_fds=True).communicate() logging.info("VPS %s shut down",vpsname) return "OK","Shut down %s" % vpsname except: returnString = "NOTOK - %s %s" % (localsyserr, localsysout) logging.exception("VPS %s failed to shut down",vpsname) return returnString else: return "NOTOK" def infoVPS(vpsname): username = getUser() if username == dtcxen_user or username == vpsname: infos=['vpsname'] return "OK",infos else: return "NOTOK" def listStartedVPS(): global tabsplitter username = getUser() if username == dtcxen_user: # Bellow is the new tested and working code domains = ( tabsplitter(d.strip())[:6] for d in Popen(["/usr/sbin/xm","list"],stdout=PIPE).communicate()[0].splitlines()[1:] if d.strip() ) domlist=[] for domain in domains: if (domain[0]!="Domain-0"): domlist.insert(1,domain) domlist.sort() return (domlist) else: return "NOTOK" def changeVPSxmPassword(vpsname,password): username = getUser() if username == dtcxen_user or username == vpsname: output = commands.getstatusoutput("(echo %s; sleep 1; echo %s;) | passwd %s" % (password,password,vpsname)) return "OK" else: return "NOTOK" def changeVPSsoapPassword(vpsname,password): username = getUser() if username == dtcxen_user or username == vpsname: # FIXME EGREGIOUS SECURITY ERROR, EVERYWHERE WHERE COMMANDS MODULE IS USED output = commands.getstatusoutput("htpasswd -b /etc/dtc-xen/htpasswd %s %s" % (vpsname,password)) return "OK" else: return "NOTOK" def changeVPSsshKey(vpsname,keystring): username = getUser() if username == dtcxen_user or username == vpsname: try: # create the directory if it doesn't exist if not os.path.isdir("/var/lib/dtc-xen/ttyssh_home/%s/.ssh/" % vpsname): os.makedirs("/var/lib/dtc-xen/ttyssh_home/%s/.ssh/" % vpsname) os.chown("/var/lib/dtc-xen/ttyssh_home/%s/.ssh/" % vpsname, getuserid(vpsname), getusergroup(vpsname)) # open file stream filename = "/var/lib/dtc-xen/ttyssh_home/%s/.ssh/authorized_keys" % vpsname file = open(filename, "w") file.write(keystring) file.close() os.chown(filename, getuserid(vpsname), getusergroup(vpsname)) # In case we are using authorized_keys2, we do it a 2nd time. filename = "/var/lib/dtc-xen/ttyssh_home/%s/.ssh/authorized_keys2" % vpsname file = open(filename, "w") file.write(keystring) file.close() os.chown(filename, getuserid(vpsname), getusergroup(vpsname)) except IOError: return "NOTOK - There was an error writing to", filename return "OK" else: return "NOTOK" def fsckVPSpartition(vpsname): username = getUser() if username == dtcxen_user or username == vpsname: filename = "/var/lib/dtc-xen/states/%s" % vpsname status = getVPSState(vpsname) if status != "Not running": logging.warn("Status isn't good, we are already in process, or actually live") return "NOTOK, %s" % status # Write the semaphore file before proceeding fd2 = open(filename, 'w') fd2.write("fsck\n") logging.info("Starting file system check for %s",vpsname) cmd = "/sbin/fsck.ext3" args = [cmd, "-p","/dev/lvm1/%s" % vpsname ] spawnedpid = os.spawnv(os.P_NOWAIT, cmd, args ) fd2.write("%s\n" % spawnedpid) fd2.close() return "OK" return "NOTOK" def changeBSDkernel(vpsname,ramsize,kerneltype,allipaddrs): username = getUser() if username == dtcxen_user or username == vpsname: logging.info("Changing kernel of a BSD VM: vps: %s ram: %s kernel: %s",vpsname,ramsize,kerneltype) cmd = "dtc_change_bsd_kernel %s %s %s '%s'" % (vpsname,ramsize,kerneltype,allipaddrs) print cmd output = commands.getstatusoutput(cmd) return "OK" def writeXenHVMconf(vpsname,ramsize,allipaddrs,vncpassword,howtoboot): username = getUser() if username == dtcxen_user or username == vpsname: cmd = "dtc_write_xenhvm_conf %s %s '%s' %s %s" % (vpsname,ramsize,allipaddrs,vncpassword,howtoboot) logging.info("Now calling: %s" % cmd) print cmd output = commands.getstatusoutput(cmd) return "OK" def reportInstalledIso(vpsname): username = getUser() if username == dtcxen_user or username == vpsname: path = "/var/lib/dtc-xen/ttyssh_home/%s"%vpsname files = [ os.path.basename(f) for f in glob.glob(path+"/*.iso") if os.path.isfile(f) ] return files def reinstallVPSos(vpsname,ostype,ramsize,password,nics=None,gateway=None,dns=None): # Take care! This time, the vpsname has to be only the number (eg XX and not xenXX) # nicspecs is a series of NIC specifications username = getUser() if username == dtcxen_user or username == vpsname: logging.info("Reinstalling %s on VPS %s",ostype,vpsname) #maybe these should be notices if notices are below info severity filename = "/var/lib/dtc-xen/states/xen%s" % vpsname logging.debug("Checking %s for mkos",vpsname) status = getVPSState("xen%s" % vpsname) if status != "Not running": return "NOTOK, %s" % status # Write the semaphore file before proceeding fd2 = open(filename, 'w') fd2.write("mkos\n") log = file("%s/%s.log" % (vpsimage_mount_point, vpsname),"w",0) # FIXME idea: we could reuse the log isntead of a file, a stringio or something that reflects all the log activity into the logging module # that way everything goes into /var/log/dtc-soap-server.log # brilliant? you be the judge args = ["/usr/sbin/dtc_reinstall_os", "-v", "-vpsid", vpsname, "-ram", ramsize, "-os", ostype ] if gateway: args = args + [ "-gw", gateway ] if dns: args = args + [ "-dns", dns ] if type(nics) in (str,unicode): if "+" in nics: nics = [ s.strip() for s in nics.split("+") if s.strip() ] else: nics = [ s.strip() for s in nics.split("\n") if s.strip() ] if nics: nicargs = [] for nic in nics: nicargs.append("-nic") nicargs.append(nic) args = args + nicargs newenv = os.environ.copy() newenv['PASSWORD'] = password logging.debug("Running %s in subprocess",args) if subprocess: proc = subprocess.Popen(args,stdout=log,stderr=subprocess.STDOUT,close_fds=True,cwd="/",env=newenv) spawnedpid = proc.pid def wait_for_child(): # watcher thread target try: proc.wait() if proc.returncode != 0: level = logging.warn else: level = logging.debug level("Subprocess %s (PID %s) is done -- return code: %s", threading.currentThread().getName(),proc.pid,proc.returncode) except: logging.exception("Watcher thread %s died because of exception",threading.currentThread().getName()) raise watcher = threading.Thread(target=wait_for_child,name="dtc_reinstall_os watcher for xen%s"%vpsname) watcher.setDaemon(True) watcher.start() logging.debug("Subprocess %s (PID %s) started and being watched",watcher.getName(),spawnedpid) else: spawnedpid = os.spawnv(os.P_NOWAIT, cmd, args ) fd2.write("%s\n" % spawnedpid) fd2.close() logging.info("Reinstallation process launched") return "OK, started mkos." return "NOTOK" def setupLVMDisks(vpsname,hddsize,swapsize,imagetype='lvm'): username = getUser() if username == dtcxen_user or username == vpsname: logging.info("Starting disk setup for xen%s: %s HHD, %s SWAP, %s imagetype",vpsname,hddsize,swapsize,imagetype) cmd = "/usr/sbin/dtc_setup_vps_disk %s %s %s %s" % (vpsname,hddsize,swapsize,imagetype) output = commands.getstatusoutput(cmd) # FIXME THIS IS FAIL -- it doesnt get stderr logging.debug("Command stdout: %s",cmd) return "OK" else: return "NOTOK" def getuserid(user): import pwd if isinstance(user, int): return user entry = pwd.getpwnam(user) return entry[2] def getusergroup(user): import pwd import grp return grp.getgrgid(pwd.getpwnam(user)[3])[2] def getgroupid(group): import grp if isinstance(group, int): return group entry = grp.getgrnam(group) return entry[2] def startup2(): global perfdata_dir,data_collection_lock,perfdata_dir,tabsplitter,tabcolonsplitter logging.info("Finished defining functions.") tabsplitter = re.compile("[\t ]+").split tabcolonsplitter = re.compile("[\t :]+").split data_collection_lock = RLock() perfdata_dir = os.path.join("/","var","lib","dtc-xen","perfdata") logging.info("Setup Performance Data directory at %s" % perfdata_dir) class Server(Thread): def __init__(self,server): Thread.__init__(self,name="Server thread") self.server = server self.setDaemon(True) @log_exceptions def run(self): logging.info("Starting server thread") while True: try: self.server.serve_forever() except Exception: logging.exception("Server thread died, restarting") class DataCollector(Thread): global data_collection_lock def __init__(self): Thread.__init__(self,name="Data collector thread") self.setDaemon(True) @log_exceptions def run(self): """Saves a sample to path perfdata_dir prototype sample: { "xen01" : { "timestamp":1237287382.45, "diff_cpu_time":51.5, # cputime "diff_net_inbytes":838375767, # network bytes in "diff_net_outbytes":324328402389, # network bytes out "diff_filesystem_sectors":5134, # fs sectors "diff_swap_sectors":5134, # fs sectors ... }, "xen02" : { "timestamp":1237287382.45, "diff_cpu_time":51.5, # cputime "diff_net_inbytes":838375767, # network bytes in "diff_net_outbytes":324328402389, # network bytes out "diff_filesystem_sectors":5134, # fs sectors "diff_swap_sectors":5134, # fs sectors ... }, } each item in the sample dictionary is keyed by node name, and its value contains: timestamp: time.time() output diff_cpu_time: differential CPU time, as a float (cputime column in xm list) diff_net_*bytes: differential network bytes for the first network device assigned to it, by Xen ID diff_*_sectors: differential total disk blocks read + written (both swap and file partition accesses) """ logging.info("Starting data collection thread") # load latest data file try: dictionary = pickle.load(file(os.path.join(perfdata_dir,"last-sample.pickle"))) except IOError,e: if e.errno == 2: dictionary = {} else: raise while True: started_time = time.time() global tabsplitter old_dictionary,dictionary = dictionary,{} domains = ( tabsplitter(d.strip()) for d in Popen(["/usr/sbin/xm","list"], stdout=PIPE).communicate()[0].splitlines()[2:] if d.strip() ) procnetdev_readout = file("/proc/net/dev").readlines() for domain in domains: name,xid,mem,cpu,state,cpu_time=domain[0:6] cpu_time = float(cpu_time) # if cpu time was measured the last time, and it was less than this one, get the difference findvif = [ re.sub("sdkljflsdkjfsdlfj.*:","",o).strip() for o in procnetdev_readout if o.startswith("vif%s.0:"%xid) ] # handle the condition where the vif interface isn't up yet, or has been shutdown if len(findvif) > 0: vifdiscard,net_inbytes,a,a,a,a,a,a,a,net_outbytes,a,a,a,a,a,a,a=tabcolonsplitter( findvif [0] ) else: logging.info("Could not find vif%s.0!"%xid) net_inbytes,net_outbytes = int(net_inbytes),int(net_outbytes) def get_blocks_dm(minor): line = file("/sys/block/dm-%s/stat" % minor,'r').readline().split() return int(line[2]) + int(line[6]) try: filesystem_sectors = get_blocks_dm( os.minor(os.stat("/dev/mapper/%s-%s" % (server_lvmname,name)).st_rdev) ) except OSError,e: if e.errno == 2: filesystem_sectors = 0 else: raise try: swap_sectors = get_blocks_dm( os.minor(os.stat("/dev/mapper/%s-%sswap" % (server_lvmname,name)).st_rdev) ) except OSError,e: if e.errno == 2: swap_sectors = 0 else: raise # now we account for the difference if it is the sensible thing to do dictionary[name] = { "timestamp":started_time, "diff_cpu_time":cpu_time, "diff_net_inbytes":net_inbytes, "diff_net_outbytes":net_outbytes, "diff_filesystem_sectors":filesystem_sectors, "diff_swap_sectors":swap_sectors, "cpu_time":cpu_time, "net_inbytes":net_inbytes, "net_outbytes":net_outbytes, "filesystem_sectors":filesystem_sectors, "swap_sectors":swap_sectors, } # compute differences if name in old_dictionary: for reading in "cpu_time,net_inbytes,net_outbytes,filesystem_sectors,swap_sectors".split(","): # we basically diff old and new unless old is bigger than new if old_dictionary[name][reading] <= dictionary[name][reading]: dictionary[name]["diff_"+reading] = dictionary[name][reading] - old_dictionary[name][reading] try: data_collection_lock.acquire() try: os.mkdir(perfdata_dir) except OSError,e: if e.errno != 17: raise pickle.dump(dictionary,file(os.path.join(perfdata_dir,"last-sample.pickle"),"w")) pickle.dump(dictionary,file(os.path.join(perfdata_dir,"sample-%s.pickle"%time.time()),"w")) finally: data_collection_lock.release() elapsed_time = time.time() - started_time logging.info("Sample data collected. Collection time: %s seconds"%elapsed_time) time.sleep(60 - elapsed_time) def getCollectedPerformanceData(count=None): """Returns a list with the latest samples collected by the DataCollector, then removes them from the disk. If the count argument is specified, it fetches then deletes a maximum of samples, in chronological order. This allows for batched data fetches. """ username = getUser() if username == dtcxen_user: logging.info("getCollectedPerformanceData called.") samples = [] try: data_collection_lock.acquire() loadfiles = glob.glob(os.path.join(perfdata_dir,"sample-*.pickle")) loadfiles.sort() if count > 0: loadfiles = loadfiles[:count] samples = [ pickle.load(file(p)) for p in loadfiles ] for p in loadfiles: os.unlink(p) finally: data_collection_lock.release() return samples else: return "NOTOK" def getVPSState(vpsname): username = getUser() if username == dtcxen_user or username == vpsname: # fixme: sed upon rpm build time to set the correct path for /var/lib filename = "/var/lib/dtc-xen/states/%s" % vpsname logging.debug("Checking %s for getVPSState", filename) try: logging.debug("Opening %s" , filename) fd = open(filename, 'r') command = fd.readline() logging.debug( "Checking fsck") if string.find(command,"fsck") != -1: fsckpid = int(fd.readline()) logging.debug( "fsck process meant to be at %s" , fsckpid) try: returnstatus = os.waitpid(fsckpid, os.WNOHANG) if returnstatus[1] == 0: logging.debug( "Founded running fsck!") fd.close() return "fsck" else: logging.debug( "Status is %s" , returnstatus[1]) except: logging.debug( "Failed to find running process... delete state file...") fd.close() os.remove(filename) else: logging.debug( "Checking mkos") if string.find(command,"mkos") != -1: mkospid = int(fd.readline()) logging.debug( "mkos process meant to be at %s" , mkospid) try: returnstatus = os.waitpid(mkospid, os.WNOHANG) if returnstatus[1] == 0: logging.debug( "Founded running mkos!") fd.close() return "mkos" else: logging.debug( "Status is %s" , returnstatus[1]) except: logging.debug( "Failed to find running process... delete state file...") fd.close() os.remove(filename) else: logging.debug( "Invalid state file...") fd.close() return "NOTOK, invalid state file" except IOError,e: # FIXME WHY is this trapped? if e.errno == 2: logging.debug("No semaphore (fsck/mkos): continuing") else: raise output,error = subprocess.Popen(["/usr/sbin/xm","list",vpsname], stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate() if error: return "Not running" values = [ s.strip() for s in output.splitlines() ][-1].split() names = ["id","domid","maxmem","vcpus","state","cpuseconds"] info = dict( zip(names,values) ) for val in "maxmem vcpus domid".split(): info[val] = int(info[val]) for val in "cpuseconds".split(): info[val] = float(info[val]) thelist = ["domain"] thelist.extend( [ i for i in info.items() ] ) return thelist else: return "NOTOK" def getVPSInstallLog(vpsname,numlines): username = getUser() if username == dtcxen_user or username == vpsname: log = file("%s/%s.log" % (vpsimage_mount_point, vpsname),"r").readlines() numlines = int(numlines) if not numlines or numlines < 0: lastlines = "\n".join(log) else: lastlines = "\n".join(log[-numlines:]) def toascii(char): if ord(char) in [10,13] or 32 <= ord(char) <= 127: return char return " " lastlines = "".join([ toascii(c) for c in lastlines ]) return lastlines else: return "NOTOK" def getInstallableOS(): folderlist = os.listdir('/usr/share/dtc-xen-os/') return folderlist def getInstallableAPP(): folderlist = os.listdir('/usr/share/dtc-xen-app/') return folderlist def startup3(): # ask for returned SOAP responses to be converted to basic python types Config.simplify_objects = 1 # specify name of authorization function Config.authMethod = "_authorize" def getUser(): c = GetSOAPContext() # get authorization info from HTTP headers ah = c.httpheaders.get("Authorization","") if ah: # decode and analyze the string for the username and password # (we slice the string from 6 onwards to remove the "Basic ") username, password = base64.decodestring(ah[6:].strip()).split(":") return username else: return 0 def isUserValid(vpsname): username = getUser() if vpsname == username: logging.debug( "Valid user: %s", username) return 1 else: return 0 def _authorize(*args, **kw): global Config logging.debug( "_authorize called..." ) c = kw["_SOAPContext"] logging.debug( "**kw =%s" , str(kw) ) # The socket object, useful for logging.debug( "Peer connected: %s", c.connection.getpeername() ) # get authorization info from HTTP headers ah = c.httpheaders.get("Authorization","") if not ah: logging.debug("NO authorization information in HTTP headers, refusing.") return 0 # decode and analyze the string for the username and password # (we slice the string from 6 onwards to remove the "Basic ") try: username, password = base64.decodestring(ah[6:].strip()).split(":") except ValueError: # moron user did not specify the user name and password logging.debug("NO password information in HTTP headers, refusing.") return 0 logging.debug("Loading /etc/dtc-xen/htpasswd...") fd = open('/etc/dtc-xen/htpasswd', 'r') for line in fd: u, h = line.strip().split(':') if u == username: verify_pass = crypt.crypt(password, h[:2]) if verify_pass == h: fd.close() logging.debug( "Password matches the one in the file!") return 1 else: fd.close() logging.debug("Password didn't match the one in .htpasswd") return 0 logging.debug("Couldn't find user in password file!") return 0 def _passphrase(cert): logging.debug("Pass phrase faked...") return cert_passphrase def main(argv=None): startup() startup2() startup3() if not Config.SSLserver: ### This is wrong. IT should just raise Import Error. FIXME raise RuntimeError, "this Python installation doesn't have OpenSSL and M2Crypto" logging.info("Starting SSL context to secure webservice...") ssl_context = SSL.Context() ssl_context.load_cert(firstexisting(['/etc/dtc-xen/dtc-xen.cert.cert','/etc/pki/tls/certs/dtc-xen.crt']), firstexisting(['/etc/dtc-xen/privkey.pem','/etc/pki/tls/private/dtc-xen.key']), callback=_passphrase) logging.info("Starting SOAP server to serve webserivce requests...") soapserver = SOAPpy.SOAPServer((server_host, server_port), ssl_context = ssl_context) # No ssl # soapserver = SOAPpy.SOAPServer((server_host, server_port)) #let's make some functions log exceptions, arguments and retvalues for f in [startVPS,destroyVPS,reinstallVPSos,getVPSState,getCollectedPerformanceData]: f = log_exceptions(f) # this is required because really really really old python versions don't support decorators logging.info("Register functions with the SOAP server...") soapserver.registerFunction(_authorize) soapserver.registerFunction(testVPSServer) soapserver.registerFunction(startVPS) soapserver.registerFunction(destroyVPS) soapserver.registerFunction(shutdownVPS) soapserver.registerFunction(killVPS) soapserver.registerFunction(listStartedVPS) soapserver.registerFunction(getVPSState) soapserver.registerFunction(changeVPSxmPassword) soapserver.registerFunction(changeVPSsoapPassword) soapserver.registerFunction(changeVPSsshKey) soapserver.registerFunction(reportInstalledIso) soapserver.registerFunction(reinstallVPSos) soapserver.registerFunction(fsckVPSpartition) soapserver.registerFunction(changeBSDkernel) soapserver.registerFunction(writeXenHVMconf) soapserver.registerFunction(setupLVMDisks) soapserver.registerFunction(getCollectedPerformanceData) soapserver.registerFunction(getInstallableOS) soapserver.registerFunction(getVPSInstallLog) soapserver.registerFunction(getInstallableAPP) if run_as_daemon: # Daemonize requested. Daemonize and write pid file to /var/run/dtc-xen.pid logging.info("Attempting to daemonize...") import daemon # unconditionally close stdin/stdout/stderr, otherwise yum reinstall fails for fd in [0,1,2]: try: os.close(fd) except OSError: pass daemon.daemonize() pid = os.getpid() pidfile =file("/var/run/dtc-xen.pid","w") pidfile.write("%s"%pid) pidfile.close() logging.info("Daemonization successful -- running with PID %s"%pid) else: logging.info("Not running as a daemon (running as a normal process)") signal.signal(signal.SIGINT,sighandler) signal.signal(signal.SIGTERM,sighandler) signal.signal(signal.SIGHUP,sighandler) collector = DataCollector() collector.start() server = Server(soapserver) server.start() global keepRunning while keepRunning == 1: signal.pause() shutdown() if __name__ == "__main__": # enable the below to trace the main server process #import sys #import trace # create a Trace object, telling it what to ignore, and whether to # do tracing or line-counting or both. #tracer = trace.Trace( #ignoredirs=[sys.prefix, sys.exec_prefix], #trace=1, #count=1) # run the new command using the given tracer #tracer.run('main()') # make a report, placing output in /tmp #r = tracer.results() #r.write_results(show_missing=True, coverdir="/tmp") # cleanly run main() and handle exits sys.exit(main()) dtc-xen-0.5.17/src/dtc_write_xenhvm_conf0000755000175000017500000000731611736663746016775 0ustar zigozigo#!/bin/sh set -e USAGE="Usage: $0 Where allipaddrs is of the form '1.2.3.4 1.2.3.5' (eg: separated by space), and howtoboot is 'name.iso' in /var/lib/dtc-xen/ttyssh_home/xenXX or 'hdd'" if [ $# -lt 5 ]; then echo $USAGE fi # Source the configuration in the config file! if [ -f /etc/dtc-xen/dtc-xen.conf ] ; then . /etc/dtc-xen/dtc-xen.conf fi # Figure out the LVM name from dtc-xen.conf LVMNAME=`dtc-xen-volgroup` [ -z "$LVMNAME" ] && { echo "Could not determine volume group from which to provision the volume" 1>&2 echo "You might want to set provisioning_volgroup in dtc-xen.conf" 1>&2 exit 78 } FSTAB_LVMNAME=`echo ${LVMNAME} | sed -e 's/-/--/g'` # Figure out the VPS mount point if [ -n "$provisioning_mount_point" ] then VPSGLOBPATH="$provisioning_mount_point" else VPSGLOBPATH="$VPS_MOUNTPOINT" fi INSTALL_KERNELPATH="/boot/netbsd-INSTALL_XENU" NORMAL_KERNELPATH="/boot/netbsd-XENU" # Get parameters from command line VPSNUM=$1 VPSNAME=xen${VPSNUM} VPSHOSTNAME=xen${NODE_NUM}${VPSNUM} RAMSIZE=$2 ALL_IPADDRS=$3 VNC_PASSWORD=$4 HOW_TO_BOOT=$5 MAC_ADDR=${vps_mac_prefix}:${VPSNUM} if [ ! -z "${MAC_ADDR}" ] ; then XEN_WRITE_MAC="mac=${MAC_ADDR}, " else XEN_WRITE_MAC="" fi XEN_BR=${bridge} if [ ! -z "${XEN_BR}" ] ; then BRIDGE_DIRECTIVE=", bridge=${XEN_BR}" else BRIDGE_DIRECTIVE="" fi if [ ! -z "${VCPUS}" ] ; then VCPUSSET="vcpus=${VCPUS}" else VCPUSSET="vcpus=1" fi if [ ! -z "${MAXMEM}" ] ; then MAXMEMSET="maxmem=${MAXMEM}" else MAXMEMSET="" fi if [ ! -z "${PAE}" ] ; then PAESET="pae=${PAE}" else PAESET="" fi if [ ! -z "${ACPI}" ] ; then ACPISET="acpi=${ACPI}" else ACPISET="" fi if [ ! -z "${APIC}" ] ; then APICSET="apic=${APIC}" else APICSET="" fi if [ ! -z "${KEYMAP}" ] ; then KEYMAPSET="keymap='${KEYMAP}'" else KEYMAPSET="" fi if [ ! -z "${CPUS}" ] ; then CPUSSET="cpus=${CPUS}" else CPUSSET="" fi if [ ! -z "${CPUCAP}" ] ; then CPUCAPSET="cpu_cap=${CPUCAP}" else CPUCAPSET="" fi if [ ! -z "${CPUWEIGHT}" ] ; then CPUWEIGHTSET="cpu_weight=${CPUWEIGHT}" else CPUWEIGHTSET="" fi if [ -f /usr/lib/xen-default/boot/hvmloader ] ; then HVMLOADER=/usr/lib/xen-default/boot/hvmloader elif [ -f /usr/lib/xen/boot/hvmloader ] ; then HVMLOADER=/usr/lib/xen/boot/hvmloader fi echo -n "kernel = \"${HVMLOADER}\" builder = 'hvm' memory = ${RAMSIZE} name = \"${VPSNAME}\" ${CPUSSET} ${CPUCAPSET} ${CPUWEIGHTSET} ${VCPUSSET} ${MAXMEMSET} ${PAESET} ${ACPISET} ${APICSET} ${KEYMAPSET} vif = [ 'type=ioemu, ${XEN_WRITE_MAC}ip=${ALL_IPADDRS}${BRIDGE_DIRECTIVE}' ] disk=[ 'phy:/dev/mapper/${FSTAB_LVMNAME}-xen${VPSNUM},ioemu:hda,w'" >/etc/xen/${VPSNAME} # Set the additional cdrom drives: add all *.iso files to the config file HDDLIST="bcdefghijklmnopqrstuvwxyz" INCREMENT=2 for i in `find /var/lib/dtc-xen/ttyssh_home/xen${VPSNUM}/ -mindepth 1 -maxdepth 1 -iname '*.iso' | cut -d'/' -f7 | tr \\\r\\\n ,\ ` ; do DRIVE_LETTER=`echo ${HDDLIST} | awk '{print substr($0,'${INCREMENT}',1)}'` INCREMENT=$(( $INCREMENT + 1)) echo -n ,\'file:/var/lib/dtc-xen/ttyssh_home/xen${VPSNUM}/$i,hd${DRIVE_LETTER}:cdrom,r\' >>/etc/xen/${VPSNAME} done echo " ]" >>/etc/xen/${VPSNAME} # Set the VNC configuration if [ -z "${VNC_PASSWORD}" -o "${VNC_PASSWORD}" = "no_vnc" ] ; then echo "nographic=1 vnc=0" >>/etc/xen/${VPSNAME} else echo "vfb = [ \"type=vnc,vncdisplay=${VPSNUM},vncpasswd=${VNC_PASSWORD}\" ] nographic=0 vnc=1 stdvga=1" >>/etc/xen/${VPSNAME} fi # Set the boot device if [ ! "${HOW_TO_BOOT}" = "hdd" -a -e /var/lib/dtc-xen/ttyssh_home/xen${VPSNUM}/${HOW_TO_BOOT} ] ; then echo "cdrom=\"/var/lib/dtc-xen/ttyssh_home/xen${VPSNUM}/${HOW_TO_BOOT}\" boot=\"d\"" >>/etc/xen/${VPSNAME} else echo "boot=\"c\"" >>/etc/xen/${VPSNAME} fi echo "serial='pty'" >>/etc/xen/${VPSNAME} dtc-xen-0.5.17/src/dtc-xen_userconsole0000755000175000017500000000146611736663746016402 0ustar zigozigo#!/bin/sh echo "Welcome to dtc-xen ssh console!" echo "WARNING:" echo "You might need to press enter once to display the login prompt." echo "You can login only ONCE in this console, and you cannot resize it either." echo "You'd be a lot more comfortable if you install sshd and connect to it" echo "directly." echo "It is recommended to use this ssh remote access only in order to debug" echo "a broken virtual machine (VM/VPS) or after you reinstalled your VPS to" echo "install the ssh daemon, or also if you are to debug network and/or" echo "your firewall." echo "If your ssh daemon is not installed, login as root, then do:" echo "apt-get install ssh (Debian) or yum install openssh-server (CentOS)" sleep 1 if [ -n "$1" ]; then echo "Sorry, no shell commands allowed" exit 1 fi sudo /usr/sbin/xm console $USER dtc-xen-0.5.17/src/dtc-xen_domUconf_network_debian0000755000175000017500000000232111736663746020655 0ustar zigozigo#!/bin/sh set -e . /usr/share/dtc-xen/dtc-xen-parse-param ETC="${VPS_PATH}/etc" if [ "${VIRT_TYPE}" = "vz" ] ; then ETHNAME_PREFIX=vnet else ETHNAME_PREFIX=eth fi if [ ! -z "${NICS}" ] ; then echo "auto lo iface lo inet loopback " >${ETC}/network/interfaces # Configure the eth0 N=0 for i in $NICS ; do N_IP=`echo ${i} | cut -s -d"," -f1` N_MASK=`echo ${i} | cut -s -d"," -f2` N_BCAST=`echo ${i} | cut -s -d"," -f3` N_NET=`ipcalc -n ${N_IP} ${N_MASK} | grep Network | awk '{print $2}' | cut -d"/" -f1` if [ -z "${N_NET}" ] ; then N_NET=`ipcalc -n ${N_IP} ${N_MASK} | cut -d"=" -f2` fi if [ ${N} = 0 ] ; then DEVICE="${ETHNAME_PREFIX}0" else DEVICE="${ETHNAME_PREFIX}0:${N}" fi echo "auto ${DEVICE} iface ${DEVICE} inet static address ${N_IP} netmask ${N_MASK} network ${N_NET} broadcast ${N_BCAST}" >>${ETC}/network/interfaces if [ ${N} = 0 ] ; then echo " gateway ${GATEWAY}" >>${ETC}/network/interfaces fi echo "" >>${ETC}/network/interfaces N=$(( ${N} + 1 )) done fi # Set the resolv.conf echo "nameserver "`echo ${DNS} | cut -d"," -f1` > ${ETC}/resolv.conf if [ -z ""`echo ${DNS} | cut -s -d"," -f2` ] ; then echo `echo ${DNS} | cut -s -d"," -f2` >>${ETC}/resolv.conf fi dtc-xen-0.5.17/src/dtc_install_neoshine0000755000175000017500000000614411736663746016605 0ustar zigozigo#!/bin/sh CACHEDIR="/var/cache/yum" # where yum caches stuff -- is created as a subdir # of the destination chroot # FIXME perhaps after installation the script can modify the target machine's yum config to point to our Squid proxy # or define http_proxy inside the machine. that would make upgrades for customers much much faster. # better idea: instead of using a web cache, use a stash on the machine, we rsync the new RPMs into it once it's finished # we would need a mutex (flock or fcntl based?) that mutially excludes the critical section # the critical section is both the yum and the rsync process # we also need to rsync packages from the stash into the var cache on the vps, and a mutex to lock out if another yum is running, just as in the first scenario # cannot use a symlink because its chrooted for the duration of the process # at any case, the repo names for different distros need to be different, otherwise the caches will clash horribly # FIXME once that is done, we can stop using apt-proxy or apt-cacher # FIXME try to make it for suse, mandriva or any other rpm-based distro YUMENVIRON="$1" # where the yum config is generated and deployed INSTALLROOT="$2" # destination directory / chroot for installation if [ "${INSTALLROOT}" = "" -o ! -d "${INSTALLROOT}" -o "${YUMENVIRON}" = "" ] ; then echo "usage: centos-installer /yum/environment (will be created) /destination/directory (must exist)" echo "dest dir MUST BE an absolute path" exit 126 fi set -e set -x which rpm >/dev/null 2>&1 || { echo "rpm is not installed. please install rpm." ; exit 124 ; } # sometimes when the RPM database is inconsistent, yum fails but exits with success status # we make sure the db is in good health mkdir -p /var/lib/rpm rpm --rebuilddb # set distro ver releasever=5 # detect architecture ARCH=`uname -m` if [ "${ARCH}" = x86_64 ] ; then exclude="*.i386 *.i586 *.i686" basearch=x86_64 elif [ "${ARCH}" = i686 ] ; then exclude="*.x86_64" basearch=i386 else echo "Unknown architecture: ${ARCH} -- stopping centos-installer" exit 3 fi # make yum environment mkdir -p ${YUMENVIRON}/pluginconf.d ${YUMENVIRON}/repos.d ${CACHEDIR} ${INSTALLROOT}/var/log # In case the folder is not there: mkdir -p /var/lib/rpm # configure yum: cat > "${YUMENVIRON}/yum.conf" << EOF [main] reposdir=$YUMENVIRON/repos.d pluginconfpath=$YUMENVIRON/pluginconf.d cachedir=$CACHEDIR installroot=$INSTALLROOT exclude=$exclude keepcache=1 #debuglevel=4 #errorlevel=4 pkgpolicy=newest distroverpkg=centos-release tolerant=1 exactarch=1 obsoletes=1 gpgcheck=1 plugins=1 metadata_expire=1800 EOF cat > "${YUMENVIRON}/pluginconf.d/installonlyn.conf" << EOF [main] enabled=1 tokeep=5 EOF cat > "${YUMENVIRON}/repos.d/ND6.repo" << EOF [base] name=nd6 - Base baseurl=http://10.3.1.135/repo/ND/6/x86_64/os/ gpgcheck=0 [base2] name=fc13 - Base baseurl=http://10.3.1.135/repo/fedora/releases/13/Everything/x86_64/os/ gpgcheck=0 EOF # unleash yum export LANG=C exec yum -c "${YUMENVIRON}/yum.conf" -y install basesystem neokylin-release yum wget which yum-basearchonly nano rsyslog passwd joe screen dtc-xen-0.5.17/src/dtc_setup_vps_disk0000755000175000017500000000657611736663746016322 0ustar zigozigo#!/bin/sh if [ $# -lt 3 ]; then echo "Usage: $0 [lvm/vbd]" exit 64 fi # Source the configuration in the config file! if [ -f /etc/dtc-xen/dtc-xen.conf ] ; then . /etc/dtc-xen/dtc-xen.conf fi # Figure out the VPS mount point if [ -n "$provisioning_mount_point" ] then VPSGLOBPATH="$provisioning_mount_point" else VPSGLOBPATH="$VPS_MOUNTPOINT" fi # Things that most of then time don't change VPSNUM=$1 VPSNAME=xen${VPSNUM} VPSHOSTNAME=xen${NODE_NUM}${VPSNUM} VPSHDD=$2 VPSMEM=$3 IMAGE_TYPE=$4 if [ -z "$IMAGE_TYPE" ] ; then IMAGE_TYPE=lvm ; fi # Figure out the LVM name from dtc-xen.conf if [ "$IMAGE_TYPE" = "lvm" ] ; then LVMNAME=`dtc-xen-volgroup` if [ -z "$LVMNAME" ] ; then echo "Could not determine volume group from which to provision the volume" 1>&2 echo "You might want to set provisioning_volgroup in dtc-xen.conf" 1>&2 exit 78 fi fi FSTAB_LVMNAME=`echo ${LVMNAME} | sed -e 's/-/--/g'` # redirect stdout and stderr to log files, so we can see what happened during install echo "Redirecting standard output to $VPSGLOBPATH/$VPSNUM.stdout..." echo "Redirecting standard error to $VPSGLOBPATH/$VPSNUM.stderr..." if [ -e $VPSGLOBPATH/$VPSNUM.setuplvm.stdout ]; then mv $VPSGLOBPATH/$VPSNUM.setuplvm.stdout $VPSGLOBPATH/$VPSNUM.setuplvm.stdout.old fi if [ -e $VPSGLOBPATH/$VPSNUM.setuplvm.stderr ]; then mv $VPSGLOBPATH/$VPSNUM.setuplvm.stderr $VPSGLOBPATH/$VPSNUM.setuplvm.stderr.old fi exec 1>$VPSGLOBPATH/$VPSNUM.setuplvm.stdout exec 2>$VPSGLOBPATH/$VPSNUM.setuplvm.stderr if [ -x /sbin/lvcreate -a -x /sbin/lvremove ] ; then LVCREATE=/sbin/lvcreate LVREMOVE=/sbin/lvremove else if [ -x /usr/sbin/lvcreate -a -x /usr/sbin/lvremove ] ; then LVCREATE=/usr/sbin/lvcreate LVREMOVE=/usr/sbin/lvremove else echo "Could not find lvcreate and lvremove binaries!" > /dev/stderr exit 1 fi fi MKFS=/sbin/mkfs.ext3 MKDIR=/bin/mkdir MKSWAP=/sbin/mkswap echo "Seleted ${VPSNAME}: ${VPSHDD}MB HDD and ${VPSMEM}MB RAM"; echo "Creating disks..." if [ ""$IMAGE_TYPE = "lvm" ]; then # Remove existing partitions if they existed if [ -L /dev/${LVMNAME}/${VPSNAME} ] ; then $LVREMOVE -f /dev/${LVMNAME}/${VPSNAME} fi if [ -L /dev/${LVMNAME}/${VPSNAME}swap ] ; then $LVREMOVE -f /dev/${LVMNAME}/${VPSNAME}swap fi # (re)create the partitions if [ ! -L /dev/${LVMNAME}/${VPSNAME} ] ; then $LVCREATE -L${VPSHDD} -n${VPSNAME} ${LVMNAME} $MKDIR -p ${VPSGLOBPATH}/${VPSNUM} fi if [ ! -L /dev/${LVMNAME}/${VPSNAME}swap ] ; then $LVCREATE -L${VPSMEM} -n${VPSNAME}swap ${LVMNAME} fi if grep ${VPSNAME} /etc/fstab >/dev/null ; then echo "LV already exists in fstab" else echo "/dev/mapper/${FSTAB_LVMNAME}-${VPSNAME} ${VPSGLOBPATH}/${VPSNUM} ext3 defaults,noauto 0 0" >>/etc/fstab fi else if [ -e ${VPSGLOBPATH}/${VPSNAME}.img ]; then umount ${VPSGLOBPATH}/${VPSNAME}.img rm ${VPSGLOBPATH}/${VPSNAME}.img fi if [ -e ${VPSGLOBPATH}/${VPSNAME}.swap.img ]; then umount ${VPSGLOBPATH}/${VPSNAME}.swap.img rm ${VPSGLOBPATH}/${VPSNAME}.swap.img fi # (re)create the files dd if=/dev/zero of=$VPSGLOBPATH/${VPSNAME}.img bs=1M count=${VPSHDD} dd if=/dev/zero of=$VPSGLOBPATH/${VPSNAME}.swap.img bs=1M count=${VPSMEM} if grep ${VPSNAME} /etc/fstab >/dev/null ; then echo "LoopMount already exists in fstab: skipping" else echo "$VPSGLOBPATH/${VPSNAME}.img ${VPSGLOBPATH}/${VPSNUM} ext3 defaults,noauto,loop 0 0" >>/etc/fstab fi fi dtc-xen-0.5.17/src/selection_config_file0000644000175000017500000001226211736663746016721 0ustar zigozigo # This is the FULL list of question that would be requested by # debconf when setting-up DTC with debconf level set to medium. # Here is the full list of things that should be replaced: # __PASSWORD__ : password for dtc, mysql and phpmadmin # __DOMAIN_NAME__ : domain name of the VPS # __IP__ADDRESS__ # Best is to use something like this before using it: # sed -i "s/__PASSWORD__/your-password/g" selection_config_file # sed -i "s/__DOMAIN_NAME__/example.com/g" selection_config_file # sed -i "s/__IP__ADDRESS__/1.2.3.4/g" selection_config_file # MySQL Server mysql-server-5.0 mysql-server/root_password password __PASSWORD__ mysql-server-5.0 mysql-server/root_password seen true mysql-server-5.0 mysql-server/root_password_again password __PASSWORD__ mysql-server-5.0 mysql-server/root_password_again seen true mysql-server-5.0 mysql-server-5.0/need_sarge_compat boolean false mysql-server-5.0 mysql-server-5.0/need_sarge_compat seen true # Webalizer webalizer webalizer/directory string /var/www/webalizer webalizer webalizer/directory seen true webalizer webalizer/doc_title string Usate statistics for webalizer webalizer/doc_title seen true webalizer webalizer/logfile string /var/lib/apache2/access.log.1 webalizer webalizer/logfile seen true webalizer webalizer/dnscache boolean false webalizer webalizer/dnscache seen true # Mailgraph mailgraph mailgraph/start_on_boot boolean true mailgraph mailgraph/start_on_boot seen true mailgraph mailgraph/mail_log string /var/log/mail.log mailgraph mailgraph/mail_log seen true mailgraph mailgraph/ignore_localhost boolean false mailgraph mailgraph/ignore_localhost seen true # ca-certificates ca-certificates ca-certificates/trust_new_crts boolean true ca-certificates ca-certificates/trust_new_crts seen true # clamav clamav-freshclam clamav-freshclam/autoupdate_freshclam select daemon clamav-freshclam clamav-freshclam/autoupdate_freshclam seen true clamav-freshclam clamav-freshclam/local_mirror select db.us.clamav.net clamav-freshclam clamav-freshclam/local_mirror seen true clamav-freshclam clamav-freshclam/http_proxy string clamav-freshclam clamav-freshclam/http_proxy seen true clamav-freshclam clamav-freshclam/NotifyClamd boolean true clamav-freshclam clamav-freshclam/NotifyClamd seen true # Courier courier-base courier-base/webadmin-configmode boolean true courier-base courier-base/webadmin-configmode seen true courier-ssl courier-ssl/certnotice string fakestring courier-ssl courier-ssl/certnotice seen true # Postfix postfix postfix/main_mailer_type select Internet Site postfix postfix/main_mailer_type seen true postfix postfix/mailname string /etc/mailname postfix postfix/mailname seen true postfix postfix/destinations string mx.__DOMAIN_NAME__, localhost.__DOMAIN_NAME__, localhost.localdomain, localhost postfix postfix/destinations seen true postfix postfix/root_address string postfix postfix/root_address seen true postfix postfix/recipient_delim string + postfix postfix/recipient_delim seen true # mlmmj mlmmj mlmmj/text-format-changed string toto mlmmj mlmmj/text-format-changed seen true mlmmj mlmmj/remove-on-purge boolean false mlmmj mlmmj/remove-on-purge seen true # pure-ftpd pure-ftpd-common pure-ftpd/standalone-or-inetd select standalone pure-ftpd-common pure-ftpd/standalone-or-inetd seen true pure-ftpd-common pure-ftpd/ftpwho-setuid boolean false pure-ftpd-common pure-ftpd/ftpwho-setuid seen true pure-ftpd-common pure-ftpd/virtualchroot boolean true pure-ftpd-common pure-ftpd/virtualchroot seen true # sasl2 sasl2-bin cyrus-sasl2/backup-sasldb2 string /var/backups/sasldb2.back sasl2-bin cyrus-sasl2/backup-sasldb2 seen true # sbox sbox-dtc sbox-dtc/conf_use_dtc_dtcgrp boolean true sbox-dtc sbox-dtc/conf_use_dtc_dtcgrp seen true # dtc dtc-postfix-courier dtc/conf_mysqlautoconfig boolean true dtc-postfix-courier dtc/conf_mysqlautoconfig seen true dtc-postfix-courier dtc/conf_use_cyrus boolean false dtc-postfix-courier dtc/conf_use_cyrus seen true dtc-postfix-courier dtc/main_domainname string __DOMAIN_NAME__ dtc-postfix-courier dtc/main_domainname seen true dtc-postfix-courier dtc/conf_use_nated_vhosts boolean true dtc-postfix-courier dtc/conf_use_nated_vhosts seen true dtc-postfix-courier dtc/conf_ipaddr string __IP__ADDRESS__ dtc-postfix-courier dtc/conf_ipaddr seen true dtc-postfix-courier dtc/conf_admpass password __PASSWORD__ dtc-postfix-courier dtc/conf_admpass seen true # phpmyadmin phpmyadmin phpmyadmin/reconfigure-webserver multiselect apache2 phpmyadmin phpmyadmin/reconfigure-webserver seen true phpmyadmin phpmyadmin/setup-username string admin phpmyadmin phpmyadmin/setup-username seen true phpmyadmin phpmyadmin/setup-password password __PASSWORD__ phpmyadmin phpmyadmin/setup-password password true phpmyadmin phpmyadmin/restart-webserver boolean false phpmyadmin phpmyadmin/restart-webserver seen true # debconf debconf debconf/frontend select Noninteractive debconf debconf/frontend seen true debconf debconf/priority select medium debconf debconf/priority seen true debconf debconf-apt-progress/title string fake debconf debconf-apt-progress/title seen true debconf debconf-apt-progress/preparing string fake debconf debconf-apt-progress/preparing seen true # man-db man-db man-db/install-setuid boolean false man-db man-db/install-setuid seen true dtc-xen-0.5.17/src/dtc-xen-client0000755000175000017500000000140511736663746015226 0ustar zigozigo#!/usr/bin/env python import SOAPpy import sys url = sys.argv[1] # of the form https://dtc-xen:JDsPassword@dtcxenserver.example.com:8089/ method = sys.argv[2] params = sys.argv[3:] server = SOAPpy.SOAPProxy(url) func = getattr(server,method) if params: result = func(*params) else: result = func() def print_recursive(r,depth=0): prefix = " " * depth if type(r) in (list,SOAPpy.Types.arrayType,SOAPpy.Types.typedArrayType): if type(r) == SOAPpy.Types.arrayType: ty = "array" elif type(r) == SOAPpy.Types.typedArrayType: ty = "typedArray" elif type(r) == list: ty = "list" else: assert False print prefix + "%s: ["%ty for e in r: print_recursive(e,depth+1) print prefix + "]" else: print prefix, type(r), repr(r) print_recursive(result) dtc-xen-0.5.17/src/bashrc0000644000175000017500000000121411736663746013645 0ustar zigozigo# ~/.bashrc: executed by bash(1) for non-login shells. # automated bashrc for VPS users # www.gplhost.com BLUE="\[\033[1;34m\]" LGRAY="\[\033[0;37m\]" NO_COL="\[\033[0m\]" LBLUE="\[\033[1;36m\]" RED="\[\033[1;31m\]" export PS1=${RED}'\u'${LGRAY}@${BLUE}GPLHost${LGRAY}:${LBLUE}'VPS_HOSTNAME'${LGRAY}'>_'${NO_COL}' \w\$ ' umask 022 # You may uncomment the following lines if you want `ls' to be colorized: export LS_OPTIONS='--color=auto' eval `dircolors` alias ls='ls $LS_OPTIONS' alias ll='ls $LS_OPTIONS -l' alias l='ls $LS_OPTIONS -lA' # # Some more alias to avoid making mistakes: # alias rm='rm -i' # alias cp='cp -i' # alias mv='mv -i' dtc-xen-0.5.17/src/dtc_install_centos0000755000175000017500000000774411736663746016277 0ustar zigozigo#!/bin/sh CACHEDIR="/var/cache/yum" # where yum caches stuff -- is created as a subdir # of the destination chroot # FIXME perhaps after installation the script can modify the target machine's yum config to point to our Squid proxy # or define http_proxy inside the machine. that would make upgrades for customers much much faster. # better idea: instead of using a web cache, use a stash on the machine, we rsync the new RPMs into it once it's finished # we would need a mutex (flock or fcntl based?) that mutially excludes the critical section # the critical section is both the yum and the rsync process # we also need to rsync packages from the stash into the var cache on the vps, and a mutex to lock out if another yum is running, just as in the first scenario # cannot use a symlink because its chrooted for the duration of the process # at any case, the repo names for different distros need to be different, otherwise the caches will clash horribly # FIXME once that is done, we can stop using apt-proxy or apt-cacher # FIXME try to make it for suse, mandriva or any other rpm-based distro YUMENVIRON="$1" # where the yum config is generated and deployed INSTALLROOT="$2" # destination directory / chroot for installation if [ "${INSTALLROOT}" = "" -o ! -d "${INSTALLROOT}" -o "${YUMENVIRON}" = "" ] ; then echo "usage: centos-installer /yum/environment (will be created) /destination/directory (must exist)" echo "dest dir MUST BE an absolute path" exit 126 fi set -e set -x which rpm >/dev/null 2>&1 || { echo "rpm is not installed. please install rpm." ; exit 124 ; } # sometimes when the RPM database is inconsistent, yum fails but exits with success status # we make sure the db is in good health mkdir -p /var/lib/rpm rpm --rebuilddb # set distro ver releasever=6 # detect architecture ARCH=`uname -m` if [ "${ARCH}" = x86_64 ] ; then exclude="*.i386 *.i586 *.i686" basearch=x86_64 elif [ "${ARCH}" = i686 ] ; then exclude="*.x86_64" basearch=i386 else echo "Unknown architecture: ${ARCH} -- stopping centos-installer" exit 3 fi # make yum environment mkdir -p ${YUMENVIRON}/pluginconf.d ${YUMENVIRON}/repos.d ${CACHEDIR} ${INSTALLROOT}/var/log # In case the folder is not there: mkdir -p /var/lib/rpm # configure yum: cat > "${YUMENVIRON}/yum.conf" << EOF [main] reposdir=$YUMENVIRON/repos.d pluginconfpath=$YUMENVIRON/pluginconf.d cachedir=$CACHEDIR installroot=$INSTALLROOT exclude=$exclude keepcache=1 #debuglevel=4 #errorlevel=4 pkgpolicy=newest distroverpkg=centos-release tolerant=1 exactarch=1 obsoletes=1 gpgcheck=1 plugins=1 metadata_expire=1800 EOF cat > "${YUMENVIRON}/pluginconf.d/installonlyn.conf" << EOF [main] enabled=1 tokeep=5 EOF cat > "${YUMENVIRON}/repos.d/CentOS-Base.repo" << EOF [base] name=CentOS-6 - Base #baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/ mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os gpgcheck=1 gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6 [updates] name=CentOS-6 - Updates #baseurl=http://mirror.centos.org/centos/$releasever/updates/$basearch/ mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates gpgcheck=1 gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6 [extras] name=CentOS-6 - Extras #baseurl=http://mirror.centos.org/centos/$releasever/extras/$basearch/ mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras gpgcheck=1 gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6 [centosplus] name=CentOS-6 - Plus #baseurl=http://mirror.centos.org/centos/$releasever/centosplus/$basearch/ mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus gpgcheck=1 gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6 EOF # unleash yum export LANG=C exec yum -c "${YUMENVIRON}/yum.conf" -y install coreutils basesystem centos-release yum-basearchonly initscripts upstart nano nano yum wget which passwd joe screen dtc-xen-0.5.17/src/dtc_change_bsd_kernel0000755000175000017500000000330211736663746016655 0ustar zigozigo#!/bin/sh USAGE="Usage: $0 [normal|install]" if [ $# -lt 3 ]; then echo $USAGE fi # Things that often change # Source the configuration in the config file! if [ -f /etc/dtc-xen/dtc-xen.conf ] ; then . /etc/dtc-xen/dtc-xen.conf fi # Figure out the LVM name from dtc-xen.conf LVMNAME=`dtc-xen-volgroup` [ -z "$LVMNAME" ] && { echo "Could not determine volume group from which to provision the volume" 1>&2 echo "You might want to set provisioning_volgroup in dtc-xen.conf" 1>&2 exit 78 } FSTAB_LVMNAME=`echo ${LVMNAME} | sed -e 's/-/--/g'` #NODE_NUM=6501 #DEBIAN_REPOS="http://65.apt-proxy.gplhost.com:9999/debian" #NETMASK=255.255.255.0 #NETWORK=202.124.18.0 #BROADCAST=202.124.18.255 #GATEWAY=202.124.18.1 # Figure out the VPS mount point if [ -n "$provisioning_mount_point" ] then VPSGLOBPATH="$provisioning_mount_point" else VPSGLOBPATH="$VPS_MOUNTPOINT" fi INSTALL_KERNELPATH="${bsd_install_kernel_path}" NORMAL_KERNELPATH="${bsd_kernel_path}" # Things that most of then time don't change VPSNUM=$1 VPSNAME=xen${VPSNUM} VPSHOSTNAME=xen${NODE_NUM}${VPSNUM} RAMSIZE=$2 KERNEL_TYPE=$3 ALL_IPADDRS=$4 MAC_ADDR=${vps_mac_prefix}:${VPSNUM} case "$KERNEL_TYPE" in "install") KERNELPATH=$INSTALL_KERNELPATH ;; "normal") KERNELPATH=$NORMAL_KERNELPATH ;; *) echo $USAGE; exit 1 ;; esac if [ ! -z "${MAC_ADDR}" ] ; then XEN_WRITE_MAC="mac=${MAC_ADDR}, " else XEN_WRITE_MAC="" fi echo "kernel = \"${KERNELPATH}\" memory = ${RAMSIZE} name = \"${VPSNAME}\" vif = [ '${XEN_WRITE_MAC}ip=${ALL_IPADDRS}' ] disk = [ 'phy:/dev/mapper/${FSTAB_LVMNAME}-${VPSNAME},0x3,w' ] " >/etc/xen/${VPSNAME} if [ ! -e /etc/xen/auto/${VPSNAME} ] ; then ln -s ../${VPSNAME} /etc/xen/auto/${VPSNAME} fi dtc-xen-0.5.17/src/dtc-panel_autodeploy.sh0000755000175000017500000000466011736663746017143 0ustar zigozigo#!/bin/sh # Given the fact that your VPS is well configured # with a correct hostname ans IP, this script will # setup DTC in ONCE, by just giving a password that # will be set for the root MySQL user, DTC and phpmyadmin. # # This will only run on Debian based VPS, it should # run well with Squeeze, but it's not tested if using Ubuntu. set -e # Check number of params and print usage. if ! [ $# = 1 ] ; then echo "Usage: dtc-autodeploy " exit 1 fi # Get the password to set using the command line... PASSWORD=$1 export DEBCONF_FRONTEND=noninteractive APTGET="apt-get -o Dpkg::Options::=--force-confnew --force-yes -fuy" apt-get update ${APTGET} install ssh ${APTGET} dist-upgrade # Set the apt to NOT install the recommends, to make it a smaller footprint echo "APT{ Install-Recommends \"false\"; }" >/etc/apt/apt.conf # Find the hostname and default interface and IP of the VPS DOMAIN_NAME=`hostname --domain` DEFAULT_IF=`/sbin/route | grep default |awk -- '{ print $8 }'` IP_ADDR=`ifconfig ${DEFAULT_IF} | grep 'inet addr' | sed 's/.\+inet addr:\([0-9.]\+\).\+/\1/'` # Set the values in debconf MKTEMP="mktemp -t" SETSEL_FILE=`${MKTEMP} DTC_AUTODEPLOY.XXXXXX` || exit 1 #DEBCONF_FRONTEND=noninteractive apt-get --force-yes --assume-yes install squirrelmail squirrelmail-locales ${APTGET} install squirrelmail squirrelmail-locales # Copy our selection_config_file template file, and tweak it with correct values cp selection_config_file ${SETSEL_FILE} sed -i "s/__PASSWORD__/${PASSWORD}/g" ${SETSEL_FILE} sed -i "s/__DOMAIN_NAME__/${DOMAIN_NAME}/g" ${SETSEL_FILE} sed -i "s/__IP__ADDRESS__/${IP_ADDR}/g" ${SETSEL_FILE} # Set the values needed to setup DTC debconf-set-selections ${SETSEL_FILE} ${APTGET} install dtc-toaster # Sets back debconf to interactive mode with priority medium, # so that the user can install new packages (like roundcube) # more comfortably. echo "debconf debconf/frontend select Dialog debconf debconf/frontend seen true debconf debconf/priority select medium debconf debconf/priority seen true debconf debconf-apt-progress/title string fake debconf debconf-apt-progress/title seen true debconf debconf-apt-progress/preparing string fake debconf debconf-apt-progress/preparing seen true" >${SETSEL_FILE} debconf-set-selections ${SETSEL_FILE} dpkg-reconfigure -f noninteractive debconf # Finally start the dtc shell installer and we are done! /usr/share/dtc/admin/install/install sleep 2 invoke-rc.d apache2 restart dtc-xen-0.5.17/src/dtc-xen-volgroup0000755000175000017500000000063511736663746015631 0ustar zigozigo#!/bin/sh set -e PATH=/sbin:/bin:/usr/sbin:/usr/bin [ -f /etc/dtc-xen/soap.conf ] && . /etc/dtc-xen/soap.conf [ -f /etc/dtc-xen/dtc-xen.conf ] && . /etc/dtc-xen/dtc-xen.conf if [ "$soap_server_lvmname" != "" ] ; then echo "$soap_server_lvmname" exit 0 fi if [ "$provisioning_volgroup" != "" ] ; then echo "$provisioning_volgroup" exit 0 fi vgdisplay -c -A | tail -n 1 | cut -d":" -f1 | awk '{print $1}' dtc-xen-0.5.17/src/vgdisplay_free_size0000755000175000017500000000030311736663746016441 0ustar zigozigo#!/bin/sh PESIZE=`vgdisplay -c lvm1 | cut -d':' -f13` FREEPE=`vgdisplay -c lvm1 | cut -d':' -f16` FREESIZE=$((${PESIZE} * ${FREEPE} )) FREESIZE_MEG=$((${FREESIZE} / 1024 )) echo $FREESIZE_MEG dtc-xen-0.5.17/src/dtc-xen_domU_gen_xen_conf0000755000175000017500000001156511736663746017456 0ustar zigozigo#!/bin/sh set -e # DIE on errors . /usr/share/dtc-xen/dtc-xen-parse-param VPSNAME=xen${VPSNUM} # Select the type of partition (eg: sdaX vs xvdX) if [ "${XEN_DOMU_HDD_DEV_TYPE}" = "xvd" ] ; then part_dev=xvda swap_dev=xvdb else part_dev=sda1 swap_dev=sda2 fi ################################# ### XEN STARTUP FILE CREATION ### ################################# if [ ! -z "${MAC_ADDR}" ] ; then XEN_WRITE_MAC="mac=${MAC_ADDR}, " else XEN_WRITE_MAC="" fi if [ ! -z "${XEN_BR}" ] ; then BRIDGE_DIRECTIVE=", bridge=${XEN_BR}" else BRIDGE_DIRECTIVE="" fi if [ ! -z "${VCPUS}" ] ; then VCPUSSET="vcpus=${VCPUS}" else VCPUSSET="vcpus=1" fi if [ ! -z "${MAXMEM}" ] ; then MAXMEMSET="maxmem=${MAXMEM}" else MAXMEMSET="" fi if [ ! -z "${PAE}" ] ; then PAESET="pae=${PAE}" else PAESET="" fi if [ ! -z "${ACPI}" ] ; then ACPISET="acpi=${ACPI}" else ACPISET="" fi if [ ! -z "${APIC}" ] ; then APICSET="apic=${APIC}" else APICSET="" fi if [ ! -z "${KEYMAP}" ] ; then KEYMAPSET="keymap='${KEYMAP}'" else KEYMAPSET="" fi if [ ! -z "${CPUS}" ] ; then CPUSSET="cpus=${CPUS}" else CPUSSET="" fi if [ ! -z "${CPUCAP}" ] ; then CPUCAPSET="cpu_cap=${CPUCAP}" else CPUCAPSET="" fi if [ ! -z "${CPUWEIGHT}" ] ; then CPUWEIGHTSET="cpu_weight=${CPUWEIGHT}" else CPUWEIGHTSET="" fi if [ -f /etc/redhat-release ] ; then BRIDGE_DIRECTIVE=", bridge=xenbr0" fi if [ "$DISTRO" = "xenhvm" ] ; then echo -n "kernel = \"/usr/lib/xen/boot/hvmloader\" builder = 'hvm' memory = ${VPSMEM} name = \"${VPSNAME}\" ${CPUSSET} ${CPUCAPSET} ${CPUWEIGHTSET} ${VCPUSSET} ${MAXMEMSET} ${PAESET} ${ACPISET} ${APICSET} ${KEYMAPSET} vif = [ 'type=ioemu, ${XEN_WRITE_MAC}ip=${ALL_IPADDRS}${BRIDGE_DIRECTIVE}' ] disk=[ 'phy:/dev/mapper/${FSTAB_LVMNAME}-xen${VPSNUM},ioemu:hda,w'" >/etc/xen/${VPSNAME} # Add all *.iso files to the config file HDDLIST="bcdefghijklmnopqrstuvwxyz" INCREMENT=1 for i in `find /var/lib/dtc-xen/ttyssh_home/xen${VPSNUM} -mindepth 1 -maxdepth 1 -iname '*.iso' | cut -d'/' -f5 | tr \\\r\\\n ,\ ` ; do DRIVE_LETTER=`echo ${HDDLIST} | awk '{print substr($0,$INCREMENT,1)}'` INCREMENT=$(( $INCREMENT + 1)) echo -n ,\'file:/var/lib/dtc-xen/ttyssh_home/xen${VPSNUM}/$i,hd${DRIVE_LETTER}:cdrom,r\' >>/etc/xen/${VPSNAME} echo $i done # Set the VPN password echo " ] vfb = [ \"type=vnc,vncdisplay=${VPSNUM},vncpasswd=XXXX\" ]" >>/etc/xen/${VPSNAME} # Set the boot cd if variable is set if [ -z "${BOOT_ISO}" -a -e /var/lib/dtc-xen/ttyssh_home/xen${VPSNUM}/${BOOT_ISO} ] ; then echo "cdrom=\"/var/lib/dtc-xen/ttyssh_home/xen${VPSNUM}/${BOOT_ISO}\" boot=\"d\" nographic=0 vnc=1 stdvga=1" >>/etc/xen/${VPSNAME} # Otherwise boot on the HDD else echo "boot=\"c\" nographic=1" >>/etc/xen/${VPSNAME} fi echo "serial='pty'" >>/etc/xen/${VPSNAME} elif [ "$DISTRO" = "netbsd" ] ; then echo "kernel = \"${bsd_kernel_path}\" memory = ${VPSMEM} ${CPUSSET} ${CPUCAPSET} ${CPUWEIGHTSET} ${VCPUSSET} ${MAXMEMSET} ${KEYMAPSET} name = \"${VPSNAME}\" vif = [ '${XEN_WRITE_MAC}ip=${ALL_IPADDRS}${BRIDGE_DIRECTIVE}' ] " >/etc/xen/${VPSNAME} if [ "$IMAGE_TYPE" = "lvm" ]; then echo "disk = [ 'phy:/dev/mapper/${FSTAB_LVMNAME}-xen${VPSNUM},0x3,w' ] " >>/etc/xen/${VPSNAME} else echo "disk = [ 'file:$VPSGLOBPATH/${VPSNAME}.img,0x301,w' ] " >>/etc/xen/${VPSNAME} fi else # Set the configured kernel name echo "kernel = \"${KERNELPATH}\"" > /etc/xen/${VPSNAME} # Set a initrd image if configured if ! [ -z "${INITRDPATH}" ] ; then echo "ramdisk = \"${INITRDPATH}\"" >> /etc/xen/${VPSNAME} fi # Set memory, domU name and vif echo "memory = ${VPSMEM} ${CPUSSET} ${CPUCAPSET} ${CPUWEIGHTSET} ${VCPUSSET} ${MAXMEMSET} ${KEYMAPSET} name = \"${VPSNAME}\" vif = [ '${XEN_WRITE_MAC}ip=${ALL_IPADDRS}${BRIDGE_DIRECTIVE}' ] " >> /etc/xen/${VPSNAME} # Set the HDDs if [ "$IMAGE_TYPE" = "lvm" ]; then echo "disk = [ 'phy:/dev/mapper/${FSTAB_LVMNAME}-xen${VPSNUM},${part_dev},w','phy:/dev/mapper/${FSTAB_LVMNAME}-xen${VPSNUM}swap,${swap_dev},w' ] " >> /etc/xen/${VPSNAME} else echo "disk = [ 'file:$VPSGLOBPATH/${VPSNAME}.img,${part_dev},w','file:$VPSGLOBPATH/${VPSNAME}.swap.img,${swap_dev},w' ] " >> /etc/xen/${VPSNAME} fi # Set the boot parameters (runlevel and tty) if [ "$DISTRO" = "slackware" ]; then echo "root = \"/dev/${part_dev} ro\" # Sets runlevel 3. extra = \"3 TERM=xterm xencons=tty console=tty1\" " >>/etc/xen/${VPSNAME} else # Use different extra = depending on the dom0 OS type if [ -z "${XENU_EXTRA_PARM}" ] ; then # CentOS doesn't need the: TERM=xterm xencons=tty console=tty1 if [ -f /etc/redhat-release ] ; then XENU_EXTRA_PARM="4" # Debian domU wont have console without: TERM=xterm xencons=tty console=tty1 else XENU_EXTRA_PARM="4 TERM=xterm xencons=tty console=tty1" fi fi echo "root = \"/dev/${part_dev} ro\" # Sets runlevel 4. extra = \"${XENU_EXTRA_PARM}\" " >>/etc/xen/${VPSNAME} fi fi # The reboot autostart if [ ! -e /etc/xen/auto/${VPSNAME} ] ; then ln -s ../${VPSNAME} /etc/xen/auto/${VPSNAME} fi dtc-xen-0.5.17/src/dtc-xen_domUconf_standard0000755000175000017500000001020311736663746017460 0ustar zigozigo#!/bin/sh # This script is shared by almost all Unix distributions, it's a good idea to call it. if [ -r /usr/share/dtc-xen/dtc-xen-parse-param ]; then . /usr/share/dtc-xen/dtc-xen-parse-param else echo "dtc-xen_domUconf_standard: Fatal Error: Cannot read file /usr/share/dtc-xen/dtc-xen-parse-param. Exiting ..." && exit 1 fi if [ "x$VPS_PATH" = "x" ]; then echo "dtc-xen_domUconf_standard: Fatal Error: VPS_PATH is not defined or empty. Exiting ..." && exit 1 fi ETC=${VPS_PATH}/etc if [ "${XEN_DOMU_HDD_DEV_TYPE}" = "xvd" ] ; then part_dev=xvda swap_dev=xvdb else part_dev=sda1 swap_dev=sda2 fi # Setup the fstab echo "/dev/${part_dev} / ext3 errors=remount-ro 0 0 proc /proc proc defaults 0 0 /dev/${swap_dev} none swap sw 0 0 none /dev/pts devpts defaults 0 0 " >${ETC}/fstab # Tweaks the /etc/inittab to use the console device instead of tty1 if [ -f ${ETC}/inittab ] ; then sed -i "s/tty1/console/" ${ETC}/inittab fi # This one is for Ubuntu, yet it's not enough, since it's still not # displaying at boot time (it does at shutdown though...) if [ -f ${ETC}/init/tty1.conf ] ; then sed -i "s/tty1/console/" ${ETC}/init/tty1.conf fi # Setup hostname and hosts echo "${VPS_FQDN}" >${ETC}/hostname echo "127.0.0.1 localhost.localdomain localhost ${FIRST_IP} ${VPS_FQDN} ${VPS_DOMAIN} # The following lines are desirable for IPv6 capable hosts ::1 ip6-localhost ip6-loopback fe00::0 ip6-localnet ff00::0 ip6-mcastprefix ff02::1 ip6-allnodes ff02::2 ip6-allrouters ff02::3 ip6-allhosts " >${ETC}/hosts # Setup the devices mkdir -p ${VPS_PATH}/dev/ echo "Making VPS devices with MAKEDEV generic, this WILL take a while..." OLDPWDDIR=`pwd` cd ${VPS_PATH}/dev /sbin/MAKEDEV generic cd ${OLDPWDDIR} # Fix the /dev/ptmx and /dev/pts device and folder rm -rf ${VPS_PATH}/dev/ptmx ${VPS_PATH}/dev/pts mknod ${VPS_PATH}/dev/ptmx c 5 2 chmod 666 ${VPS_PATH}/dev/ptmx mkdir ${VPS_PATH}/dev/pts # If we run on a non-debian non-64 bits system, disable the tls folder FOUNDED_ARCH=`uname -m` if [ $FOUNDED_ARCH = "i386" -o $FOUNDED_ARCH = "i486" -o $FOUNDED_ARCH = "i586" -o $FOUNDED_ARCH = "i686" ] ; then if ! [ -f ${VPS_PATH}/etc/debian_version ] ; then if [ -d "${VPS_PATH}/lib/tls" ] ; then echo "Disabling lib/tls" mv ${VPS_PATH}/lib/tls ${VPS_PATH}/lib/tls.disabled fi fi fi # Setup the kernel echo "Installing kernel and modules..." if [ ! -e ${VPS_PATH}/lib/modules ]; then $MKDIR -p ${VPS_PATH}/lib/modules fi echo "cp -auxf ${KMOD_PATH} ${VPS_PATH}/lib/modules" cp -auxf ${KMOD_PATH} ${VPS_PATH}/lib/modules cp -L ${KERNELPATH} ${VPS_PATH}/boot if [ ! -e ${VPS_PATH}/boot/vmlinuz ] ; then ln -s ${KERNELPATH} ${VPS_PATH}/boot/vmlinuz fi echo "chroot ${VPS_PATH} /sbin/depmod -a ${KERNEL_RELEASE}" chroot ${VPS_PATH} /sbin/depmod -a ${KERNEL_RELEASE} # Copy an eventual /etc/dtc-xen/authorized_keys2 file if [ -f /etc/dtc-xen/authorized_keys2 ] ; then if [ ! -d "${VPS_PATH}/root/.ssh" ] ; then mkdir -p "${VPS_PATH}/root/.ssh" chmod 700 "${VPS_PATH}/root/.ssh" fi if [ -d "${VPS_PATH}/root/.ssh" -a ! -e "${VPS_PATH}/root/.ssh/authorized_keys2" ] ; then cp /etc/dtc-xen/authorized_keys2 "${VPS_PATH}/root/.ssh/authorized_keys2" chmod 600 "${VPS_PATH}/root/.ssh/authorized_keys2" fi if [ -d "${VPS_PATH}/root/.ssh" -a ! -e "${VPS_PATH}/root/.ssh/authorized_keys" ] ; then cp /etc/dtc-xen/authorized_keys2 "${VPS_PATH}/root/.ssh/authorized_keys" chmod 600 "${VPS_PATH}/root/.ssh/authorized_keys" fi fi # Customize the /root/.bashrc script sed "s/VPS_HOSTNAME/${VPS_FQDN}/" /etc/dtc-xen/bashrc >${VPS_PATH}/root/.bashrc if [ ! -z "${LOCALE}" ] ; then LOCALESET="${LOCALE}" else LOCALESET="en_US" fi if [ "${DISTRO}" = "debian" ] ; then if [ -f ${VPS_PATH}/etc/locale.gen ] ; then echo "Setting up Debian locale to en_US.UTF-8" TMP_FILE=`mktemp -t DTC_SET_LOCALE.XXXXXX` || exit 1 grep -v "${LOCALESET}.UTF-8" ${VPS_PATH}/etc/locale.gen >${TMP_FILE} cat <${TMP_FILE} >${VPS_PATH}/etc/locale.gen rm ${TMP_FILE} echo "${LOCALESET}.UTF-8 UTF-8" >>${VPS_PATH}/etc/locale.gen chroot ${VPS_PATH} localedef -i ${LOCALESET} -c -f UTF-8 -A /usr/share/locale/locale.alias ${LOCALESET}.UTF-8 chroot ${VPS_PATH} locale-gen fi fi exit 0 dtc-xen-0.5.17/src/soap.conf0000644000175000017500000000013411736663746014271 0ustar zigozigo# properties for soap_server.py soap_server_host=node6502.gplhost.com soap_server_port=8089 dtc-xen-0.5.17/src/dtc-xen_migrate0000755000175000017500000000420611736663746015464 0ustar zigozigo#!/bin/sh set -e . /etc/dtc-xen/dtc-xen.conf print_usage () { echo "Usage: dtc-xen [remote-vps-id]" } if [ $# -lt 2 -o $# -gt 3 ] ; then print_usage exit 1 fi VPS_ID=${1} DEST_NODE=${2} if [ -z "${3}" ] ; then VPS_REMOTE_ID=${3} else VPS_REMOTE_ID=${VPS_ID} fi VG=`dtc-xen-volgroup` DEST_VG=`ssh ${DEST_NODE} 'dtc-xen-volgroup'` RAM=`cat /etc/xen/xen${VPS_ID} | grep memory | awk '{print $3}'` HDD=`lvdisplay -c /dev/${VG}/xen${VPS_ID} | cut -d":" -f7` HDD=$((${HDD} / 2048 )) echo "Migrating xen${VPS_ID} to ${DEST_NODE}:${VPS_REMOTE_ID} HDD: ${HDD}MB on ${DEST_VG}, RAM: ${RAM}" echo "=> Creating HDD space on ${DEST_NODE}" ssh $DEST_NODE "dtc_setup_vps_disk $VPS_REMOTE_ID ${HDD} ${RAM}" echo "=> Formating remote partitions" ssh $DEST_NODE "mkfs.ext3 /dev/${DEST_VG}/xen${VPS_REMOTE_ID}" ssh $DEST_NODE "mkswap /dev/${DEST_VG}/xen${VPS_REMOTE_ID}swap" echo "=> mounting partition" ssh $DEST_NODE "mount /var/lib/dtc-xen/mnt/${VPS_REMOTE_ID}" echo "=> Shutting down VPS" xm shutdown xen${VPS_ID} xm console xen${VPS_ID} echo "=> Mounting partition" mount /var/lib/dtc-xen/mnt/${VPS_ID} echo "=> Synchronizing content with rsync" nice rsync -e ssh -azvp --numeric-ids /var/lib/dtc-xen/mnt/${VPS_ID}/ ${DEST_NODE}:/var/lib/dtc-xen/mnt/${VPS_REMOTE_ID} echo "=> Building remote configuration file" scp /etc/xen/xen${VPS_ID} ${DEST_NODE}:/etc/xen/xen${VPS_REMOTE_ID} REMOTE_MAC_PREFIX=`ssh ${DEST_NODE} "cat /etc/dtc-xen/dtc-xen.conf | grep vps_mac_prefix | cut -d'=' -f2"` ssh ${DEST_NODE} "sed -i s/${VG}/${DEST_VG}/ /etc/xen/xen${VPS_REMOTE_ID} && sed -i s/${VG}/${DEST_VG}/ /etc/xen/xen${VPS_REMOTE_ID} && sed -i s/${vps_mac_prefix}:${VPS_ID}/$REMOTE_MAC_PREFIX:${VPS_REMOTE_ID}/ /etc/xen/xen${VPS_REMOTE_ID} && sed -i s/xen${VPS_ID}/xen${VPS_REMOTE_ID}/ /etc/xen/xen${VPS_REMOTE_ID}" echo "=> Unmounting remote" ssh ${DEST_NODE} "umount /var/lib/dtc-xen/mnt/${VPS_REMOTE_ID}" echo "=> Starting ${DEST_NODE}:${VPS_REMOTE_ID}" ssh ${DEST_NODE} "xm create xen${VPS_REMOTE_ID}" echo "=> Unmounting local VM partition" umount /var/lib/dtc-xen/mnt/${VPS_ID} echo "DONE! You check xen${VPS_REMOTE_ID} on ${DEST_NODE} is working correctly now!" dtc-xen-0.5.17/src/dtc-xen-parse-param0000755000175000017500000000766411736663746016175 0ustar zigozigo#!/bin/sh # To be included by each scripts for parsing # Figure out the LVM name from dtc-xen.conf LVMNAME=`dtc-xen-volgroup` if [ -z "$LVMNAME" ] ; then echo "Could not determine volume group from which to provision the volume" 1>&2 echo "You might want to set provisioning_volgroup in dtc-xen.conf" 1>&2 exit 78 fi FSTAB_LVMNAME=`echo ${LVMNAME} | sed -e 's/-/--/g'` NUM_NIC=0 for i in $@ ; do case "${1}" in "-path") VPS_PATH="${2}" shift shift ;; "-ram") VPSMEM="${2}" shift shift ;; "-os") DISTRO=${2} shift shift ;; "--mac") MAC_ADDR="${2}" shift shift ;; "--bridge") XEN_BR="${2}" shift shift ;; "--maxmem") MAXMEM="${2}" shift shift ;; "--locale") LOCALE="${2}" shift shift ;; "--keymap") KEYMAP="${2}" shift shift ;; "--vcpus") VCPUS="${2}" shift shift ;; "--cpus") CPUS="${2}" shift shift ;; "--cpucap") CPUCAP="${2}" shift shift ;; "--cpuweight") CPUWEIGHT="${2}" shift shift ;; "--pae") PAE="${2}" shift shift ;; "--acpi") ACPI="${2}" shift shift ;; "--apic") APIC="${2}" shift shift ;; "-vpsid") VPSNUM="${2}" shift shift ;; "-nic") PARAM=${2} # Manage the nics to give it as parameters to the setup-vps-network script if [ "${NUM_NIC}" = 0 ] ; then ALL_IPADDRS=`echo ${PARAM} | cut -d"," -f1` FIRST_IP=`echo ${PARAM} | cut -s -d"," -f1` FW_NICS_CMD="-nic ${PARAM}" NICS=${PARAM} else ALL_IPADDRS="${ALL_IPADDRS} "`echo ${PARAM} | cut -d"," -f1` FW_NICS_CMD="${FW_NICS_CMD} -nic ${PARAM}" NICS=$NICS" "${PARAM} fi NUM_NIC=$(( ${NUM_NIC} + 1 )) shift shift ;; "-gw") GATEWAY="$2" shift shift ;; "--vps-fqdn") VPS_FQDN="$2" shift shift ;; "--vps-domain") VPS_DOMAIN="$2" shift shift ;; "--node-fqdn") NODE_FQDN="$2" shift shift ;; "-dns") DNS=${2} shift shift ;; "--virt-type") VIRT_TYPE=${2} shift shift ;; "--kernel") KERNELPATH="$2" shift shift ;; "--kernel-release") KERNEL_RELEASE=${2} shift shift ;; "--kmod-path") KMOD_PATH="${2}" shift shift ;; "--initrd") INITRDPATH="${2}" shift shift ;; "--vnc-pass") VNC_PASSWORD="${2}" shift shift ;; "--boot-iso") BOOT_ISO="${2}" shift shift ;; "--disk-type") IMAGE_TYPE="${2}" shift shift ;; "--lvm-name") LVMNAME="${2}" shift shift ;; "--xen-domu-hdd-dev-type") XEN_DOMU_HDD_DEV_TYPE="${2}" shift shift ;; "--xenu_extra_parm") XENU_EXTRA_PARM="${2}" shift shift ;; esac done # Calculate the command line to forward between scripts HVM_PARMS="" if [ -z "${VNC_PASSWORD}" ] ; then HVM_PARMS="--vnc-pass ${VNC_PASSWORD}" fi if [ -z "${BOOT_ISO}" ] ; then HVM_PARMS="${HVM_PARMS} --boot-iso ${BOOT_ISO}" fi KERNEL_P="--kernel ${KERNELPATH} --kernel-release ${KERNEL_RELEASE} --kmod-path ${KMOD_PATH} --initrd ${INITRDPATH}" FW_PARAMS="--disk-type ${IMAGE_TYPE} --xen-domu-hdd-dev-type ${XEN_DOMU_HDD_DEV_TYPE} -path ${VPS_PATH} -ram ${VPSMEM} -vpsid ${VPSNUM} --vps-fqdn ${VPS_FQDN} --vps-domain ${VPS_DOMAIN} --node-fqdn ${NODE_FQDN} ${FW_NICS_CMD} -dns ${DNS} -gw ${GATEWAY} --virt-type ${VIRT_TYPE} ${KERNEL_P}" if [ -n "${MAC_ADDR}" ] ; then FW_PARAMS="${FW_PARAMS} --mac ${MAC_ADDR}" fi if [ -n "${XEN_BR}" ] ; then FW_PARAMS="${FW_PARAMS} --bridge ${XEN_BR}" fi if [ -z "${HVM_PARMS}" ] ; then FW_PARAMS="${FW_PARAMS} ${HVM_PARMS}" fi if [ -z "${LVMNAME}" ] ; then FW_PARAMS="${FW_PARAMS} --lvm-name ${LVMNAME}" fi if [ -n "${XENU_EXTRA_PARM}" ] ; then FW_PARAMS="${FW_PARAMS} --xenu_extra_parm ${XENU_EXTRA_PARM}" fi dtc-xen-0.5.17/src/.htpasswd0000644000175000017500000000002611736663746014316 0ustar zigozigoJohnDoe:x/wM9yUk.FXvY dtc-xen-0.5.17/src/dtc-xen_domU_gen_vz_conf0000644000175000017500000000403111736663746017306 0ustar zigozigo#!/bin/sh set -e # DIE on errors . /usr/share/dtc-xen/dtc-xen-parse-param VPSNAME=${VPSNUM} HALFMEM=$((VPSMEM / 2)) QUARTERMEM=$((VPSMEM / 4)) PRIVMPAGESHARD=$((HALFMEM * 11 / 10)) HDDHARD=$((VPSHDD * 11 / 10)) INODES=$((VPSHDD / 4)) INODESHARD=$((INODES * 11 / 10)) ################################# ### VZ STARTUP FILE CREATION ### ################################# if [ ! -z "${MAC_ADDR}" ] ; then XEN_WRITE_MAC="mac=${MAC_ADDR}, " else XEN_WRITE_MAC="" fi echo -n "ONBOOT=\"yes\" # Primary parameters NUMPROC=\"1024:1024\" NUMTCPSOCK=\"9223372036854775807:9223372036854775807\" NUMOTHERSOCK=\"9223372036854775807:9223372036854775807\" VMGUARPAGES=\"${HALFMEM}:9223372036854775807\" # Secondary parameters KMEMSIZE=\"9223372036854775807:9223372036854775807\" OOMGUARPAGES=\"${HALFMEM}:9223372036854775807\" PRIVVMPAGES=\"${HALFMEM}:${PRIVMPAGESHARD}\" TCPSNDBUF=\"9223372036854775807:9223372036854775807\" TCPRCVBUF=\"9223372036854775807:9223372036854775807\" OTHERSOCKBUF=\"9223372036854775807:9223372036854775807\" DGRAMRCVBUF=\"9223372036854775807:9223372036854775807\" # Auxiliary parameters NUMFILE=\"9223372036854775807:9223372036854775807\" NUMFLOCK=\"9223372036854775807:9223372036854775807\" NUMPTY=\"255:255\" NUMSIGINFO=\"1024:1024\" DCACHESIZE=\"9223372036854775807:9223372036854775807\" LOCKEDPAGES=\"${QUARTERMEM}:${QUARTERMEM}\" SHMPAGES=\"9223372036854775807:9223372036854775807\" NUMIPTENT=\"9223372036854775807:9223372036854775807\" PHYSPAGES=\"0:9223372036854775807\" # Disk quota parameters DISKSPACE=\"${VPSHDD}:${HDDHARD}\" DISKINODES=\"${INODES}:${INODESHARD}\" QUOTATIME=\"0\" QUOTAUGIDLIMIT=\"0\" # CPU fair sheduler parameter CPUUNITS=\"1000\" CPUS=\"1\" CPULIMIT=\"10\" VE_ROOT=\"/var/lib/dtc-xen/mnt/${VPSNUM}\" VE_PRIVATE=\"/var/lib/vz/private/${VPSNUM}\" OSTEMPLATE=\"ubuntu-8.0-standard_8.04-1_i386\" ORIGIN_SAMPLE=\"\" IP_ADDRESS=\"${FIRST_IP}\" HOSTNAME=\"${VPS_FQDN}\" DESCRIPTION=\"\" NAMESERVER=\"${DNS}\" SEARCHDOMAIN=\"\" NETIF=\"ifname=venet0,mac=${XEN_WRITE_MAC},host_mac=${XEN_WRITE_MAC}\" " >/etc/vz/conf/${VPSNAME} dtc-xen-0.5.17/src/dtc_kill_vps_disk0000755000175000017500000000476511736663746016113 0ustar zigozigo#!/bin/sh if [ $# -lt 1 ]; then echo "Usage: $0 [lvm/vbd]" exit fi # Things that often change # Source the configuration in the config file! if [ -f /etc/dtc-xen/dtc-xen.conf ] ; then . /etc/dtc-xen/dtc-xen.conf fi # Figure out the VPS mount point if [ -n "$provisioning_mount_point" ] then VPSGLOBPATH="$provisioning_mount_point" else VPSGLOBPATH="$VPS_MOUNTPOINT" fi # Things that most of then time don't change VPSNUM=$1 VPSNAME=xen${VPSNUM} VPSHOSTNAME=xen${NODE_NUM}${VPSNUM} IMAGE_TYPE=$2 if [ -z "$IMAGE_TYPE" ] ; then IMAGE_TYPE=lvm ; fi # Figure out the LVM name from dtc-xen.conf if [ "$IMAGE_TYPE" = "lvm" ] ; then LVMNAME=`dtc-xen-volgroup` [ -z "$LVMNAME" ] && { echo "Could not determine volume group from which to provision the volume" 1>&2 echo "You might want to set provisioning_volgroup in dtc-xen.conf" 1>&2 exit 78 } fi FSTAB_LVMNAME=`echo ${LVMNAME} | sed -e 's/-/--/g'` # redirect stdout and stderr to log files, so we can see what happened during install echo "Redirecting standard output to $VPSGLOBPATH/$VPSNUM.stdout..." echo "Redirecting standard error to $VPSGLOBPATH/$VPSNUM.stderr..." if [ -e $VPSGLOBPATH/$VPSNUM.setuplvm.stdout ]; then mv $VPSGLOBPATH/$VPSNUM.setuplvm.stdout $VPSGLOBPATH/$VPSNUM.setuplvm.stdout.old fi if [ -e $VPSGLOBPATH/$VPSNUM.setuplvm.stderr ]; then mv $VPSGLOBPATH/$VPSNUM.setuplvm.stderr $VPSGLOBPATH/$VPSNUM.setuplvm.stderr.old fi exec 1>$VPSGLOBPATH/$VPSNUM.setuplvm.stdout exec 2>$VPSGLOBPATH/$VPSNUM.setuplvm.stderr if [ -x /sbin/lvcreate -a /sbin/lvremove ] ; then LVCREATE=/sbin/lvcreate LVREMOVE=/sbin/lvremove else if [ -x /usr/sbin/lvcreate -a /usr/sbin/lvremove ] ; then LVCREATE=/usr/sbin/lvcreate LVREMOVE=/usr/sbin/lvremove else echo "Could not find lvcreate and lvremove binaries!" > /dev/stderr exit 1 fi fi echo "Seleted ${VPSNAME}"; echo "Destroying disks..." if [ ""$IMAGE_TYPE = "lvm" ]; then # Remove existing partitions if they existed if [ -L /dev/${LVMNAME}/${VPSNAME} ] ; then $LVREMOVE -f /dev/${LVMNAME}/${VPSNAME} fi if [ -L /dev/${LVMNAME}/${VPSNAME}swap ] ; then $LVREMOVE -f /dev/${LVMNAME}/${VPSNAME}swap fi else if [ -e ${VPSGLOBPATH}/${VPSNAME}.img ]; then umount ${VPSGLOBPATH}/${VPSNAME}.img rm ${VPSGLOBPATH}/${VPSNAME}.img fi if [ -e ${VPSGLOBPATH}/${VPSNAME}.swap.img ]; then umount ${VPSGLOBPATH}/${VPSNAME}.swap.img rm ${VPSGLOBPATH}/${VPSNAME}.swap.img fi fi # Remove the auto start file if [ -f /etc/xen/auto/${VPSNAME} ] ; then rm /etc/xen/auto/${VPSNAME} fi dtc-xen-0.5.17/src/dtc_reinstall_os0000755000175000017500000006765111736663746015757 0ustar zigozigo#!/bin/sh set -e # DIE on errors ######################### ### MANAGE PARAMETERS ### ######################### if [ $# -lt 5 ]; then echo "Usage: $0 [ OPTIONS ] "> /dev/stderr echo "Parameters are (in any order):"> /dev/stderr echo " -vpsid : A number between 01 and 99"> /dev/stderr echo " -ram : RAM size of the VPS in MB"> /dev/stderr echo " -nic [,[,]] : At least one -nic, can be multiple times"> /dev/stderr echo " -pass : root pass for the VPS OS"> /dev/stderr echo " -os : System to setup"> /dev/stderr echo " [ -gw ] : Default gateway"> /dev/stderr echo " [ -dns [,] ] : Default DNS server(s) in /etc/resolv.conf"> /dev/stderr echo "-------------------------------------------------------------------------" > /dev/stderr echo "All what is not enclosed with [] is mandatory!" > /dev/stderr echo "You have to provide at least ONE -nic options, as dtc-xen doesn't support bootstraping" > /dev/stderr echo "an operating system without a network setup" > /dev/stderr echo "If the netmask and broadcast are omited, the setup of the host OS will be used" > /dev/stderr echo "-------------------------------------------------------------------------" > /dev/stderr echo "" > /dev/stderr echo " can be one of the follwing:" > /dev/stderr echo "debian, debian-dtc, centos, neoshine, netbsd, xenhvm, manual" > /dev/stderr echo "or one of the operating system image names present in /usr/share/dtc-xen-os" > /dev/stderr echo "or one of the appliances folder names present in /usr/share/dtc-xen-app" > /dev/stderr echo "" > /dev/stderr echo "Options:" > /dev/stderr echo " [ -v ] : Print the log in the standard output" > /dev/stderr echo "General options:" > /dev/stderr echo " [ --disk-type lvm|vdb ] : Use LVM partition or disk image" > /dev/stderr echo " [ --initrd /dev/stderr echo " [ --kernel /dev/stderr echo " [ --kernel-release ] : Path to the kernel modules folder" > /dev/stderr echo " [ --kmod-path ] : Path to the kernel modules folder" > /dev/stderr echo " [ --initrd /dev/stderr echo " [ --vps-fqdn ] : Customizes the hostname of the VPS" > /dev/stderr echo " [ --mac ] : MAC address of the VPS" echo " [ --bridge ] : Network Bridge" > /dev/stderr echo " [ --maxmem ] : Maximum domain memory in MB" > /dev/stderr echo " [ --vcpus ] : Number of vcpus" > /dev/stderr echo " [ --cpus ] : CPU settings" > /dev/stderr echo " [ --cpucap ] : Set the maximum amount of cpu" > /dev/stderr echo " [ --cpuweight ] : Set the cpu time ratio to be allocated to the domain" > /dev/stderr echo " [ --pae 0|1 ] : Disable or enable PAE of HVM domain " > /dev/stderr echo " [ --acpi 0|1 ] : Disable or enable ACPI of HVM domain" > /dev/stderr echo " [ --apic 0|1 ] : Disable or enable APIC mode " > /dev/stderr echo " [ --keymap ] : Set keyboard layout used " > /dev/stderr echo " [ --locale ] : Set locale" > /dev/stderr echo " [ --virt-type ] : Virtualization (for the moment, xen or vz only)" > /dev/stderr echo "Options specific to Xen HVM guests:" > /dev/stderr echo " [ --vnc-pass ] : VNC password for the physical console" > /dev/stderr echo " [ --boot-iso ] : CDROM device to boot on" > /dev/stderr echo "" > /dev/stderr echo "-------------------------------------------------------------------------" > /dev/stderr echo "Example1: $0 -v -vpsid 01 -ram 512 -nic 192.168.2.176,255.255.255.0,192.168.2.255 -pass MyRootPass -os debian -gw 192.168.2.1 -dns 192.168.2.1" > /dev/stderr echo "" > /dev/stderr echo "Example2: $0 -vpsid 02 -ram 512 -nic 192.168.9.2 -nic 192.168.9.3 -gw 192.168.9.1 \\" > /dev/stderr echo " -dns 192.168.9.1 -pass MyRootPass -os kde-nx-server-3.3.0" > /dev/stderr exit 1 fi # Source the configuration in the config file! if [ -f /etc/dtc-xen/dtc-xen.conf ] ; then . /etc/dtc-xen/dtc-xen.conf fi if [ -n "$debian_release" ] ; then DEBIAN_RELEASE="$debian_release" ; fi if [ -n "$debian_repo" ] ; then DEBIAN_REPOS="$debian_repo" ; fi # Some defaults if not present in the conf file... if [ -z "$DEBIAN_RELEASE" ] ; then DEBIAN_RELEASE=lenny ; fi if [ -z "$DEBIAN_REPOS" ] ; then DEBIAN_REPOS="http://ftp.us.debian.org/debian/" ; fi # Manage options in any order... DO_EXIT="no" NUM_NIC=0 REDIRECTOUTPUT=true VNC_PASSWORD=`dd if=/dev/random bs=64 count=1 2>|/dev/null | md5sum | cut -d' ' -f1` for i in $@ ; do # echo "Found option: ${1} ${2}" case "${1}" in "--short-circuit") # This one is for debug purposes, do not use... SHORT_CIRCUIT="yes" shift ;; "-vpsid") if [ -z "${2}" ] ; then echo "Parameter for option -vpsid is missing" > /dev/stderr ; DO_EXIT="yes" ; fi VPSNUM="${2}" shift shift ;; "-ram") if [ -z "${2}" ] ; then echo "Parameter for option -ram is missing" > /dev/stderr ; DO_EXIT="yes" ; fi VPSMEM="${2}" shift shift ;; "--mac") MAC_ADDR="${2}" shift shift ;; "--bridge") XEN_BR="${2}" shift shift ;; "--maxmem") MAXMEM="${2}" shift shift ;; "--vcpus") VCPUS="${2}" shift shift ;; "--cpus") CPUS="${2}" shift shift ;; "--cpucap") CPUCAP="${2}" shift shift ;; "--cpuweight") CPUWEIGHT="${2}" shift shift ;; "--pae") PAE="${2}" shift shift ;; "--acpi") ACPI="${2}" shift shift ;; "--apic") APIC="${2}" shift shift ;; "--keymap") KEYMAP="${2}" shift shift ;; "--locale") LOCALE="${2}" shift shift ;; "-nic") if [ -z "${2}" ] ; then echo "Parameter for option -nic is missing" > /dev/stderr ; exit 1 ; fi # Manage the nics to give it as parameters to the setup-vps-network script PARAM=${2} PARAM_TMP=${2} if [ -z ""`echo ${PARAM} | cut -s -d"," -f2` ] ; then if [ -z "${NETMASK}" ] ; then echo "Parameter NETMASK not found: either edit /etc/dtc-xen/dtc-xen.conf or use a netmask parameter" > /dev/stderr ; exit 1 fi PARAM="${PARAM},${NETMASK}" fi if [ -z ""`echo ${PARAM_TMP} | cut -s -d"," -f3` ] ; then if [ -z "${BROADCAST}" ] ; then echo "Parameter BROADCAST not found: either edit /etc/dtc-xen/dtc-xen.conf or use a broadcast parameter" > /dev/stderr ; exit 1 fi PARAM="${PARAM},${BROADCAST}" fi if [ "${NUM_NIC}" = 0 ] ; then ALL_IPADDRS=`echo ${PARAM} | cut -d"," -f1` FW_NICS_CMD="-nic ${PARAM}" NICS=${PARAM} else ALL_IPADDRS="${ALL_IPADDRS} "`echo ${PARAM} | cut -d"," -f1` FW_NICS_CMD="${FW_NICS_CMD} -nic ${PARAM}" NICS=$NICS" "${PARAM} fi NUM_NIC=$(( ${NUM_NIC} + 1 )) shift shift ;; "-pass") if [ -z "${2}" ] ; then echo "Parameter for option -pass is missing" > /dev/stderr ; DO_EXIT="yes" ; fi PASSWORD=${2} shift shift ;; "-os") if [ -z "${2}" ] ; then echo "Parameter for option -os is missing" > /dev/stderr ; DO_EXIT="yes" ; fi DISTRO=${2} shift shift ;; "-gw") if [ -z "${2}" ] ; then echo "Parameter for option -gw is missing" > /dev/stderr ; DO_EXIT="yes" ; fi GATEWAY="$2" shift shift ;; "-v") REDIRECTOUTPUT=false shift ;; "--vnc-pass") if [ -z "${2}" ] ; then echo "Parameter for option --vnc-pass is missing" > /dev/stderr ; DO_EXIT="yes" ; fi VNC_PASSWORD="$2" shift shift ;; "--boot-iso") if [ -z "${2}" ] ; then echo "Parameter for option --boot-iso is missing" > /dev/stderr ; DO_EXIT="yes" ; fi BOOT_ISO="$2" shift shift ;; "-dns") DNS=${2} shift shift ;; "--vps-fqdn") if [ -z "${2}" ] ; then echo "Parameter for option --vps-fqdn is missing" > /dev/stderr ; DO_EXIT="yes" ; fi VPS_FQDN=${2} shift shift ;; "--vps-domain") if [ -z "${2}" ] ; then echo "Parameter for option --vps-domain is missing" > /dev/stderr ; DO_EXIT="yes" ; fi VPS_DOMAIN=${2} shift shift ;; "--virt-type") if [ -z "${2}" ] ; then echo "Parameter for option --virt-type is missing" > /dev/stderr ; DO_EXIT="yes" ; fi VIRT_TYPE=${2} shift shift ;; "--kernel") if [ -z "${2}" ] ; then echo "Parameter for option --kernel is missing" > /dev/stderr ; DO_EXIT="yes" ; fi KERNELPATH="$2" shift shift ;; "--kernel-release") if [ -z "${2}" ] ; then echo "Parameter for option --kernel-release is missing" > /dev/stderr ; DO_EXIT="yes" ; fi KERNEL_RELEASE=${2} shift shift ;; "--kmod-path") if [ -z "${2}" ] ; then echo "Parameter for option --kmod-path is missing" > /dev/stderr ; DO_EXIT="yes" ; fi KMOD_PATH=${2} shift shift ;; "--initrd") if [ -z "${2}" ] ; then echo "Parameter for option --initrd is missing" > /dev/stderr ; DO_EXIT="yes" ; fi INITRDPATH=${2} shift shift ;; "--disk-type") if [ -z "${2}" ] ; then echo "Parameter for option --disk-type is missing" > /dev/stderr ; DO_EXIT="yes" ; fi IMAGE_TYPE=${2} shift shift ;; *) ;; esac done # Detect the virtualization type if not are given on the command line if [ -z "${VIRT_TYPE}" ] ; then if [ -d /proc/xen ] ; then VIRT_TYPE="xen" fi if [ -d /proc/vz ] ; then VIRT_TYPE="vz" fi fi if [ -z "${VIRT_TYPE}" ] ; then echo "Could not find /proc/xen or /proc/vz: impossible to tell if Xen or VZ is running. Will exit now" > /dev/stderr DO_EXIT="yes" fi # Default to using xvdX and not sdaX if [ -z "${XEN_DOMU_HDD_DEV_TYPE}" ] ; then XEN_DOMU_HDD_DEV_TYPE=xvd fi if [ -z "${VPSNUM}" ] ; then echo "No VPS number. Please use -vpsid ." > /dev/stderr DO_EXIT="yes" fi if [ -z "${VPSMEM}" ] ; then echo "No RAM size. Please use -ram " > /dev/stderr DO_EXIT="yes" fi if [ -z "${GATEWAY}" ] ; then echo "No gateway ip. Please use -gw or edit /etc/dtc-xen/dtc-xen.conf" > /dev/stderr DO_EXIT="yes" fi if [ -z "${PASSWORD}" ] ; then echo "No root pass. Please use -pass " > /dev/stderr DO_EXIT="yes" fi if [ -z "${DISTRO}" ] ; then echo "No distribution selected, please use -os " > /dev/stderr DO_EXIT="yes" fi if [ -z "${KERNELPATH}" ] ; then TESTME=/boot/vmlinuz-`uname -r` if [ -e ${TESTME} ] ; then KERNELPATH=${TESTME} else echo "No kernel was found. Either use --kernel, or define a KERNELPATH in /etc/dtc-xen/dtc-xen.conf, or make sure you have installed Xen" > /dev/stderr fi fi if [ -z "${KERNEL_RELEASE}" ] ; then KERNEL_RELEASE=`uname -r` fi if [ -z "${KMOD_PATH}" ] ; then TESTME=/lib/modules/`uname -r` if [ -e ${TESTME} ] ; then KMOD_PATH=/lib/modules/`uname -r` else echo "No kernel was found. Either use --kmod-path, or define a KMOD_PATH in /etc/dtc-xen/dtc-xen.conf, or make sure you have installed Xen" > /dev/stderr fi fi if [ -z "${INITRDPATH}" ] ; then TESTME=/boot/initrd.img-`uname -r` if [ -e "${TESTME}" ] ; then INITRDPATH=${TESTME} else TESTME=/boot/initrd-`uname -r`.img if [ -e "${TESTME}" ] ; then INITRDPATH=${TESTME} else echo "WARNING! No initrd image found! Will continue without an initial ramdisk image." > /dev/stderr fi fi fi if [ -z "${DNS}" ] ; then DNS=`grep "nameserver" /etc/resolv.conf | head -n 1 | cut -d" " -f2` echo "WARNING! No dns defined, guessed: ${DNS}" fi if [ ${DO_EXIT} = "yes" ] ; then echo "Parameters not validated: will exit now!" > /dev/stderr exit 1 fi # Figure out the VPS mount point if [ -n "${provisioning_mount_point}" ] ; then VPSGLOBPATH="${provisioning_mount_point}" else VPSGLOBPATH="$VPS_MOUNTPOINT" fi if [ -z "${IMAGE_TYPE}" ] ; then IMAGE_TYPE=lvm fi # Figure out the LVM name from dtc-xen.conf if [ "${IMAGE_TYPE}" = "lvm" ] ; then LVMNAME=`dtc-xen-volgroup` if [ -z "$LVMNAME" ] ; then echo "Could not determine volume group from which to provision the volume" 1>&2 echo "You might want to set provisioning_volgroup in dtc-xen.conf" 1>&2 exit 78 fi fi FSTAB_LVMNAME=`echo ${LVMNAME} | sed -e 's/-/--/g'` # Finds the kernel name if [ -z "${KERNELPATH}" ] ; then if [ -e /boot/vmlinuz-`uname -r` ] ; then KERNELPATH=/boot/vmlinuz-`uname -r` fi fi if [ -z "${KERNELPATH}" ] ; then echo "Could not find the kernel image file!" 1>&2 exit 78 fi VPSNAME=xen${VPSNUM} NODE_FQDN=`hostname --fqdn` # Manuel, what we have been discussing about using mx.xenXX.dom0-fqdn or xenXX.dom0-fqdn by default # is right here! I believe we should give an entire domain to each VPS, so I want "mx.", but maybe # can make this configurable, there's an option now as you see, this is just the default... if [ -z "${VPS_DOMAIN}" ] ; then VPS_DOMAIN="${VPSNAME}.${NODE_FQDN}" fi if [ -z "${VPS_FQDN}" ] ; then VPS_FQDN="mx.${VPS_DOMAIN}" fi if [ -z "${MAC_ADDR}" ] ; then if [ ! -z "${vps_mac_prefix}" ] ; then MAC_ADDR=${vps_mac_prefix}:${VPSNUM} fi fi if [ -z "${XEN_BR}" ] ; then if [ ! -z "${bridge}" ] ; then XEN_BR=${bridge} fi fi FOUNDED_ARCH=`uname -m` case "$FOUNDED_ARCH" in i386) DEBIAN_BINARCH=i386 CENTOS_BINARCH=i386 ;; i436) DEBIAN_BINARCH=i386 CENTOS_BINARCH=i386 ;; i586) DEBIAN_BINARCH=i386 CENTOS_BINARCH=i386 ;; i686) DEBIAN_BINARCH=i386 CENTOS_BINARCH=i386 ;; x86_64) DEBIAN_BINARCH=amd64 CENTOS_BINARCH=x86_64 ;; *) echo "Unrecognized arch: exiting!" exit 1 ;; esac # default distro to debian if [ -z "$DISTRO" ]; then DISTRO=debian fi LVCREATE=/sbin/lvcreate MKFS=/sbin/mkfs.ext3 MKDIR=/bin/mkdir MKSWAP=/sbin/mkswap MOUNT=/bin/mount UMOUNT=/bin/umount DEBOOTSTRAP=/usr/sbin/debootstrap # We forward always this list of parameters to all scripts: calc_formard_parms (){ HVM_PARMS="" if [ -z "${VNC_PASSWORD}" ] ; then HVM_PARMS="--vnc-pass ${VNC_PASSWORD}" fi if [ -z "${BOOT_ISO}" ] ; then HVM_PARMS="${HVM_PARMS} --boot-iso ${BOOT_ISO}" fi KERNEL_P="--kernel ${KERNELPATH} --kernel-release ${KERNEL_RELEASE} --kmod-path ${KMOD_PATH} --initrd ${INITRDPATH}" FW_PARAMS="--disk-type ${IMAGE_TYPE} --xen-domu-hdd-dev-type ${XEN_DOMU_HDD_DEV_TYPE} -os ${DISTRO} -ram ${VPSMEM} -path ${VPSGLOBPATH}/${VPSNUM} -vpsid ${VPSNUM} --vps-fqdn ${VPS_FQDN} --vps-domain ${VPS_DOMAIN} --node-fqdn ${NODE_FQDN} ${FW_NICS_CMD} -dns ${DNS} -gw ${GATEWAY} --virt-type ${VIRT_TYPE} ${KERNEL_P}" if [ -n "${MAC_ADDR}" ] ; then FW_PARAMS="${FW_PARAMS} --mac ${MAC_ADDR}" fi if [ -n "${XEN_BR}" ] ; then FW_PARAMS="${FW_PARAMS} --bridge ${XEN_BR}" fi if [ -n "${MAXMEM}" ] ; then FW_PARAMS="${FW_PARAMS} --maxmem ${MAXMEM}" fi if [ -n "${VCPUS}" ] ; then FW_PARAMS="${FW_PARAMS} --vcpus ${VCPUS}" fi if [ -n "${CPUS}" ] ; then FW_PARAMS="${FW_PARAMS} --cpus ${CPUS}" fi if [ -n "${CPUCAP}" ] ; then FW_PARAMS="${FW_PARAMS} --cpucap ${CPUCAP}" fi if [ -n "${CPUWEIGHT}" ] ; then FW_PARAMS="${FW_PARAMS} --cpuweight ${CPUWEIGHT}" fi if [ -n "${PAE}" ] ; then FW_PARAMS="${FW_PARAMS} --pae ${PAE}" fi if [ -n "${ACPI}" ] ; then FW_PARAMS="${FW_PARAMS} --acpi ${ACPI}" fi if [ -n "${APIC}" ] ; then FW_PARAMS="${FW_PARAMS} --apic ${APIC}" fi if [ -n "${KEYMAP}" ] ; then FW_PARAMS="${FW_PARAMS} --keymap ${KEYMAP}" fi if [ -n "${LOCALE}" ] ; then FW_PARAMS="${FW_PARAMS} --locale ${LOCALE}" fi if [ -z "${HVM_PARMS}" ] ; then FW_PARAMS="${FW_PARAMS} ${HVM_PARMS}" fi if [ -z "${LVMNAME}" ] ; then FW_PARAMS="${FW_PARAMS} --lvm-name ${LVMNAME}" fi if [ -n "${XENU_EXTRA_PARM}" ] ; then FW_PARAMS="${FW_PARAMS} --xenu_extra_parm ${XENU_EXTRA_PARM}" fi } calc_formard_parms ##################################################### ### Check / creation of the DTC-Xen user / group #### ##################################################### GETENT=getent XENUSERS=xenusers XEN_USER_HOME=/var/lib/dtc-xen/ttyssh_home if ${GETENT} passwd xen${VPSNUM} >/dev/null ; then echo "User xen${VPSNUM} already exists: skipping creation!" else if [ -x /usr/sbin/useradd ] ; then if [ ! -x /bin/bash ] ; then echo "Could not find the bash shell!" exit 1 fi /usr/sbin/useradd --home "${XEN_USER_HOME}/xen${VPSNUM}" -m -s /usr/bin/dtc-xen_userconsole -g ${XENUSERS} xen${VPSNUM} else echo "Cound not find the useradd binary!" exit 1 fi fi # Modify an eventual wrong old config mkdir -p "${XEN_USER_HOME}/xen${VPSNUM}/.ssh" chown -R xen${VPSNUM}:${XENUSERS} "${XEN_USER_HOME}/xen${VPSNUM}" usermod -d "${XEN_USER_HOME}/xen${VPSNUM}" -g ${XENUSERS} -s /usr/bin/dtc-xen_userconsole xen${VPSNUM} ###################################### ### REDIRECTION OF STANDARD OUTPUT ### ###################################### # redirect stdout and stderr to log files, so we can see what happened during install if [ "$REDIRECTOUTPUT" = "true" ] ; then echo "Redirecting standard output to $VPSGLOBPATH/$VPSNUM.stdout..." echo "Redirecting standard error to $VPSGLOBPATH/$VPSNUM.stderr..." if [ -e $VPSGLOBPATH/$VPSNUM.stdout ]; then mv $VPSGLOBPATH/$VPSNUM.stdout $VPSGLOBPATH/$VPSNUM.stdout.old fi if [ -e $VPSGLOBPATH/$VPSNUM.stderr ]; then mv $VPSGLOBPATH/$VPSNUM.stderr $VPSGLOBPATH/$VPSNUM.stderr.old fi exec 1>$VPSGLOBPATH/$VPSNUM.stdout exec 2>$VPSGLOBPATH/$VPSNUM.stderr fi ############################ ### FORMAT THE PARTITION ### ############################ if ! [ "${VIRT_TYPE}" = "vz" -a -n "${VZ_NO_MOUNT}" ] ; then if [ "${DISTRO}" = "xenhvm" ] ; then echo "Not formating disks, xen HVM will use emulated hard drives." elif [ "$DISTRO" = "netbsd" ] ; then echo "Not formating disks, NetBSD will use emulated hard drives." else echo "Creating disks..." set +e $UMOUNT ${VPSGLOBPATH}/${VPSNUM} 2> /dev/null rmdir ${VPSGLOBPATH}/${VPSNUM} 2> /dev/null set -e $MKDIR -p ${VPSGLOBPATH}/${VPSNUM} if [ "$IMAGE_TYPE" = "lvm" ]; then if [ -z "${SHORT_CIRCUIT}" ] ; then $MKFS -q /dev/${LVMNAME}/${VPSNAME} $MKSWAP /dev/${LVMNAME}/${VPSNAME}swap else echo "Not doing MKFS: debuging..." fi if grep ${VPSNAME} /etc/fstab >/dev/null ; then echo "LV already exists in fstab: skipping" else echo "/dev/mapper/${FSTAB_LVMNAME}-${VPSNAME} ${VPSGLOBPATH}/${VPSNUM} ext3 defaults,noauto 0 0" >>/etc/fstab fi else # support for file backed VPS # Create files for hdd and swap (only if they don't exist) if [ ! -e $VPSGLOBPATH/${VPSNAME}.img ]; then dd if=/dev/zero of=$VPSGLOBPATH/${VPSNAME}.img bs=1G seek=${VPSHDD} count=1 fi $MKFS -F $VPSGLOBPATH/${VPSNAME}.img if [ ! -e $VPSGLOBPATH/${VPSNAME}.swap.img ]; then dd if=/dev/zero of=$VPSGLOBPATH/${VPSNAME}.swap.img bs=1M seek=${VPSMEM} count=1 fi $MKSWAP $VPSGLOBPATH/${VPSNAME}.swap.img if grep ${VPSNAME} /etc/fstab >/dev/null ; then echo "LoopMount already exists in fstab: skipping" else echo "$VPSGLOBPATH/${VPSNAME}.img ${VPSGLOBPATH}/${VPSNUM} ext3 defaults,noauto,loop 0 0" >>/etc/fstab fi fi if ! [ "${VIRT_TYPE}" = "vz" -a -n "${VZ_NO_MOUNT}" ] ; then echo "Mounting..." $MOUNT ${VPSGLOBPATH}/${VPSNUM} fi fi fi #################### ### BOOTSTRAPING ### #################### echo "Bootstraping..." # Search if we are installing an appliance that depends on a particular distribution APPLIANCE="" if [ -e /usr/share/dtc-xen-app/${DISTRO}/depends ] ; then APPLIANCE="${DISTRO}" DISTRO=`cat /usr/share/dtc-xen-app/${DISTRO}/depends` fi # Rebuild the params since DISTRO might have change if we use appliances. calc_formard_parms if [ "$DISTRO" = "xenhvm" -o "$DISTRO" = "netbsd" ] ; then echo "There's nothing to bootstrap, as you will use the provided distribution installer in this case." elif [ "$DISTRO" = "centos" -o "$DISTRO" = "neoshine" ] ; then if [ -z "${SHORT_CIRCUIT}" ] ; then if [ "$DISTRO" = "centos" ] ; then /usr/sbin/dtc_install_centos /var/lib/dtc-xen/yum "$VPSGLOBPATH/$VPSNUM" else /usr/sbin/dtc_install_neoshine /var/lib/dtc-xen/yum "$VPSGLOBPATH/$VPSNUM" fi # Copy the CentOS inittab if dom0 is CentOS as well, otherwise no console... if [ -f /etc/redhat-release ] ; then cp /etc/dtc-xen/inittab $VPSGLOBPATH/$VPSNUM/etc fi else echo "Not bootstraping: debuging..." fi elif [ "$DISTRO" = "debian" -o "$DISTRO" = "debian-dtc" ] ; then if [ ${DEBIAN_BINARCH} = "i386" ] ; then ADD_LIBC="libc6-xen," else ADD_LIBC="" fi if [ -z "${SHORT_CIRCUIT}" ] ; then if [ -z "${debian_added_debs}" ] ; then debian_added_debs=module-init-tools,locales,udev,joe,screen fi echo $DEBOOTSTRAP --verbose --include=${ADD_LIBC}${debian_added_debs} --arch ${DEBIAN_BINARCH} ${DEBIAN_RELEASE} ${VPSGLOBPATH}/${VPSNUM} ${DEBIAN_REPOS} $DEBOOTSTRAP --verbose --include=${ADD_LIBC}${debian_added_debs} --arch ${DEBIAN_BINARCH} ${DEBIAN_RELEASE} ${VPSGLOBPATH}/${VPSNUM} ${DEBIAN_REPOS} || debret=$? else echo "Not bootstraping: debuging..." fi if [ "$debret" != "" ]; then echo "Failed to install $DISTRO via bootstrap!!" exit $debret fi else if [ -e /usr/share/dtc-xen-os/${DISTRO}/install_os ] ; then /usr/share/dtc-xen-os/${DISTRO}/install_os ${FW_PARAMS} else echo "Currently, you will have to manually install your distro... sorry :)" echo "The filesystem is mounted on ${VPSGLOBPATH}/${VPSNUM}" echo "Remember to unmount (umount ${VPSGLOBPATH}/${VPSNUM}) before booting the OS" echo "if you are not running VZ." echo "Cheers!" exit fi fi ######################## ### OS CUSTOMIZATION ### ######################## echo "Customizing vps fstab, hosts and hostname for distro ${DISTRO}..." if [ "$DISTRO" = "debian" -o "$DISTRO" = "debian-dtc" -o "$DISTRO" = "centos" -o "$DISTRO" = "neoshine" ] ; then /usr/sbin/dtc-xen_domUconf_standard ${FW_PARAMS} if [ "$DISTRO" = "debian" -o "$DISTRO" = "debian-dtc" ] ; then sed "s/VPS_HOSTNAME/${VPS_FQDN}/" /etc/dtc-xen/motd >${VPSGLOBPATH}/${VPSNUM}/etc/motd.tail fi else if [ -x /usr/share/dtc-xen-os/${DISTRO}/custom_os ] ; then /usr/share/dtc-xen-os/${DISTRO}/custom_os ${FW_PARAMS} fi fi if [ "$DISTRO" = "netbsd" -o "$DISTRO" = "xenhvm" ] ; then echo "Not changing password for netbsd or xenhvm!" else echo -n "Setting root password..." chroot ${VPSGLOBPATH}/${VPSNUM} sh -c "echo root:$PASSWORD | chpasswd" if [ $? -eq 0 ] ; then echo "[OK]" else echo "[FAIL]" fi fi #################################### ### NETWORK CONFIG CUSTOMIZATION ### #################################### # handle the network setup echo "Setting-up network for distro ${DISTRO}..." if [ "$DISTRO" = "netbsd" -o "$DISTRO" = "xenhvm" ] ; then echo "Nothing to do: it's BSD or xenhvm!" elif [ "$DISTRO" = "centos" -o "$DISTRO" = "neoshine" ] ; then /usr/sbin/dtc-xen_domUconf_network_redhat ${FW_PARAMS} elif [ "$DISTRO" = "debian" -o "$DISTRO" = "debian-dtc" ] ; then /usr/sbin/dtc-xen_domUconf_network_debian ${FW_PARAMS} if [ -f /etc/dtc-xen/sources.list ] ; then cp /etc/dtc-xen/sources.list ${VPSGLOBPATH}/${VPSNUM}/etc/apt else cp /etc/apt/sources.list ${VPSGLOBPATH}/${VPSNUM}/etc/apt fi else if [ -x /usr/share/dtc-xen-os/${DISTRO}/setup_network ] ; then /usr/share/dtc-xen-os/${DISTRO}/setup_network ${FW_PARAMS} else echo "Not implemented for other distros yet" exit 1 fi fi ################################# ### XEN STARTUP FILE CREATION ### ################################# if [ "${VIRT_TYPE}" = "xen" ] ; then /usr/sbin/dtc-xen_domU_gen_xen_conf ${FW_PARAMS} fi if [ "${VIRT_TYPE}" = "vz" ] ; then /usr/sbin/dtc-xen_domU_gen_vz_conf ${FW_PARAMS} fi ######################## ### SOME LAST THINGS ### ######################## # need to install 2.6 compat stuff for centos3 if [ "$DISTRO" = "centos" -a "$CENTOS_RELEASE" = "neoshine" ]; then mkdir -p ${VPSGLOBPATH}/${VPSNUM}/tmp wget -O ${VPSGLOBPATH}/${VPSNUM}/tmp/yum.conf.mini ftp://ftp.pasteur.fr/pub/BIS/tru/2.6_CentOS-3/yum.conf.mini chroot ${VPSGLOBPATH}/${VPSNUM} yum -c /tmp/yum.conf.mini -y update chroot ${VPSGLOBPATH}/${VPSNUM} yum -c /tmp/yum.conf.mini install initscripts_26 chroot ${VPSGLOBPATH}/${VPSNUM} rm /tmp/yum.conf.mini fi # Remove the persistent-net udev config, so the eth wont get renamed # when changing MAC, which is extremely not cool when migrating a VM if [ "$DISTRO" = "debian-dtc" -o "$DISTRO" = "debian" ] ; then rm -f ${VPSGLOBPATH}/${VPSNUM}/etc/udev/rules.d/z25_persistent-net.rules rm -f ${VPSGLOBPATH}/${VPSNUM}/etc/udev/rules.d/70-persistent-net.rules fi if [ "$DISTRO" = "debian-dtc" ] ; then cp /usr/share/dtc-xen/dtc-panel_autodeploy.sh ${VPSGLOBPATH}/${VPSNUM}/root/dtc-panel_autodeploy chmod +x ${VPSGLOBPATH}/${VPSNUM}/root/dtc-panel_autodeploy cp /usr/share/dtc-xen/selection_config_file ${VPSGLOBPATH}/${VPSNUM}/root # We don't want the devices to be created, as this would fail in VZ (to be checked...) if [ "${VIRT_TYPE}" = "vz" ] ; then echo "dtc-postfix-courier dtc/conf_omit_dev_mknod boolean true dtc-postfix-courier dtc/conf_omit_dev_mknod seen true" >>${VPSGLOBPATH}/${VPSNUM}/root/selection_config_file fi echo "#!/bin/sh ### BEGIN INIT INFO # Provides: dtc-panel_autodeploy # Required-Start: $remote_fs # Required-Stop: $remote_fs # Should-Start: $network $syslog # Should-Stop: $network $syslog # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: Automatically installs DTC # Description: Automatically installs DTC # uppon boot time ### END INIT INFO case \"\$1\" in start) cd /root /root/dtc-panel_autodeploy ${PASSWORD} update-rc.d -f dtc-panel_autodeploy remove ;; *) echo -n "" ;; esac exit 0 " >${VPSGLOBPATH}/${VPSNUM}/etc/init.d/dtc-panel_autodeploy chmod +x ${VPSGLOBPATH}/${VPSNUM}/etc/init.d/dtc-panel_autodeploy chroot ${VPSGLOBPATH}/${VPSNUM} update-rc.d dtc-panel_autodeploy defaults fi ########################################## ### SETUP APPLIANCE SCRIPT AND FOLDERS ### ########################################## if [ ! -z "${APPLIANCE}" ] ; then echo "Setting up appliance boot-stage setup script ${APPLIANCE}..." cp /usr/share/dtc-xen-app/${APPLIANCE}/setup-script ${VPSGLOBPATH}/${VPSNUM}/root/dtc-xen-appliance-setup if [ -e /usr/share/dtc-xen-app/${APPLIANCE}/setup-folder ] ; then cp -rf /usr/share/dtc-xen-app/${APPLIANCE}/setup-folder ${VPSGLOBPATH}/${VPSNUM}/root/ fi echo "#!/bin/sh cd /root /root/dtc-xen-appliance-setup ${PASSWORD} rm /etc/rc2.d/S99dtc-xen-appliance rm /etc/rc3.d/S99dtc-xen-appliance rm /etc/rc4.d/S99dtc-xen-appliance rm /etc/rc5.d/S99dtc-xen-appliance rm /etc/init.d/dtc-xen-appliance " >${VPSGLOBPATH}/${VPSNUM}/etc/init.d/dtc-xen-appliance chmod +x ${VPSGLOBPATH}/${VPSNUM}/etc/init.d/dtc-xen-appliance ln -s ../init.d/dtc-xen-appliance ${VPSGLOBPATH}/${VPSNUM}/etc/rc2.d/S99dtc-xen-appliance ln -s ../init.d/dtc-xen-appliance ${VPSGLOBPATH}/${VPSNUM}/etc/rc3.d/S99dtc-xen-appliance ln -s ../init.d/dtc-xen-appliance ${VPSGLOBPATH}/${VPSNUM}/etc/rc4.d/S99dtc-xen-appliance ln -s ../init.d/dtc-xen-appliance ${VPSGLOBPATH}/${VPSNUM}/etc/rc5.d/S99dtc-xen-appliance fi ############################################################### ### Custom postinstall script (user defined, not mandatory) ### ############################################################### if [ -n "${custom_postinstall_script}" ] ; then if [ -x ${custom_postinstall_script} ] ; then ${custom_postinstall_script} ${FW_PARAMS} fi fi #################################################### ### CUSTOM last_stage_postinst SCRIPT FOR DISTRO ### #################################################### echo "Setting-up network for distro ${DISTRO}..." if ! [ "$DISTRO" = "netbsd" -o "$DISTRO" = "xenhvm" -o "$DISTRO" = "centos" -o "$DISTRO" = "neoshine" -o "$DISTRO" = "debian" -o "$DISTRO" = "debian-dtc" ] ; then if [ -x /usr/share/dtc-xen-os/${DISTRO}/last_stage_custom ] ; then /usr/share/dtc-xen-os/${DISTRO}/last_stage_custom ${FW_PARAMS} fi fi ####################### ### UMOUNT AND EXIT ### ####################### if ! [ "${VIRT_TYPE}" = "vz" -o "$DISTRO" = "netbsd" -o "$DISTRO" = "xenhvm" ] ; then echo "Unmounting proc and filesystem root..." $UMOUNT ${VPSGLOBPATH}/${VPSNUM}/proc 2> /dev/null || /bin/true $UMOUNT ${VPSGLOBPATH}/${VPSNUM} fi echo "Install script finished: click on the installation tab on the left to refresh!" exit 0 dtc-xen-0.5.17/src/dtc-xen_domUconf_network_redhat0000755000175000017500000000221111736663746020700 0ustar zigozigo#!/bin/sh set -e . /usr/share/dtc-xen/dtc-xen-parse-param ETC="${VPS_PATH}/etc" if [ "${VIRT_TYPE}" = "vz" ] ; then ETHNAME_PREFIX=vnet else ETHNAME_PREFIX=eth fi # Configure the eth0 if [ ! -z "${NICS}" ] ; then N=0 for i in $NICS ; do N_IP=`echo ${i} | cut -s -d"," -f1` N_MASK=`echo ${i} | cut -s -d"," -f2` N_BCAST=`echo ${i} | cut -s -d"," -f3` N_NET=`ipcalc -n ${N_IP} ${N_MASK} | grep Network | awk '{print $2}' | cut -d"/" -f1` if [ -z "${N_NET}" ] ; then N_NET=`ipcalc -n ${N_IP} ${N_MASK} | cut -d"=" -f2` fi if [ ${N} = 0 ] ; then DEVICE="eth0" else DEVICE="eth0:${N}" fi echo "DEVICE=${DEVICE} BOOTPROTO=static BROADCAST=${N_BCAST} IPADDR=${N_IP} NETMASK=${N_MASK} NETWORK=${N_NET} ONBOOT=yes " >${ETC}/sysconfig/network-scripts/ifcfg-${DEVICE} N=$(( ${N} + 1 )) done # Set the gateway file echo "NETWORKING=yes HOSTNAME=mx.xen${VPSNUM}.${NODE_FQDN} GATEWAY=${GATEWAY} " >${ETC}/sysconfig/network fi # Set the resolv.conf echo "nameserver "`echo ${DNS} | cut -d"," -f1` > ${ETC}/resolv.conf if [ -z ""`echo ${DNS} | cut -s -d"," -f2` ] ; then echo `echo ${DNS} | cut -s -d"," -f2` >>${ETC}/resolv.conf fi dtc-xen-0.5.17/src/dtc-xen_finish_install0000755000175000017500000000455311736663746017047 0ustar zigozigo#!/bin/sh set -e echo "DISCLAIMER!" echo "This script is a helper to remove AllowTcpForwarding option from your" echo "/etc/ssh/sshd_config file, and allow the use of ssh for your users to" echo "reach /usr/bin/dtc-xen_userconsole, which will let them connect to the" echo "tty1 of their virtual machines." echo "This script isn't fail-proof, it is just a helper to setup things faster" echo "and it works if your ssh daemon has been freshly installed. If you aren't" echo "sure, you should inspect /etc/ssh/sshd_config and /etc/sudoers after you" echo "ran this script to make sure it fits your environment." echo "" # Modify the sudoers file if grep xenusers /etc/sudoers 2>&1 >/dev/null ; then echo "Sudoers already modified" else echo "Adding avaibility of dtc-xen_userconsole to xenusers in /etc/sudoers" echo "%xenusers ALL= NOPASSWD: /usr/sbin/xm console xen*" >>/etc/sudoers fi if grep "AllowTcpForwarding no" /etc/ssh/sshd_config ; then echo "Port forwarding seems to be disabled already!" else if grep "AllowTcpForwarding" /etc/ssh/sshd_config ; then echo "There is a AllowTcpForwarding but not to no: please disable port forwarding NOW!" else echo "AllowTcpForwarding no" >>/etc/ssh/sshd_config echo "Disabling ssh port forwarding for security reasons" if [ -x /usr/sbin/invoke-rc.d -a /etc/init.d/ssh ] ; then echo "Restarting ssh daemon" invoke-rc.d ssh restart else echo "Please restart the ssh daemon or do a \"killall -HUP sshd\" right after this package is setup!!!" fi fi fi if grep -q "/usr/bin/dtc-xen_userconsole" /etc/shells ; then echo "/etc/shells already knows /usr/bin/dtc-xen_userconsole" else echo "Adding /bin/dtc-xen_userconsole to /etc/shells" echo "/usr/bin/dtc-xen_userconsole" >>/etc/shells fi echo "" echo "If you wish to, there are some dtc-xen-os VM images that are available to setup automatically some operating systems. These are available in a 3rd party repository as Debian packages. Here are some of the mirrors available: Main mirror: deb ftp://ftp.gplhost.com/debian stable main Europe mirror: deb ftp://ftp.gplhost.fr/debian stable main Asia mirror: deb ftp://ftp.gplhost.sg/debian stable main Note that these are *not* officially backed by Debian support, and they are maintained on a best effort basis (eg: some might well be outdated and would need security upgrades just right after the install)." echo "" exit 0 dtc-xen-0.5.17/src/motd0000644000175000017500000000064611736663746013356 0ustar zigozigo ______ ___________________ GPL.Host_____ ____ ___| .__ ( ___/___(____ / |______| |_______( /___( _/_\___ __/ | \___ \_ |/ / |\ \_ ____ \_ ___ \_______ \| | | |/ / _____/ |/ / | / / |/ / s!|/ / | |_________\ | |__________/|___| / /|________\_________\GPL| Opensource dr|ven hosting worldwide____/http://gplhost.com |HOST VPS_HOSTNAME dtc-xen-0.5.17/dtc-xen.spec0000644000175000017500000001563711736663756014126 0ustar zigozigoName: dtc-xen Summary: DTC Xen VPS remote management suite Version: 0.5.17 Release: 8 Group: System Environment/Daemons License: GPLv2+ Url: http://www.gplhost.com/software-dtc-xen.html Source: %{name}-%{version}.tar.gz BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) Requires: python Requires: logrotate Requires: python-soap Requires: xen Requires: openssl Requires: chkconfig Requires: coreutils Requires: shadow-utils Requires: sudo Requires: gawk Requires: lvm2 # for the htpasswd command: Requires: yum Requires: MAKEDEV Requires: debootstrap BuildRequires: make BuildRequires: coreutils BuildRequires: gzip BuildRequires: sed BuildArch: noarch %description DTC-Xen lets you create and manage Xen VPS instances remotely, monitor their status and shut them down. You can use any SOAP client to interface with DTC-Xen, but you might want to use DTC to easily manage an entire farm of Xen VPSes. %package firewall Summary: DTC Xen VPS firewall Group: Applications/System Requires: iptables %description firewall DTC-Xen firewall is a rate-limiting firewall script that you can use on your servers using DTC-Xen. If running in a production environment, you might want to have a basic firewall running on your dom0 to avoid having DoS attack. This is not the state-of-the-art, but just another attempt to make things a bit more smooth. Comments and contribution are more than welcome! The main principle of this firewall script is to rate limit connections to both your dom0 and your VPSes. It's principle is NOT block any connection. For example, dtc-xen-firewall denies ssh for 300 seconds after 10 attempts on your dom0, rate limit ping to 5 per seconds on your dom0 and to 50/s globally for all your VPS, and does the same kind of thing for SYN flood attacks. Take care, it also blocks any connection to the port 25, as in a normal dom0, you would install a mail server to send system messages to the administrators, but you don't want to accept any incoming message. %prep rm -rf %{buildroot}/* %setup -q %build %install set -e make install DESTDIR=%{buildroot} DISTRO=centos SYSCONFIG_DIR=%{_sysconfdir} USRSBIN_DIR=%{_sbindir} USRBIN_DIR=%{_bindir} INITRD_DIR=%{_initrddir} \ MAN_DIR=%{_mandir} SHARE_DIR=%{_datadir} VARLIB_DIR=%{_localstatedir}/lib SHARE_DOC_DIR=%{_defaultdocdir} USRBIN_DIR=%{_bindir} sed -i 's/root adm/root root/g' %{buildroot}%{_sysconfdir}/logrotate.d/dtc-xen sed -i 's|^provisioning_mount_point.*|provisioning_mount_point=%{_localstatedir}/lib/dtc-xen/mnt|g' %{buildroot}%{_sysconfdir}/dtc-xen/dtc-xen.conf touch %{buildroot}%{_sysconfdir}/dtc-xen/htpasswd chmod 600 %{buildroot}%{_sysconfdir}/dtc-xen/htpasswd sed -i 's|/etc/dtc-xen|%{_sysconfdir}/dtc-xen|g' %{buildroot}%{_sbindir}/dtc-xen-volgroup make install_dtc-xen-firewall DISTRO=centos DESTDIR=%{buildroot} DISTRO=centos SYSCONFIG_DIR=%{_sysconfdir} USRSBIN_DIR=%{_sbindir} \ INITRD_DIR=%{_initrddir} MAN_DIR=%{_mandir} SHARE_DIR=%{_datadir} VARLIB_DIR=%{_localstatedir}/lib \ SHARE_DOC_DIR=%{_defaultdocdir} USRBIN_DIR=%{_bindir} %clean rm -rf %{buildroot} %pre /usr/sbin/groupadd -r xenusers 2>/dev/null exit 0 %post oldumask=`umask` umask 077 if [ ! -f %{_sysconfdir}/pki/tls/private/dtc-xen.key ] ; then /usr/bin/openssl genrsa -rand /proc/apm:/proc/cpuinfo:/proc/dma:/proc/filesystems:/proc/interrupts:/proc/ioports:/proc/pci:/proc/rtc:/proc/uptime 1024 > %{_sysconfdir}/pki/tls/private/dtc-xen.key 2> /dev/null fi FQDN=`hostname` if [ "x${FQDN}" = "x" ]; then FQDN=localhost.localdomain fi if [ ! -f %{_sysconfdir}/pki/tls/certs/dtc-xen.crt ] ; then cat << EOF | /usr/bin/openssl req -new -key %{_sysconfdir}/pki/tls/private/dtc-xen.key \ -x509 -days 365 -set_serial $RANDOM \ -out %{_sysconfdir}/pki/tls/certs/dtc-xen.crt 2>/dev/null -- SomeState SomeCity SomeOrganization SomeOrganizationalUnit ${FQDN} root@${FQDN} EOF fi umask $oldumask if [ "$1" == "1" ] ; then # Manuel: this below will setup MULTIPLE TIMES dtc-xen_userconsole in /etc/shells # if we also install multiple times the package. Please fix!!! echo "%{_bindir}/dtc-xen_userconsole" >> %{_sysconfdir}/shells # same here, please do a grep as test first [ -f %{_sysconfdir}/sudoers ] && echo "%xenusers ALL= NOPASSWD: /usr/sbin/xm console xen*" >> %{_sysconfdir}/sudoers /sbin/chkconfig --add dtc-xen if [ -x /sbin/runlevel -a -x /sbin/service -a -x /bin/awk ] ; then runlevel=` /sbin/runlevel | awk ' { print $2 } ' ` if [ $runlevel == 3 -o $runlevel == 4 -o $runlevel == 4 ] ; then /sbin/service dtc-xen start fi fi else if [ -x /sbin/service ] ; then /sbin/service dtc-xen condrestart fi fi exit 0 %preun if [ "$1" == "0" ] ; then if [ -x /sbin/service ] ; then /sbin/service dtc-xen stop ; fi /sbin/chkconfig --del dtc-xen without=`grep -v 'dtc-xen_userconsole' %{_sysconfdir}/shells` echo "$without" > %{_sysconfdir}/shells [ -f %{_sysconfdir}/sudoers ] && { without=`grep -v '%xenusers' %{_sysconfdir}/sudoers` echo "$without" > %{_sysconfdir}/sudoers } fi %postun # Manuel: are you 100% sure you should delete the group? That # seems a bad idea to me, as when reinstalling, it could change # the GID of some already existing files. Know what I mean??? if [ "$1" == "0" ] ; then /usr/sbin/groupdel xenusers fi %post firewall if [ "$1" == "1" ] ; then /sbin/chkconfig --add dtc-xen-firewall if [ -x /sbin/runlevel -a -x /sbin/service -a -x /bin/awk ] ; then runlevel=` /sbin/runlevel | awk ' { print $2 } ' ` if [ $runlevel == 3 -o $runlevel == 4 -o $runlevel == 4 ] ; then /sbin/service dtc-xen-firewall start fi fi else if [ -x /sbin/service ] ; then /sbin/service dtc-xen-firewall condrestart fi fi %preun firewall if [ "$1" == "0" ] ; then if [ -x /sbin/service ] ; then /sbin/service dtc-xen-firewall stop fi /sbin/chkconfig --del dtc-xen-firewall fi %files %defattr(0755,root,root,-) %doc doc/changelog doc/README.RPM doc/examples/* %{_sbindir}/* %{_bindir}/* %dir %{_sysconfdir}/dtc-xen %config(noreplace) %{_sysconfdir}/dtc-xen/bashrc %config(noreplace) %{_sysconfdir}/dtc-xen/motd %config(noreplace) %{_sysconfdir}/dtc-xen/sources.list %config(noreplace) %{_sysconfdir}/dtc-xen/inittab %attr(0600,root,root) %config(noreplace) %{_sysconfdir}/dtc-xen/dtc-xen.conf %attr(0600,root,root) %config(noreplace) %{_sysconfdir}/dtc-xen/htpasswd %config(noreplace) %{_sysconfdir}/logrotate.d/* %config %{_initrddir}/dtc-xen %dir %{_localstatedir}/lib/dtc-xen %attr(0750,root,root) %{_localstatedir}/lib/dtc-xen/states %attr(0750,root,root) %{_localstatedir}/lib/dtc-xen/perfdata %attr(0750,root,root) %{_localstatedir}/lib/dtc-xen/mnt %attr(0755,root,root) %{_localstatedir}/lib/dtc-xen/ttyssh_home %{_datadir}/dtc-xen/* %{_mandir}/*/* %files firewall %config(noreplace) %{_sysconfdir}/dtc-xen/dtc-xen-firewall-config %config %{_initrddir}/dtc-xen-firewall %changelog * Wed Jun 24 2009 Manuel Amador (Rudd-O) 0.4.0-7 - added debootstrap dependency * Fri Jun 11 2009 Manuel Amador (Rudd-O) 0.4.0-1 - initial release