def testAttribs(self): tmpdir = tempfile.mkdtemp() try: dir1_path = os.path.join(tmpdir, 'dir1') cuisine.dir_ensure(dir1_path) file1_path = os.path.join(dir1_path, 'file1') cuisine.file_write(file1_path, 'test', mode='666') cuisine.dir_attribs(tmpdir, mode=755, recursive=True) attribs = cuisine.file_attribs_get(dir1_path) self.assertEqual(attribs.get('mode'), '755') finally: cuisine.dir_remove(tmpdir, recursive=True)
def post_build(self): with mode_sudo(): # Sets up a new RabbitMQ user and deletes the default guest user with warn_only(): sudo('rabbitmqctl delete_user user') sudo('rabbitmqctl delete_user guest') sudo('rabbitmqctl add_user user password') sudo("rabbitmqctl set_permissions -p / user '.*' '.*' '.*'") # Updates PYTHONPATH and performs a south migration - to include djceelry module path_1 = ':/var/django/project' sudo('export PYTHONPATH=$PYTHONPATH'+path_1) if self.site.run_sync_db: sudo('cd /var/django/project/ && python manage.py migrate') #------------------------------------------------------ # Celery/Celerybeat Setup # Creates and setups up the celery folder for logs and PID files # sets the owner as www-data. sudo('cd /home/ && mkdir -p celery') dir_attribs('/home/celery/', owner='www-data', recursive=True) # Set permissions so only www-data can access this folder and its # contents. sudo('chmod 700 -R /home/celery/') # Copy over the daemon and configuration files to the appropriate directories. # Make the daemon files executable. put('celeryd.init', '/etc/init.d/', use_sudo=True) put('celerybeat.init', '/etc/init.d/', use_sudo=True) put('celeryd.default', '/etc/default/', use_sudo=True) put('celerybeat.default', '/etc/default/', use_sudo=True) sudo('cd /etc/init.d/ && mv celeryd.init celeryd && mv celerybeat.init celerybeat') sudo( 'cd /etc/default/ && mv celeryd.default celeryd && ' 'mv celerybeat.default celerybeat' ) sudo('chmod +x /etc/init.d/celeryd') sudo('chmod +x /etc/init.d/celerybeat') # Start the celeryd daemon with celerybeat (-B). sudo('service celeryd start -B') # Sets celeryd service to auto start and auto stop on startup/shutdown # respectively. sudo('update-rc.d celeryd defaults 99 01')
def utils_ssl_cert_install(): """ Create the ssl directory, upload the certs and create a combined cert """ source_dir = prompt("ssl key file directory") dest_dir = "/svr/ssl" source_file_list = local("ls {}".format(source_dir), capture=True).split("\n") cmd_crt_comb = "cat {dest_dir}/{site_name}.crt {}/geo_trust_intermediate.crt > {dest_dir}/{site_name}.crt" with cuisine.mode_sudo(): cuisine.dir_ensure("/svr/ssl/", recursive=True) cuisine.dir_attribs(dest_dir, mode="0400") for fl in source_file_list: cuisine.file_upload(dest_dir, "{}/{}".format(source_dir, fl)) cuisine.file_attribs("{}/{}".format(dest_dir, fl), mode="0400") sudo(cmd_crt_comb.format(dest_dir=dest_dir, site_name=env.site_name))