Added simple tasks

This commit is contained in:
Antonio de la Rosa 2022-04-26 00:42:48 +02:00
parent 0b509f74e5
commit 57b1064734
7 changed files with 160 additions and 3 deletions

View file

@ -0,0 +1,55 @@
#!/usr/bin/env python3
import sys
import subprocess
import argparse
import platform
import distro
pyv=platform.python_version_tuple()
if pyv[0]!='3':
print('Need python 3 for execute this script')
sys.exit(1)
parser = argparse.ArgumentParser(description='Script for create a new mariadb server.')
parser.add_argument('--password', help='The password of the new server', required=True)
args = parser.parse_args()
linux_distro=distro.id()
#Dash, the default debian stretch shell, don't support <<<
#sudo debconf-set-selections <<< 'mariadb-server mariadb-server/root_password password your_password'
#sudo debconf-set-selections <<< 'mariadb-server mariadb-server/root_password_again password your_password'
print('Installing MariaDB...')
if linux_distro=='debian':
if subprocess.call("sudo DEBIAN_FRONTEND=noninteractive apt-get -y --force-yes install mariadb-server", shell=True) > 0:
print('Error, cannot install MariaDB...')
sys.exit(1)
elif linux_distro=='arch':
if call("sudo pacman -S --noconfirm mariadb", shell=True) > 0:
print('Error, cannot install MariaDB...')
exit(1)
print('Setting the password...')
if subprocess.call("sudo mysqladmin -u root password "+args.password, shell=True) > 0:
print('Error, cannot set the MariaDB Root password')
sys.exit(1)
else:
print('Mariadb installed successfully')
sys.exit(0)
"""
if subprocess.call("sudo echo 'mariadb-server mariadb-server/root_password_again password "+args.password+"' | sudo debconf-set-selections", shell=True) > 0:
print('Error, cannot set the password again')
sys.exit(1)
"""
print('Setted the password')

View file

@ -19,6 +19,7 @@ parser.add_argument('--url_stats', help='The url where pastafaristats notify the
parser.add_argument('--user', help='The user for pastafari', required=True)
parser.add_argument('--pub_key', help='The pub key used in pastafari user', required=True)
parser.add_argument('--group', help='Server group', required=False)
parser.add_argument('--path', help='A path used for save internal things for pastafari', required=True)
args = parser.parse_args()
@ -98,9 +99,11 @@ if check_url.match(args.url_stats):
#su - $USER -s /bin/bash -c "composer --working-dir=$HOME/scripts require guzzlehttp/guzzle:~6.0"
#pt=Path('/home/'+args.user+'/pzoo/tasks')
args.path=os.path.basename(args.path)
#pt.mkdir(mode=0o755, parents=True, exist_ok=True)
pt=Path('/home/'+args.user+'/'+args.path+'/tasks')
pt.mkdir(mode=0o755, parents=True, exist_ok=True)
# Create scripts pzoo
"""