def install(): # add pgp key print(green('Adding PGP key')) deb.add_apt_key(keyid='58118E89F3A912897C070ADBF76221572C52609D', keyserver='p80.pool.sks-keyservers.net') # add https support for apt utils.deb.install('apt-transport-https') # obtain the LSB version name id_, release, codename = run('lsb_release --id --release --codename --short').split("\r\n") # add docker apt sources list source = "deb https://apt.dockerproject.org/repo {}-{} main".format(id_.lower(), codename) append('/etc/apt/sources.list.d/docker.list', source, use_sudo=True) # update apt index deb.update_index(quiet=False) # install docker.io utils.deb.install('docker-engine') # install docker compose cmd = 'pip install -U docker-compose' sudo(cmd) # add current user to docker group current_user = env.user cmd = "gpasswd -a {} docker".format(current_user) sudo(cmd) print(green("User {} added to docker group.".format(current_user))) print(red("Remember to log out and back in to use it."))
def install(): """ Installs and configures vim """ # update apt index update_index(quiet=False) install_dependencies() # backup vim configuration folder if exists('.vim'): print(green('Backing up your vim configuration folder to .vim-bkp')) cmd = 'mv .vim .vim-bkp' run(cmd) # backup vim configuration file if exists('.vimrc'): print(green('Backing up your vim configuration file to .vimrc-bkp')) cmd = 'mv .vimrc .vimrc-bkp' run(cmd) # clone vim_config repository print(green('Cloning Vim_config repository.')) # install git if is not available git_install() git_clone('git://github.com/magnet-cl/Vim_config.git', '.vim') # installation script print(green('Installing Vim_config.')) with cd('.vim'): cmd = 'source install.sh' run(cmd)
def uptodate_index(quiet=True, max_age=86400): """ Require an up-to-date package index. This will update the package index (using ``apt-get update``) if the last update occured more than *max_age* ago. *max_age* can be specified either as an integer (a value in seconds), or as a dictionary whose keys are units (``seconds``, ``minutes``, ``hours``, ``days``, ``weeks``, ``months``) and values are integers. The default value is 1 hour. Examples: :: from fabtools import require # Update index if last time was more than 1 day ago require.deb.uptodate_index(max_age={'day': 1}) # Update index if last time was more than 1 hour and 30 minutes ago require.deb.uptodate_index(max_age={'hour': 1, 'minutes': 30}) """ if system.time() - last_update_time() > _to_seconds(max_age): update_index(quiet=quiet)
def setup(): deb.update_index() deb.upgrade() require.deb.packages([ "build-essential", "i3", "unzip", "xclip", "curl", "git", "sudo", "xdm", "iw", "network-manager", "firmware-atheros", "xfce4-terminal" ]) run('sh -c "$(curl -fsSL https://raw.githubusercontent.com/Linuxbrew/install/master/install.sh)"' ) # NOQA run("touch private.sh") git_seed(dot_dir) git_reset(dot_dir) with cd(dot_dir): with settings(warn_only=True): run("cp home/.* ~") run("cp -R fonts/ ~/.fonts") run("fc-cache -rf") run("locales") run("brew install gcc ruby curl python3 neovim bash bash-completion@2 git pipenv tmux" ) # NOQA run("pip3 install pwdman hostscli neovim tmuxp") sudo("hostscli block_all") run("curl -fLo ~/.local/share/nvim/site/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim" ) # NOQA run('nvim -c "PlugInstall | q | q"')
def ppa(name, auto_yes=False): """ Require a `PPA`_ package source. Example:: from fabtools import require # Node.js packages by Chris Lea require.deb.ppa('ppa:chris-lea/node.js', auto_yes=True) .. _PPA: https://help.launchpad.net/Packaging/PPA """ assert name.startswith('ppa:') user, repo = name[4:].split('/', 2) distrib = distrib_codename() source = '%(user)s-%(repo)s-%(distrib)s.list' % locals() if not is_file(source): package('python-software-properties') if auto_yes: prompt = '-y ' else: prompt = '' run_as_root('add-apt-repository %s %s' % (prompt, name), pty=False) update_index()
def install(): """ Installs redis """ # update apt index deb.update_index(quiet=False) # requirements utils.deb.install('build-essential') print(green('Downloading redis 2.8.9')) run('wget http://download.redis.io/releases/redis-2.8.9.tar.gz') print(green('Building redis')) run('tar xzf redis-2.8.9.tar.gz') with cd('redis-2.8.9'): run('make') print(green('Installing redis')) with cd('redis-2.8.9'): sudo('make install') print(green('Setting redis to run as daemon')) with cd('redis-2.8.9/utils'): sudo('./install_server.sh') print(green('Setting redis to start automatically at boot, ' 'assuming default settings')) sudo('update-rc.d redis_6379 defaults')
def install(): """ Installs and sets zsh as default shell """ # update apt index update_index(quiet=False) # install zsh utils.deb.install('zsh') # set as default shell for the user print(green('Re-enter your password to set zsh as default.')) with settings(hide('warnings'), warn_only=True): cmd = 'chsh -s /bin/zsh %s' % env.user while True: # prompt password until success if not run(cmd).failed: break else: print(red('Wrong password, try again.')) # install git if is not available git_install() # install oh-my-zsh if not exists('~/.oh-my-zsh'): git_clone('git://github.com/robbyrussell/oh-my-zsh.git', '~/.oh-my-zsh') # zsh configuration configure()
def install_tools(): ''' Install build tools ''' packages = ['python', 'python-dev', 'python-setuptools', 'python-pip', 'openssl', 'libssl-dev', 'libxml2-dev', 'libxslt1-dev', 'build-essential', 'git', 'sudo', 'lsb-release', 'imagemagick', 'curl', 'sqlite3'] if system.distrib_id() == 'Ubuntu': packages.append('software-properties-common') deb.update_index() deb.upgrade() require.deb.packages(packages) # Dirty hack because of fabtools that don't install pip properly sudo('curl -o - https://bootstrap.pypa.io/ez_setup.py -O - | python') sudo('curl -o - https://bootstrap.pypa.io/get-pip.py | python -') print(green('Tools successfully installed'))
def install(): # add pgp key print(green('Adding PGP key')) deb.add_apt_key(keyid='58118E89F3A912897C070ADBF76221572C52609D', keyserver='p80.pool.sks-keyservers.net') # add https support for apt utils.deb.install('apt-transport-https') # obtain the LSB version name id_, release, codename = run( 'lsb_release --id --release --codename --short').split("\r\n") # add docker apt sources list source = "deb https://apt.dockerproject.org/repo {}-{} main".format( id_.lower(), codename) append('/etc/apt/sources.list.d/docker.list', source, use_sudo=True) # update apt index deb.update_index(quiet=False) # install docker.io utils.deb.install('docker-engine') # install docker compose cmd = 'pip install -U docker-compose' sudo(cmd) # add current user to docker group current_user = env.user cmd = "gpasswd -a {} docker".format(current_user) sudo(cmd) print(green("User {} added to docker group.".format(current_user))) print(red("Remember to log out and back in to use it."))
def setup(short_hostname): deb.update_index() install_fail2ban() # HAProxy determines it's local name from hostname, and expects it # to have a "peer lb-1 ld-1.helix-cloud.ca" section present. # Thanks to the Debian HAProxy packaging team! with open(files.haproxy_cfg) as fp: cfg = fp.read() if not re.search(r'^\s*peer\s+{}'.format(short_hostname), cfg, flags=re.MULTILINE): abort("hostname does not match any set in HAProxy config!") execute(set_hostname, short_hostname) # Newer versions of HAProxy support "peers", which is good require.deb.package('software-properties-common') require.deb.ppa('ppa:vbernat/haproxy-1.7') require.deb.package('haproxy') # no such thing as \d in sed regex sed('/etc/default/haproxy', 'ENABLED=[[:digit:]]', 'ENABLED=1') put(files.haproxy_cfg, '/etc/haproxy/haproxy.cfg') service.restart('haproxy')
def uptodate_index(quiet=True, max_age=86400): """ Require an up-to-date package index. This will update the package index (using ``apt-get update``) if the last update occured more than *max_age* ago. *max_age* can be specified either as an integer (a value in seconds), or as a dictionary whose keys are units (``seconds``, ``minutes``, ``hours``, ``days``, ``weeks``, ``months``) and values are integers. The default value is 1 hour. Examples: :: from fabtools import require # Update index if last time was more than 1 day ago require.deb.uptodate_index(max_age={'day': 1}) # Update index if last time was more than 1 hour and 30 minutes ago require.deb.uptodate_index(max_age={'hour': 1, 'minutes': 30}) """ from fabtools.require import file as require_file require_file('/etc/apt/apt.conf.d/15fabtools-update-stamp', contents='''\ APT::Update::Post-Invoke-Success {"touch /var/lib/apt/periodic/fabtools-update-success-stamp 2>/dev/null || true";}; ''', use_sudo=True) if system.time() - last_update_time() > _to_seconds(max_age): update_index(quiet=quiet)
def install_tools(): ''' Install build tools ''' packages = ['python', 'python-dev', 'python-setuptools', 'python-pip', 'openssl', 'libssl-dev', 'libxml2-dev', 'libxslt1-dev', 'build-essential', 'git', 'sudo', 'lsb-release', 'imagemagick', 'curl', 'sqlite3', 'wget'] if system.distrib_id() == 'Ubuntu': packages.append('software-properties-common') deb.update_index() deb.upgrade() require.deb.packages(packages) # Dirty hack because of fabtools that don't install pip properly sudo('curl -o - https://bootstrap.pypa.io/ez_setup.py -O - | python') sudo('curl -o - https://bootstrap.pypa.io/get-pip.py | python -') print(green('Tools successfully installed'))
def install_passenger(): """ Installs nginx with passenger support """ # add pgp key print(green('Adding PGP key')) deb.add_apt_key(keyid='561F9B9CAC40B2F7', keyserver='keyserver.ubuntu.com') # add https support for apt utils.deb.install('apt-transport-https') # ubuntu 12.04 (precise) cmd = ('echo "deb https://oss-binaries.phusionpassenger.com/apt/passenger ' 'precise main" > /etc/apt/sources.list.d/passenger.list') sudo(cmd) cmd = 'sudo chmod 600 /etc/apt/sources.list.d/passenger.list' sudo(cmd) # update apt index deb.update_index(quiet=False) print(green('Installing nginx and passenger')) utils.deb.install('nginx-full') utils.deb.install('passenger') print(green('Activating passenger')) uncomment('/etc/nginx/nginx.conf', 'passenger_root', use_sudo=True) uncomment('/etc/nginx/nginx.conf', 'passenger_ruby', use_sudo=True)
def _develop(): """ Provision the environment for ecalendar """ if not contains('/etc/default/locale', 'en_US.UTF-8'): sed('/etc/default/locale', 'en_US', 'en_US.UTF-8', use_sudo=True, shell=True) # sources.list if not contains('/etc/apt/sources.list', 'mirrors.163'): sed('/etc/apt/sources.list', 'us\.archive\.ubuntu', 'mirrors.163', use_sudo=True, shell=True) deb.update_index(quiet=False) require.mysql.server(password='******') # build-essential require.deb.packages([ 'libxml2-dev', 'libxslt1-dev', 'build-essential', 'python-dev', 'cmake', 'libmysqlclient-dev', 'libssl-dev' ]) require.deb.packages([ 'python-distribute', 'python-pip' ]) with cd ('/vagrant'): sudo('easy_install -U distribute') sudo('python setup.py develop', shell=True)
def provision_vagrant(): vagrant() update_index() fabtools.require.postfix.server('example.com') create_pg_database() update_requirements() django_manage("migrate") django_migrate()
def safe_upgrade(): """ Upgrades installed packages to their most recent version """ # update apt index update_index(quiet=False) # safe upgrade cmd = 'aptitude safe-upgrade' sudo(cmd)
def upgrade_client(): """Upgrade certbot client""" # update apt index update_index(quiet=False) cmd = 'apt-get install --only-upgrade python-certbot-nginx' sudo(cmd) print(green('Certbot successfully upgraded.'))
def test_install_debian_package_in_guest_context_manager(container): from fabtools.deb import update_index from fabtools.openvz import guest from fabtools.require.deb import package with guest(container): update_index() package('htop') assert is_file('/usr/bin/htop')
def upgrade_server(): """ Helper method to upgrade the SSH server """ # update apt index update_index(quiet=False) cmd = 'apt-get install --only-upgrade openssh-server' sudo(cmd) print(green('SSH server successfully upgraded.'))
def install_deps(): # update apt index deb.update_index(quiet=False) # obtain the LSB codename codename = utils.deb.get_release_info().codename packages = NIX_DEPS[codename] for package, version in packages: deb.install(package, version)
def fix_shellshock(): """ Upgrades bash in order to avoid the 'shellshock' vulnerability. """ # update apt index update_index(quiet=False) cmd = 'apt-get install --only-upgrade bash' sudo(cmd) print(green('Bash successfully secured.'))
def upgrade_timezone_data(): """ Upgrades timezone data deb package """ # update apt index update_index(quiet=False) cmd = 'apt-get install --only-upgrade tzdata' sudo(cmd) print(green('Timezone data successfully upgraded.'))
def install(): """ Installs and sets zsh as default shell """ # update apt index update_index(quiet=False) # install zsh utils._deb.install('zsh') # install zsh examples utils._deb.install('zsh-lovers') # set as default shell for the user print(green('Re-enter your password to set zsh as default.')) with settings(hide('warnings'), warn_only=True): cmd = 'chsh -s /bin/zsh %s' % env.user while True: # prompt password until success if not run(cmd).failed: break else: print(red('Wrong password, try again.')) # install git if is not available git_install() # install oh-my-zsh git_clone('git://github.com/robbyrussell/oh-my-zsh.git', '~/.oh-my-zsh') # zsh configuration file: plugins plugins = [] recommended_plugins = (['git', 'github', 'git-flow', 'heroku', 'last-working-dir', 'pip', 'autojump', 'command-not-found', 'debian', 'encode64', 'vagrant', 'ruby']) recommended_plugins.sort() for plugin in recommended_plugins: if confirm('Would you like to use the %s plugin?' % plugin): plugins.append(plugin) plugins = ' '.join(plugins) # zsh configuration file: default editor editor = prompt('Please specify your default editor', default='vim') context = { 'plugins': plugins, 'default_editor': editor, 'user': env.user } upload_template('fabfile/templates/zshrc', '.zshrc', context=context) # zsh fabric autocomplete put('fabfile/templates/zsh_fab', '.zsh_fab') # upload custom themes themes() print(green('If the shell does not change, restart your session.'))
def install_tools(): ''' Install build tools ''' deb.update_index() deb.upgrade() require.deb.packages([ 'python', 'python-dev', 'python-setuptools', 'python-pip', 'openssl', 'libssl-dev', 'libxml2-dev', 'libxslt1-dev', 'build-essential', 'git', 'sudo', 'lsb-release', 'imagemagick', 'sqlite3' ]) print(green('Tools successfully installed'))
def configure_logrotate(framework=None, skip_installation=False): """ Configures logrotate to listen for a given framework Frameworks supported: django rails Optionally you can skip the installation of logrotate through the skip_installation parameter. """ if not framework: print(red('Please specify the framework to configure')) print(red('Usage:')) print(red('\tfab admin.configure_logrotate:rails')) print(red('\tfab admin.configure_logrotate:django')) return if not utils.arg_to_bool(skip_installation): # update apt index update_index(quiet=False) # install logrotate utils.deb.install('logrotate') # framework set if framework == 'rails': config_file = 'magnet-rails' elif framework == 'django': config_file = 'magnet-django' # create logs directory for django apps avoiding logrotate error cmd = 'mkdir -p logs' run(cmd) else: print(red('Framework not supported')) return # upload logrotate config file print(blue('Uploading logrotate config file')) config_file_path = '{}/templates/{}'.format(ROOT_FOLDER, config_file) logrotate_dir = '/etc/logrotate.d/' put(config_file_path, logrotate_dir, use_sudo=True, mode=0644) # change config file owner to root cmd = 'chown root:root {}{}'.format(logrotate_dir, config_file) sudo(cmd) # activate rotation print(blue('Activating logrotate config file')) cmd = 'logrotate -v {}{}'.format(logrotate_dir, config_file) sudo(cmd)
def install(): """ Installs PostgreSQL and its development packages. """ # update apt index deb.update_index(quiet=False) print(green('Installing PostgreSQL and its development packages.')) utils.deb.install('postgresql') utils.deb.install('postgresql-contrib') utils.deb.install('libpq-dev')
def setup(): local_clone_repos() require.files.directories([apps_dir, logs_dir]) require.files.directories(["/var/repo/"], use_sudo=True) require.deb.package("software-properties-common") sudo("add-apt-repository ppa:ondrej/php") sudo("add-apt-repository ppa:ondrej/apache2") sudo("add-apt-repository ppa:certbot/certbot") deb.update_index() deb.upgrade() require.git.command() require.deb.packages([ "mysql-server", "dpkg-dev", "php7.1", "php7.1-mysql", "php7.1-gd", "php7.1-dev", "php7.1-curl", "php7.1-cli", "php7.1-json", "php-apcu", "libpcre3-dev", "php-pear", "libapache2-mod-php7.1", "sendmail", "php7.1-mbstring", "python-pip", "python-certbot-apache" ]) sudo("yes '' | pecl install apc") sudo("pip install pygments") require.apache.server() for apache_mod in apache_mods: require.apache.module_enabled(apache_mod) push_repos() require.apache.site( hostname, template_contents=CONFIG_TPL, port=80, hostname=hostname, docroot=docroot, ) require.apache.site_enabled(hostname) require.apache.site_disabled('default') print("Please make sure %s is pointing to %s before certbot install" % (hostname, env.hosts)) sudo("certbot --apache") require.mysql.server(password=db_root_pass) with settings(mysql_user='******', mysql_password=db_root_pass): require.mysql.user(env.user, db_user_pass) grant_all(env.user) require.file("/etc/mysql/conf.d/mysql.cnf", "[mysqld]\nsql_mode=STRICT_ALL_TABLES", use_sudo=True) sudo("service mysql restart") require.nodejs.installed_from_source(version='8.9.1') with cd("%s/phabricator" % apps_dir): run("./bin/config set mysql.host localhost") run("./bin/config set mysql.user %s" % env.user) run("./bin/config set mysql.pass %s" % db_user_pass) run("./bin/config set phabricator.base-uri 'https://%s'" % hostname) run("./bin/storage upgrade --force") run("./bin/phd start") run("./bin/aphlict start")
def uptodate_index(quiet=True, max_age=86400): """ Update APT package definitions (``apt-get update``) only if specified time since last update already elapsed. Example:: from fabtools import require # do not update in 1 day require.deb.uptodate_index(max_age={'day' : 1}) """ if system.time() - last_update_time() > _simple_time_interval(max_age): update_index(quiet=quiet)
def ppa(name, auto_accept=True, keyserver=None): """ Require a `PPA`_ package source. Example:: from fabtools import require # Node.js packages by Chris Lea require.deb.ppa('ppa:chris-lea/node.js', keyserver='my.keyserver.com') .. _PPA: https://help.launchpad.net/Packaging/PPA """ assert name.startswith('ppa:') user, repo = name[4:].split('/', 2) # For ubuntu based distribution with their own version system # e.g. Elementary OS Luna version returned by lsb_release is 0.2.1 # which raise ValueError exception on float() call try: release = float(distrib_release()) except ValueError: release = 12.04 if release >= 12.04: repo = repo.replace('.', '_') auto_accept = '--yes' if auto_accept else '' else: auto_accept = '' if not isinstance(keyserver, basestring) and keyserver: keyserver = keyserver[0] if keyserver: keyserver = '--keyserver ' + keyserver else: keyserver = '' distrib = distrib_codename() source = '/etc/apt/sources.list.d/%(user)s-%(repo)s-%(distrib)s.list' % locals() if not is_file(source): if release >= 14.04: # add-apt-repository moved to software-properties-common in 14.04 package('software-properties-common') else: package('python-software-properties') run_as_root('add-apt-repository %(auto_accept)s %(keyserver)s %(name)s' % locals(), pty=False) update_index()
def full_upgrade(ask_confirmation=True): """ Upgrades installed packages to their most recent version, removing or installing packages as necessary. """ # update apt index update_index(quiet=False) # full upgrade cmd = 'aptitude full-upgrade' if not ask_confirmation: cmd = '{} -y'.format(cmd) sudo(cmd)
def ppa(name, auto_accept=True, keyserver=None): """ Require a `PPA`_ package source. Example:: from fabtools import require # Node.js packages by Chris Lea require.deb.ppa('ppa:chris-lea/node.js', keyserver='my.keyserver.com') .. _PPA: https://help.launchpad.net/Packaging/PPA """ assert name.startswith('ppa:') user, repo = name[4:].split('/', 2) release = float(distrib_release()) if release >= 12.04: repo = repo.replace('.', '_') auto_accept = '--yes' if auto_accept else '' else: auto_accept = '' if not isinstance(keyserver, basestring) and keyserver: keyserver = keyserver[0] if keyserver: keyserver = '--keyserver ' + keyserver else: keyserver = '' distrib = distrib_codename() source = '/etc/apt/sources.list.d/%(user)s-%(repo)s-%(distrib)s.list' % locals( ) if not is_file(source): if release >= 14.04: # add-apt-repository moved to software-properties-common in 14.04 package('software-properties-common') else: package('python-software-properties') run_as_root( 'add-apt-repository %(auto_accept)s %(keyserver)s %(name)s' % locals(), pty=False) update_index()
def install_yarn(): """Install yarn.""" print(green('Adding gpg key')) cmd = 'curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -' sudo(cmd) print(green('Adding apt repository')) cmd = ('echo "deb https://dl.yarnpkg.com/debian/ stable main" | ' 'tee /etc/apt/sources.list.d/yarn.list') sudo(cmd) # update apt index deb.update_index(quiet=False) print(green('Installing yarn')) utils.deb.install('yarn')
def deploy(): """Initialise or update the git clone - you can safely rerun this. e.g. to update the server fab -H <host> deploy """ # Ensure we have a mailserver setup for our domain # Note that you may have problems if you intend to run more than one # site from the same server setup_env() show_environment() setup_postgis_2() base_path, code_path, git_url, repo_alias, site_name = get_vars() fastprint('Checking out %s to %s as %s' % (git_url, base_path, repo_alias)) update_git_checkout(base_path, git_url, repo_alias) update_index() require.postfix.server(site_name) update_apache(code_path) require.deb.package('python-dev') require.deb.package('libpq-dev') require.deb.package('libgeos-c1') require.deb.package('vim') require.deb.package('curl') require.deb.package('pandoc') update_venv(code_path) set_db_permissions() with cd(os.path.join(code_path, 'django_project')): run('../venv/bin/python manage.py syncdb --noinput ') run('../venv/bin/python manage.py migrate') # if we are testing under vagrant, deploy our local media and db #if 'vagrant' in env.fg.home: # with cd(code_path): # run('cp /vagrant/projecta.db .') # run('touch django_project/core/wsgi.py') #sync_media_to_server() collectstatic() fastprint('*******************************************\n') fastprint(red(' Don\'t forget set ALLOWED_HOSTS in ')) fastprint(' django_project/core/settings/prod.py') fastprint(' to the domain name for the site.') fastprint('*******************************************\n')
def install(): """ Installs node """ print(green('Adding ppa:chris-lea/node.js to apt repositories')) run('sudo add-apt-repository ppa:chris-lea/node.js') # update apt index deb.update_index(quiet=False) # install node, taken form # http://github.com/joyent/node/wiki/Installing-Node.js-via-package-manager print(green('Installing dependencies')) utils.deb.install('python-software-properties') utils.deb.install('python') utils.deb.install('g++') utils.deb.install('make') print(green('Installing nodejs')) utils.deb.install('nodejs')
def uptodate_index(quiet=True, max_age=86400): """ Update APT package definitions (``apt-get update``) only if specified time since last update already elapsed. Example:: from fabtools import require # do not update in 1 day require.deb.uptodate_index(max_age={'day': 1}) # do not update in 1 hour and 30 minutes require.deb.uptodate_index(max_age={'hour': 1, 'minutes': 30}) """ if system.time() - last_update_time() > _to_seconds(max_age): update_index(quiet=quiet)
def install(): """ Installs certbot for nginx """ # update apt index deb.update_index(quiet=False) # requirements utils.deb.install('software-properties-common') print(green('Adding certbot PPA')) cmd = 'add-apt-repository -y ppa:certbot/certbot' sudo(cmd) # update apt index deb.update_index(quiet=False) print(green('Installing certbot')) utils.deb.install('python-certbot-nginx')
def install_tools(): """ Install build tools """ deb.update_index() deb.upgrade() require.deb.packages([ 'python', 'python-setuptools', 'python-pip', 'openssl', 'libssl-dev', 'libxml2-dev', 'libxslt1-dev', 'build-essential', 'git', 'sudo', ]) print(green("Tools successfully installed"))
def install_ntp(): """ Installs and configures the NTP daemon """ # update apt index update_index(quiet=False) print(blue('Installing NTP daemon')) utils.deb.install('ntp') print(blue('Configuring NTP servers to use US pool zone')) # patterns before = 'ubuntu\.pool\.ntp\.org' after = 'us\.pool\.ntp\.org' # ntp configuration file config_file = '/etc/ntp.conf' sed(config_file, before, after, use_sudo=True) print(blue('Restarting NTP server')) service.restart('ntp')
def full_upgrade(ask_confirmation=True): """ Upgrades installed packages to their most recent version, removing or installing packages as necessary. """ # update apt index update_index(quiet=False) # install aptitude utils.deb.install('aptitude') # full upgrade cmd = 'aptitude full-upgrade' if not ask_confirmation: cmd = '{} -y'.format(cmd) sudo(cmd)