Added support for php, composer, and php utilities
This commit is contained in:
parent
def162c1c9
commit
929a13eb88
5 changed files with 91 additions and 5 deletions
32
scripts/system/install_composer.sh
Normal file
32
scripts/system/install_composer.sh
Normal file
|
|
@ -0,0 +1,32 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
|
||||||
|
echo "Installing composer..."
|
||||||
|
|
||||||
|
EXPECTED_CHECKSUM="$(php -r 'copy("https://composer.github.io/installer.sig", "php://stdout");')"
|
||||||
|
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
|
||||||
|
ACTUAL_CHECKSUM="$(php -r "echo hash_file('sha384', 'composer-setup.php');")"
|
||||||
|
|
||||||
|
if [ "$EXPECTED_CHECKSUM" != "$ACTUAL_CHECKSUM" ]
|
||||||
|
then
|
||||||
|
>&2 echo 'ERROR: Invalid installer checksum'
|
||||||
|
rm composer-setup.php
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
php composer-setup.php --quiet
|
||||||
|
RESULT=$?
|
||||||
|
rm composer-setup.php
|
||||||
|
|
||||||
|
sudo mv composer.phar /usr/local/bin/composer
|
||||||
|
|
||||||
|
if [ $RESULT -eq 0 ]; then
|
||||||
|
|
||||||
|
echo '{"error": 0, "status": 0, "progress": 100, "no_progress":0, "message": "Composer installed sucessfully..."}'
|
||||||
|
|
||||||
|
else
|
||||||
|
echo '{"error": 1, "status": 1, "progress": 100, "no_progress":0, "message": "Error: cannot install composer!"}'
|
||||||
|
|
||||||
|
exit 1
|
||||||
|
|
||||||
|
fi
|
||||||
36
scripts/system/install_leviathanutils.py
Normal file
36
scripts/system/install_leviathanutils.py
Normal file
|
|
@ -0,0 +1,36 @@
|
||||||
|
#!/usr/bin/python3 -u
|
||||||
|
|
||||||
|
import sys, os
|
||||||
|
import subprocess
|
||||||
|
import argparse
|
||||||
|
import platform
|
||||||
|
import shutil
|
||||||
|
import pathlib
|
||||||
|
import distro
|
||||||
|
import pwd
|
||||||
|
import getpass
|
||||||
|
import re
|
||||||
|
import platform
|
||||||
|
|
||||||
|
#import pymysql.cursors
|
||||||
|
#pymysql.install_as_MySQLdb
|
||||||
|
|
||||||
|
pyv=platform.python_version_tuple()
|
||||||
|
|
||||||
|
if pyv[0]!='3':
|
||||||
|
print('Need python 3 for execute this script')
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
parser=argparse.ArgumentParser(prog='install_leviathanutils.py', description='Add leviathanutils for a system user')
|
||||||
|
|
||||||
|
parser.add_argument('--user', help='The user used for install leviathanutils', required=True)
|
||||||
|
|
||||||
|
args=parser.parse_args()
|
||||||
|
|
||||||
|
user=args.user
|
||||||
|
|
||||||
|
if subprocess.call("cd /home/{} && git clone https://git.cuchulu.com/phangoapp/leviathanutils.git && COMPOSER_ALLOW_SUPERUSER=1 composer install --working-dir=/home/{}/leviathanutils && chown -R {}:{} /home/{}/leviathanutils".format(user, user, user, user, user), shell=True) > 0:
|
||||||
|
print('Error, cannot install leviathanutils...')
|
||||||
|
exit(1)
|
||||||
|
|
||||||
|
print("Leviathanutils installed...")
|
||||||
|
|
@ -14,7 +14,7 @@ if [[ $DISTRO =~ ^Debian ]] || [[ $DISTRO =~ ^Ubuntu ]]; then
|
||||||
|
|
||||||
apt-get update
|
apt-get update
|
||||||
apt-get install sudo
|
apt-get install sudo
|
||||||
sudo apt-get -y install python3 python3-full python3-pip python3-venv libaugeas0
|
sudo apt-get -y install python3 python3-full python3-pip python3-venv libaugeas0 python3-distro
|
||||||
|
|
||||||
elif [[ $DISTRO =~ ^NAME=\"Arch ]]; then
|
elif [[ $DISTRO =~ ^NAME=\"Arch ]]; then
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -36,3 +36,20 @@ elif linux_distro=='rocky' or linux_distro=='fedora' or linux_distro=='alma' or
|
||||||
print('Error, cannot upgrade server...')
|
print('Error, cannot upgrade server...')
|
||||||
exit(1)
|
exit(1)
|
||||||
|
|
||||||
|
# Need update certbot and leviathanutils.
|
||||||
|
|
||||||
|
print('Upgrading certbot...')
|
||||||
|
|
||||||
|
#/opt/certbot/bin/pip install --upgrade certbot
|
||||||
|
|
||||||
|
if call("sudo /opt/certbot/bin/pip install --upgrade certbot", shell=True) > 0:
|
||||||
|
print('Error, cannot upgrade certbot...')
|
||||||
|
exit(1)
|
||||||
|
|
||||||
|
print('Upgrading Pastafari utils...')
|
||||||
|
|
||||||
|
print('Upgrading Composer...')
|
||||||
|
|
||||||
|
if call("sudo /usr/local/bin/composer self-update", shell=True) > 0:
|
||||||
|
print('Error, cannot upgrade composer...')
|
||||||
|
exit(1)
|
||||||
|
|
|
||||||
|
|
@ -14,8 +14,10 @@ class ServerTask(Task):
|
||||||
#self.files.append(['modules/pastafari2/scripts/system/install_psutil.sh', 0o755])
|
#self.files.append(['modules/pastafari2/scripts/system/install_psutil.sh', 0o755])
|
||||||
self.files.append(['modules/pastafari2/scripts/system/install_git.py', 0o755])
|
self.files.append(['modules/pastafari2/scripts/system/install_git.py', 0o755])
|
||||||
self.files.append(['modules/pastafari2/scripts/system/install_php.py', 0o755])
|
self.files.append(['modules/pastafari2/scripts/system/install_php.py', 0o755])
|
||||||
|
self.files.append(['modules/pastafari2/scripts/system/install_composer.sh', 0o755])
|
||||||
#self.files.append(['modules/pastafari2/scripts/system/install_unixutils.sh', 0o755])
|
#self.files.append(['modules/pastafari2/scripts/system/install_unixutils.sh', 0o755])
|
||||||
self.files.append(['modules/pastafari2/scripts/system/sudoers.d/spanel', 0o640])
|
self.files.append(['modules/pastafari2/scripts/system/sudoers.d/spanel', 0o640])
|
||||||
|
self.files.append(['modules/pastafari2/scripts/system/install_leviathanutils.py', 0o755])
|
||||||
|
|
||||||
self.files.append([self.data['pub_key'], 0o600])
|
self.files.append([self.data['pub_key'], 0o600])
|
||||||
|
|
||||||
|
|
@ -25,12 +27,11 @@ class ServerTask(Task):
|
||||||
self.commands_to_execute.append(['modules/pastafari2/scripts/system/install_python.sh', ''])
|
self.commands_to_execute.append(['modules/pastafari2/scripts/system/install_python.sh', ''])
|
||||||
self.commands_to_execute.append(['modules/pastafari2/scripts/system/install_git.py', ''])
|
self.commands_to_execute.append(['modules/pastafari2/scripts/system/install_git.py', ''])
|
||||||
self.commands_to_execute.append(['modules/pastafari2/scripts/system/install_php.py', ''])
|
self.commands_to_execute.append(['modules/pastafari2/scripts/system/install_php.py', ''])
|
||||||
#self.commands_to_execute.append(['modules/pastafari2/scripts/system/install_unixutils.sh', ''])
|
self.commands_to_execute.append(['modules/pastafari2/scripts/system/install_composer.sh', ''])
|
||||||
#self.commands_to_execute.append(['modules/pastafari2/scripts/system/install_psutil.sh', ''])
|
|
||||||
|
|
||||||
#' --url_stats='+self.data['url_stats']+
|
|
||||||
|
|
||||||
self.commands_to_execute.append(['modules/pastafari2/scripts/system/install_pzoo_stats.py', '--user='+self.data['ssh_user']+' --pub_key='+self.data['pub_key']+' --group="'+self.data['group_name']+'" --path='+remote_path])
|
self.commands_to_execute.append(['modules/pastafari2/scripts/system/install_pzoo_stats.py', '--user='+self.data['ssh_user']+' --pub_key='+self.data['pub_key']+' --group="'+self.data['group_name']+'" --path='+remote_path])
|
||||||
|
|
||||||
|
self.commands_to_execute.append(['modules/pastafari2/scripts/system/install_leviathanutils.py', '--user='+self.data['ssh_user']])
|
||||||
|
|
||||||
def post_task(self):
|
def post_task(self):
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue