Ejemplo n.º 1
0
def _copy_user_config_files(seed, user):### not yet working
    """Copy the user config files/folders from the home directory into /etc/skel
    that may be needed for live environment
    """
    stage = 'copy-user-config-files'

    _file_conf = pycone._var_from_seed(seed, 'skeleton', '_CONFIG_FILE')
    _folder_conf = pycone._var_from_seed(seed, 'skeleton', '_CONFIG_FOLDER')
    pycone._print_log(_file_conf, _folder_conf, stage)##
    _working_dir = pycone._var_from_seed(seed, 'directories', '_BUILD_DIR')[0]
    _rootfs = pycone._var_from_seed(seed, 'directories', '_ROOTFS')[0]
    pycone._print_log(_working_dir, _rootfs, stage)##
    _etc_skel = pycone._var_from_seed(seed, 'skeleton', '_SKEL_DIR')[0]
    _build_dir = '/home/pyne' + _working_dir + _rootfs + _etc_skel

    configurations = _file_conf + _folder_conf

    src_dir = '/home/' + user
    dest_dir = _build_dir
    pycone._print_log(src_dir, src_dir, stage)##

    for item in configurations:
        pycone._print_log(src_dir, src_dir, stage)##
        #pycone._copy(src_dir + '/' + item, dest_dir + '/' + item)
        print('cp -rpv', src_dir + '/' + item, dest_dir + '/' + item)
        time.sleep(2)
Ejemplo n.º 2
0
def _chroot(seed):## needs logging
    """Mount directories and chroot into new system
    """
    stage = 'chroot'
    # mount the backup/bootstrap systems for chroot
    _mount_chroot_fs(seed)
    pycone._print_log('chrootfs', None, stage)##
    time.sleep(2)

    # chroot into new system
    _working_dir = pycone._var_from_seed(seed, 'directories', '_BUILD_DIR')[0]
    _rootfs = pycone._var_from_seed(seed, 'directories', '_ROOTFS')[0] + ' '
    pycone._print_log(_working_dir, _rootfs, stage)##

    _bashfs = pycone._var_from_seed(seed, 'chroot', '_CHROOTFS')[0]
    _terminal_chroot_cmd = pycone._var_from_seed(seed, 'chroot', '_CHROOT_CMD')[0] + ' '
    pycone._print_log(_bashfs, _chroot_cmd, stage)##

    _chroot_rootfs = _working_dir + _rootfs
    _chroot_ = _terminal_chroot_cmd + _chroot_rootfs + _bashfs
    pycone._print_log(_chroot_rootfs, _chroot_, stage)##

    # lxtermimal -e 'chroot <mount dir> /bin/bash'
    print(_chroot_)
    os.system('lxterminal -e \'inxi -F\'')
Ejemplo n.º 3
0
def _mount_chroot_fs(seed):

    choice = pycone._choose_from(pyconeQ.yes_no_list, pyconeQ.mount_msg)
    # create a list of choices return the users choice

    if choice == 0:
        # choose a backup of current system
        _working_dir = pycone._var_from_seed(seed, 'directories', '_BUILD_DIR')[0]

        _mount_dev = pycone._var_from_seed(seed, 'mount', '_MOUNT')[0] + ' '
        _mount_proc = pycone._var_from_seed(seed, 'mount', '_MOUNT')[1] + ' '

        _devfs = pycone._var_from_seed(seed, 'mount', '_MOUNTFS')[0]
        _procfs = pycone._var_from_seed(seed, 'mount', '_MOUNTFS')[1]

        _mount_devfs = _mount_dev + _working_dir + _devfs
        _mount_procfs = _mount_proc + _working_dir + _procfs

        #os.system(_mount_devfs)
        #os.system(_mount_procfs)
        print(_mount_devfs)
        print(_mount_procfs)
    elif choice == 1:
        # choose to use an existing iso file
        #_new_config('iso')
        print("Nothing to do. Exiting")
        pycone._exit()
    else:
        pycone._do_help_quit(choice, pyconeQ.yes_no_list)
Ejemplo n.º 4
0
def _chroot(seed):
    _working_dir = pycone._var_from_seed(seed, 'directories', '_BUILD_DIR')[0]
    _rootfs = pycone._var_from_seed(seed, 'directories', '_ROOTFS')[0] + ' '
    _bashfs = pycone._var_from_seed(seed, 'chroot', '_CHROOTFS')[0]

    _chroot_rootfs = _working_dir + _rootfs
    _chroot_ = 'chroot ' + _chroot_rootfs + _bashfs
    print(_chroot_)
Ejemplo n.º 5
0
def _os_prober():

    _d_list = pycone._var_from_seed(_seed_, 'distributions', '_DISTRO_LIST')

    _e_list = []
    for item in _d_list:
        _e_list = _e_list.append(pycone._var_from_seed(_seed_, 'distributions', item))
        print(item)

    print(_e_list)
Ejemplo n.º 6
0
def _install_source_system_packages(base):
    """Install source packages needed to do a backup
    """
    stage = 'install-source-system-packages'
    source_packages = pycone._var_from_seed(base, 'dist-packages', '_SOURCE')
    source_packages = source_packages + pycone._var_from_seed(base, 'packages', '_SOURCE')
    # list of packages required by the source system
    pycone._print_log(source_packages, None, stage)##

    pycone._package_db_update(base)
    # update the system database from repositories

    for item in source_packages:
        pycone._install(base, item)
Ejemplo n.º 7
0
def _mount_chroot_fs(seed):## needs logging
    _working_dir = pycone._var_from_seed(seed, 'directories', '_BUILD_DIR')[0]

    _mount_dev = pycone._var_from_seed(seed, 'mount', '_MOUNT')[0] + ' '
    _mount_proc = pycone._var_from_seed(seed, 'mount', '_MOUNT')[1] + ' '

    _devfs = pycone._var_from_seed(seed, 'mount', '_MOUNTFS')[0]
    _procfs = pycone._var_from_seed(seed, 'mount', '_MOUNTFS')[1]

    _mount_devfs = _mount_dev + _working_dir + _devfs
    _mount_procfs = _mount_proc + _working_dir + _procfs

    #os.system(_mount_devfs)
    #os.system(_mount_procfs)
    print(_mount_devfs)
    print(_mount_procfs)
Ejemplo n.º 8
0
def _install_source_system_packages(base):
    """Install packages used on the source system to create iso from backup/bootstrap
    """
    stage = 'install source packages'
    pycone._print_log('', stage)##
    choice = pycone._choose_from(pyconeQ.yes_no_list, pyconeQ.source_paks_msg)
    # return the users choice
    pycone._print_log(pyconeQ.yes_no_list, stage)##
    pycone._print_log(choice + 1, stage)##

    # Check ok to install required packages
    if choice == 0:
        source_packages = pycone._var_from_seed(base, 'packages', '_SOURCE')
        # list of packages required by the source system
        pycone._print_log(choice + 1, stage)##
        pycone._print_log(source_packages, stage)##

        pycone._package_db_update(base)
        # update the database of available packages

        for item in source_packages:
            pycone._install(base, item)
        # install each required package
    elif choice == 1:
        pycone._print_log(choice + 1, stage)##
        pycone._print_log(source_packages, stage)##
        print('PyneCone cannot continue. Exiting')
        pycone._exit()
    else:
        pycone._do_help_quit(choice, pyconeQ.yes_no_list)
Ejemplo n.º 9
0
def _create_chroot_env_script(base, seed):
    """This will create a script to use within the chroot
    environment to install needed software and general house cleaning
    """
    stage = 'create-chroot-env-script'

    script = '/usr/bin/pyne-chroot.sh'

    lang = pycone._var_from_seed(seed, 'chroot', '_LANG')[0]
    update = pycone._package_db_update(base)
    install_list = pycone._var_from_seed(seed, 'chroot-pkgs', '_PACKAGES')
    chmodules_list = pycone._var_from_seed(seed, 'chroot', '_MODULES')

    script_open = open(script, flag = 'r')
    print(lang, file = script)
    print(update, file = script)
    for item in install_list =
Ejemplo n.º 10
0
def _install(base, package):
    """install given package, if not already installed
    """
    packager = pycone._var_from_seed(base, 'packager', '_PACKAGER')
    install = pycone._var_from_seed(base, 'packager', '_INSTALL')

    if 'modules' in package:
        package = package + _uname_r

    _cmd = _var_builder(packager, install) + ' ' + package

    _find = str(_var_from_seed(base, 'packager', '_FIND'))

    if _find + str(package) != 0:
        #_sys_cmd(_cmd)
        print(_cmd)
    else:
        print(package + ' already installed')
Ejemplo n.º 11
0
def _rsync_do(_mseed_):
     # choose a backup of current system
        stage = 'rsync-do'
        pycone._print_log(None, None, stage)##

        distro_dir = pycone._var_from_seed(_mseed_, 'directories', '_BUILD_DIR')

        for dir in distro_dir:
            dir = '/home/pyne' + dir

        pycone._rsync_live(_mseed_, dir)##
Ejemplo n.º 12
0
def _mkdir_p(base, _mseed_):
    """Create the directories needed to store new system
    """
    # make the dirs in the pyne dir, which doesn't get rsync'd
    stage = 'mkdir_p'
    pycone._print_log(None, None, stage)##

    distro_dir = pycone._var_from_seed(_mseed_, 'directories', '_BUILD_DIR')
    iso_creation_dir = pycone._var_from_seed(_mseed_, 'directories', '_ISO_DIR')
    required_dirs = distro_dir + iso_creation_dir

    for dir in required_dirs:
        dir = '/home/pyne' + dir
        pycone._print_log(dir, None, stage)##
        # if path is not already present, request to create it
        # else the dir exists, and PyneCone will use them
        if not os.path.exists(dir):
            print("making dir", dir)
            #os.makedirs(dir)
        time.sleep(2)
Ejemplo n.º 13
0
def _mkdir_p(base, _mseed_):
    """Create the directories needed to store new system
    """
    # make the dirs in the pyne dir, which doesn't get rsync'd
    stage = 'mkdir_p'
    pycone._print_log('', '', stage)##

    distro_dir = pycone._var_from_seed(_mseed_, 'directories', '_BUILD_DIR')
    iso_creation_dir = pycone._var_from_seed(_mseed_, 'directories', '_ISO_DIR')
    required_dirs = distro_dir + iso_creation_dir

    for dir in required_dirs:
        dir = '/home/pyne' + dir
        pycone._print_log(dir, '', stage)##
        # if path is not already present, request to create it
        # else the dir exists, and PyneCone will use them
        if not os.path.exists(dir):

            choice = pycone._choose_from(pyconeQ.yes_no_list, pyconeQ.create_new_dir_msg % dir)
            # return the users choice
            pycone._print_log(pyconeQ.yes_no_list, '', stage)##

            if choice == 0:
                pycone._print_log(choice + 1, '', stage)##
                try:
                    pycone._print_log('making dir', '', stage)
                    print("making dir", dir)
                    #os.makedirs(dir)

                except:
                    # call error handler
                    pycone._print_log('error making dir', '', stage)
                    print("error creating backup directory")
                    pycone._exit()
            elif choice == 1:
                pycone._print_log(choice + 1, '', stage)##
                print('PyneCone cannot continue. Exiting')
                pycone._exit()
            else:
                pycone._do_help_quit(choice, pyconeQ.yes_no_list)
        time.sleep(2)
Ejemplo n.º 14
0
def _get_new_dirs(seed):
    stage = 'new_dirs'
    pycone._print_log('', stage)

    _working_dir = pycone._var_from_seed(seed, 'directories', '_BUILD_DIR')
    # dir to backup or bootstrap system
    pycone._print_log(_working_dir, stage)

    _iso_dir = pycone._var_from_seed(seed, 'directories', '_ISO_DIR')
    # dir to build iso in
    pycone._print_log(_iso_dir, stage)

    _cdfs = pycone._var_from_seed(seed, 'file_systems', '_CD_FS')
    # file system format for iso
    pycone._print_log(_cdfs, stage)

    _livefs = pycone._var_from_seed(seed, 'file_systems', '_LIVE_FS')
    # file system for iso builder
    pycone._print_log(_livefs, stage)

    _grub = pycone._var_from_seed(seed, 'directories', '_GRUBFS')
    # grub file directory
    pycone._print_log(_grub, stage)

    _rootfs = pycone._var_from_seed(seed, 'directories', '_ROOTFS')
    # rootfs for working dir
    pycone._print_log(_rootfs, stage)

    #_dir_list = pycone._dir_builder(_iso_dir, _livefs)# + _grub + _working_dir + _rootfs
    _dir_list = [_iso_dir[0]+ _livefs[0], _iso_dir[0] + _grub[0], _working_dir[0] + _rootfs[0]]
    pycone._print_log(_dir_list, stage)

    return _dir_list
Ejemplo n.º 15
0
def _ask_rsync(_mseed_):

    stage = 'ask-rsync'
    pycone._print_log('', stage)##
    choice = pycone._choose_from(pyconeQ.yes_no_list, pyconeQ.start_rsync_msg)
    # return the users choice
    pycone._print_log(pyconeQ.yes_no_list, stage)##

    if choice == 0:
        # choose a backup of current system
        pycone._print_log(choice + 1, stage)##
        distro_dir = pycone._var_from_seed(_mseed_, 'directories', '_BUILD_DIR')
        for dir in distro_dir:
            dir = '/home/pyne' + dir
        pycone._rsync_live(_mseed_, dir)
    elif choice == 1:
        # choose to use an existing iso file
        #_new_config('iso')
        pycone._print_log(choice + 1, stage)##
        print("Nothing to do. Exiting")
        pycone._exit()
    else:
        pycone._do_help_quit(choice, pyconeQ.yes_no_list)
Ejemplo n.º 16
0
        print(_cmd)
    else:
        print(package + ' already installed')
#end-_install

def _os_prober():

    _d_list = pycone._var_from_seed(_seed_, 'distributions', '_DISTRO_LIST')

    _e_list = []
    for item in _d_list:
        _e_list = _e_list.append(pycone._var_from_seed(_seed_, 'distributions', item))
        print(item)

    print(_e_list)
#end-_os_prober

find_file = _find_file(application)

# if false, file missing, install file
if find_file:
    _install(some_base, package)
print(find_file)

_rsync_live_excludes = pycone._var_from_seed(seed, 'rsync-live', '_EXCLUDES')
_rsync_live_options = pycone._var_from_seed(seed, 'rsync-live', '_OPTIONS')
_dry_run = pycone._var_from_seed(seed, 'rsync', '_TESTING')

"""check to see if rsync is installed, if not install it
allow for different types of rsync, ie full clone, differential archive, backup ready for iso
"""