diff --git a/assets/default.nginxconf b/assets/default.nginxconf index 0749fb3..77faa89 100644 --- a/assets/default.nginxconf +++ b/assets/default.nginxconf @@ -53,7 +53,7 @@ server { # pass PHP scripts to FastCGI server location ~ \.php$ { - fastcgi_pass unix:/run/php/php7.0-fpm.sock; + fastcgi_pass unix:/run/php/PHP_FPM_SOCK; fastcgi_index index.php; include fastcgi_params; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; diff --git a/assets/deploy-drupal.sh b/assets/deploy-drupal.sh index 4b84a7b..ce15a8c 100755 --- a/assets/deploy-drupal.sh +++ b/assets/deploy-drupal.sh @@ -1,6 +1,6 @@ #!/bin/bash -echo "updating drupal 8" +echo "updating drupal" echo "Switching to project docroot." cd ./public_html echo "" @@ -9,18 +9,18 @@ git pull --ff-only origin prod git submodule update --init --recursive echo "" echo "Clearing drush caches." -drush cache-clear drush +vendor/bin/drush cache-clear drush echo "" echo "Composer install." composer install --no-dev echo "" echo "Running database updates." -drush updb -y +vendor/bin/drush updb -y echo "" echo "Importing configuration." -drush config-import -y +vendor/bin/drush config-import -y echo "" echo "Clearing caches." -drush cr +vendor/bin/drush cr echo "" echo "Deployment complete." diff --git a/assets/nginx-phpmyadmin.conf b/assets/nginx-phpmyadmin.conf index a671f7f..5fd6417 100644 --- a/assets/nginx-phpmyadmin.conf +++ b/assets/nginx-phpmyadmin.conf @@ -2,7 +2,7 @@ server { listen 80; location /phpmyadmin { # server_name phpmyadmin.idroot.net; - root /var/www/phpmyadmin; + root /var/www/html; index index.php; @@ -22,7 +22,7 @@ server { } location ~ \.php$ { - fastcgi_pass unix:/run/php/php8.2-fpm.sock; + fastcgi_pass unix:/run/php/PHP_FPM_SOCK; fastcgi_index index.php; include fastcgi_params; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; diff --git a/bin/_addUserSite.sh b/bin/_addUserSite.sh index 66acabe..bcb8cc3 100755 --- a/bin/_addUserSite.sh +++ b/bin/_addUserSite.sh @@ -111,7 +111,7 @@ do echo -n "confirm password" read passwdb if [ "$passwda" = "$passwdb" ]; then - $_pswd=$passwda + _pswd=$passwda passok=1 else echo "pass words don't match, please try again" @@ -119,8 +119,10 @@ do done if [ "$passok" = 1 ]; then + # TODO: not implemented yet, run manually for now: # mysql> create user '$_dbname'@'localhost' identified by '$_pswd'; # mysql> create database $_dbname; # mysql> grant all privileges on esadhar_eval.* to 'esadhar_eval'@'localhost'; # mysql> flush privileges; + : fi diff --git a/bin/autoupdate.sh b/bin/autoupdate.sh index a47f160..a0e9b1c 100755 --- a/bin/autoupdate.sh +++ b/bin/autoupdate.sh @@ -11,7 +11,7 @@ echo -e '\033[35m # https://www.howtoforge.com/how-to-configure-automatic-updates-on-debian-wheezy # https://www.bisolweb.com/tutoriels/serveur-vps-ovh-partie-5-installation-apticron/ -if [ "$EUID" -ne 0 ]; then +if [ "$(id -u)" -ne 0 ]; then echo "Please run as root" exit fi diff --git a/bin/email.sh b/bin/email.sh index f2d2aa9..8f4103c 100755 --- a/bin/email.sh +++ b/bin/email.sh @@ -9,7 +9,7 @@ echo -e '\033[35m \033[0m' echo -e "\033[35;1mEnable mail sending for php \033[0m" -if [ "$EUID" -ne 0 ]; then +if [ "$(id -u)" -ne 0 ]; then echo "Please run as root" exit fi diff --git a/bin/fail2ban.sh b/bin/fail2ban.sh index 8bc0cb8..62d8da9 100755 --- a/bin/fail2ban.sh +++ b/bin/fail2ban.sh @@ -11,7 +11,7 @@ echo -e '\033[35m \033[0m' echo -e "\033[35;1mInstalling fall2ban \033[0m" -if [ "$EUID" -ne 0 ]; then +if [ "$(id -u)" -ne 0 ]; then echo "Please run as root" exit fi diff --git a/bin/firewall.sh b/bin/firewall.sh index fd2c458..2d5e9ec 100755 --- a/bin/firewall.sh +++ b/bin/firewall.sh @@ -11,7 +11,7 @@ echo -e '\033[35m \033[0m' echo -e "\033[35;1mInstalling ufw and setup firewall (allowing only ssh and http) \033[0m" -if [ "$EUID" -ne 0 ]; then +if [ "$(id -u)" -ne 0 ]; then echo "Please run as root" exit fi diff --git a/bin/ftp.sh b/bin/ftp.sh index 5ab7a88..df0397f 100755 --- a/bin/ftp.sh +++ b/bin/ftp.sh @@ -10,7 +10,7 @@ echo -e '\033[35m |_| |_| |_| \033[0m' -if [ "$EUID" -ne 0 ] +if [ "$(id -u)" -ne 0 ] then echo "Please run as root" exit fi diff --git a/bin/gitbarrerepos.sh b/bin/gitbarrerepos.sh index 73bfcb3..f5ffb01 100755 --- a/bin/gitbarrerepos.sh +++ b/bin/gitbarrerepos.sh @@ -110,10 +110,10 @@ if [ "$vh" = "yes" ]; then cd /home/"$user"/git-repositories/"$_domain".git/hooks/ chmod +x post-receive # pre-receive - # setup git repo on site folder + echo "setup git repo on site folder" cd /home/"$user"/www/"$_domain"/public_html su -c "git init" $user - # link to the bare repo + echo "link to the bare repo" su -c "git remote add origin /home/$user/git-repositories/$_domain.git" $user chown -R "$user":"$user" /home/"$user"/www/"$_domain" diff --git a/bin/knockd.sh b/bin/knockd.sh index a462db4..f8d107a 100755 --- a/bin/knockd.sh +++ b/bin/knockd.sh @@ -11,7 +11,7 @@ echo -e '\033[35m \033[0m' echo -e "\033[35;1mInstalling knockd to control ssh port opening\033[0m" -if [ "$EUID" -ne 0 ]; then +if [ "$(id -u)" -ne 0 ]; then echo "Please run as root" exit fi diff --git a/bin/lemp.sh b/bin/lemp.sh index cf0b89b..774767a 100755 --- a/bin/lemp.sh +++ b/bin/lemp.sh @@ -10,7 +10,7 @@ echo -e '\033[35m \033[0m' echo -e "\033[35;1mLEMP server (Nginx Mysql Php-fpm) \033[0m" -if [ "$EUID" -ne 0 ]; then +if [ "$(id -u)" -ne 0 ]; then echo "Please run as root" exit fi @@ -42,7 +42,7 @@ sleep 3 apt-get --yes install ca-certificates apt-transport-https software-properties-common curl lsb-release curl -sSL https://packages.sury.org/php/README.txt | bash -x -apt-get update && apt-get upgrade +apt-get update && apt-get --yes upgrade echo -e "\033[35;1mInstalling PHP \033[0m" sleep 3 @@ -103,6 +103,7 @@ sleep 3 apt-get --yes install nginx mv /etc/nginx/sites-available/default /etc/nginx/sites-available/default.ori cp "$_assets"/default.nginxconf /etc/nginx/sites-available/default +sed -i "s/PHP_FPM_SOCK/php${PHP_VERSION}-fpm.sock/g" /etc/nginx/sites-available/default systemctl enable nginx systemctl restart nginx @@ -163,6 +164,7 @@ if [ "$installmysql" = "yes" ]; then apt-get --yes install phpmyadmin ln -s /usr/share/phpmyadmin /var/www/html/ cp "$_assets"/nginx-phpmyadmin.conf /etc/nginx/sites-available/phpmyadmin.conf + sed -i "s/PHP_FPM_SOCK/php${PHP_VERSION}-fpm.sock/g" /etc/nginx/sites-available/phpmyadmin.conf echo -e "\033[92;1mphpMyAdmin installed\033[Om" echo -e "\033[92;1mYou can access it at yourip/phpmyadmin\033[Om" @@ -192,7 +194,7 @@ echo -e '\033[35m \033[0m' echo -e "\033[35;1mInstalling Redis \033[0m" sleep 3 -apt-get --yes install redis-server php8.1-redis +apt-get --yes install redis-server php${PHP_VERSION}-redis # TODO set maxmemory=2gb # TODO set maxmemory-policy=volatile-lru @@ -206,7 +208,7 @@ apt-get --yes install redis-server php8.1-redis systemctl enable redis-server systemctl restart redis-server -systemctl restart php8.1-fpm +systemctl restart php${PHP_VERSION}-fpm echo -e "\033[92;1mRedis installed\033[Om" echo -e '\033[35m diff --git a/bin/misc.sh b/bin/misc.sh index b8e31c6..a4e7b74 100755 --- a/bin/misc.sh +++ b/bin/misc.sh @@ -9,7 +9,7 @@ echo -e '\033[35m \033[0m' -if [ "$EUID" -ne 0 ]; then +if [ "$(id -u)" -ne 0 ]; then echo "Please run as root" exit fi diff --git a/bin/mysql-db.sh b/bin/mysql-db.sh index 9081789..00515b0 100755 --- a/bin/mysql-db.sh +++ b/bin/mysql-db.sh @@ -9,7 +9,10 @@ echo -e ' echo -e "Create new mysql db and user (you will be asked a db name and a password)" -. bin/checkroot.sh +if [ "$(id -u)" -ne 0 ]; then + echo "Please run as root" + exit +fi sleep 3 diff --git a/bin/mysqlbackup.sh b/bin/mysqlbackup.sh index b3d4987..cafad0f 100755 --- a/bin/mysqlbackup.sh +++ b/bin/mysqlbackup.sh @@ -8,7 +8,7 @@ echo -e '\033[35m |__/ |_| |_| \033[0m' -if [ "$EUID" -ne 0 ]; then +if [ "$(id -u)" -ne 0 ]; then echo "Please run as root" exit fi diff --git a/bin/postgresqlbackup.sh b/bin/postgresqlbackup.sh index 3a0a7fa..5be79f8 100755 --- a/bin/postgresqlbackup.sh +++ b/bin/postgresqlbackup.sh @@ -8,7 +8,7 @@ echo -e '\033[35m |___/ |_| \033[0m' -if [ "$EUID" -ne 0 ]; then +if [ "$(id -u)" -ne 0 ]; then echo "Please run as root" exit fi diff --git a/bin/ssh.sh b/bin/ssh.sh index 40a88a2..57ef0a6 100755 --- a/bin/ssh.sh +++ b/bin/ssh.sh @@ -9,7 +9,7 @@ echo -e '\033[35m /____/____/_/ /_/ \033[0m' -if [ "$EUID" -ne 0 ]; then +if [ "$(id -u)" -ne 0 ]; then echo "Please run as root" exit fi diff --git a/bin/upgrade.sh b/bin/upgrade.sh index 90afe74..d125fb4 100755 --- a/bin/upgrade.sh +++ b/bin/upgrade.sh @@ -10,7 +10,7 @@ echo -e '\033[35m \____/_/ \____/_/ |_/_/ |_/_____/_____/ \033[0m' -if [ "$EUID" -ne 0 ]; then +if [ "$(id -u)" -ne 0 ]; then echo "Please run as root" exit fi diff --git a/bin/urbackup.sh b/bin/urbackup.sh index 2a43ac2..5506ea8 100755 --- a/bin/urbackup.sh +++ b/bin/urbackup.sh @@ -9,7 +9,7 @@ echo -e '\033[35m |_| \033[0m' -if [ "$EUID" -ne 0 ]; then +if [ "$(id -u)" -ne 0 ]; then echo "Please run as root" exit fi @@ -81,8 +81,7 @@ ufw allow from "$_ip" to any port 35622 ufw allow from "$_ip" to any port 35623 # install and enable systemd service -# cp "$_assets"/urbackup.service /etc/systemd/system/ -cp urbackupclientbackend-debian.service /etc/systemd/system/urbackup.service +cp "$_assets"/urbackup.service /etc/systemd/system/urbackup.service chmod a+x /etc/systemd/system/urbackup.service systemctl --system daemon-reload diff --git a/bin/user.sh b/bin/user.sh index 6fe2c25..483a0ea 100755 --- a/bin/user.sh +++ b/bin/user.sh @@ -9,7 +9,7 @@ echo -e '\033[35m \033[0m' echo -e "\033[35;1mCreate new user (you will be asked a user name and a password) \033[0m" -if [ "$EUID" -ne 0 ]; then +if [ "$(id -u)" -ne 0 ]; then echo "Please run as root" exit fi diff --git a/bin/webhook.sh b/bin/webhook.sh index 6da615f..521b243 100755 --- a/bin/webhook.sh +++ b/bin/webhook.sh @@ -93,7 +93,7 @@ git --git-dir=/home/"$user"/git-repositories/"$_domain.git" remote add origin "$ cp -f "$_assets"/webhook-deploy.sh /home/"$user"/webhook-deploy-"$_id".sh sed -i -r "s/DOMAIN/$_domain/g" /home/"$user"/webhook-deploy-"$_id".sh sed -i -r "s/USER/$user/g" /home/"$user"/webhook-deploy-"$_id".sh -chowm $user:$user /home/"$user"/webhook-deploy-"$_id".sh +chown $user:$user /home/"$user"/webhook-deploy-"$_id".sh chmod +x /home/"$user"/webhook-deploy-"$_id".sh # remove git bare repos hook diff --git a/bin/zabbix.sh b/bin/zabbix.sh index 42ad268..b576eda 100755 --- a/bin/zabbix.sh +++ b/bin/zabbix.sh @@ -9,7 +9,7 @@ echo -e '\033[35m /____/\__,_/_.___/_.___/_/_/|_| \033[0m' -if [ "$EUID" -ne 0 ]; then +if [ "$(id -u)" -ne 0 ]; then echo "Please run as root" exit fi diff --git a/install.sh b/install.sh index b000331..59fe866 100755 --- a/install.sh +++ b/install.sh @@ -15,7 +15,7 @@ echo -e '\033[35m \033[0m' echo -e "\033[35;1mThis script has been tested only on Linux Debian 10 \033[0m" -if [ "$EUID" -ne 0 ]; then +if [ "$(id -u)" -ne 0 ]; then echo "Please run as root" exit fi