From 540d964935ba932ffaaf70aaa3663cd31eefb5b9 Mon Sep 17 00:00:00 2001 From: Bachir Soussi Chiadmi Date: Sat, 7 Apr 2018 16:13:19 +0200 Subject: [PATCH] fixed assets path every where --- bin/email.sh | 14 +++++++++++++- bin/firewall.sh | 3 +++ bin/ftp.sh | 13 ++++++++++++- bin/gitbarrerepos.sh | 22 +++++++++++++++++----- bin/knockd.sh | 14 +++++++++++++- bin/lemp.sh | 24 ++++++++++++++++++------ 6 files changed, 76 insertions(+), 14 deletions(-) diff --git a/bin/email.sh b/bin/email.sh index 8d6b891..5478ad9 100755 --- a/bin/email.sh +++ b/bin/email.sh @@ -14,6 +14,18 @@ if [ "$EUID" -ne 0 ]; then exit fi +# get the current position +_cwd="$(pwd)" +# check for assets forlder +_assets="$_cwd/assets" +if [ ! -d "$_assets" ]; then + _assets="$_cwd/../assets" + if [ ! -d "$_assets" ]; then + echo "!! can't find assets directory !!" + exit + fi +fi + # http://www.sycha.com/lamp-setup-debian-linux-apache-mysql-php#anchor13 sleep 2 apt-get --yes --force-yes install exim4 @@ -53,7 +65,7 @@ if [ "$installdkim" = "y" ]; then chown root:Debian-exim /etc/exim4/dkim/"$domain"-private.pem chmod 440 /etc/exim4/dkim/"$domain"-private.pem - cp "$_cwd"/assets/exima4_dkim.conf /etc/exim4/conf.d/main/00_local_macros + cp "$_assets"/exima4_dkim.conf /etc/exim4/conf.d/main/00_local_macros sed -ir "s/DOMAIN_TO_CHANGE/$domain/g" /etc/exim4/conf.d/main/00_local_macros sed -ir "s/DATE_TO_CHANGE/$selector/g" /etc/exim4/conf.d/main/00_local_macros diff --git a/bin/firewall.sh b/bin/firewall.sh index ab76bae..da0ee28 100755 --- a/bin/firewall.sh +++ b/bin/firewall.sh @@ -21,6 +21,9 @@ apt-get --yes --force-yes install ufw # ufw allow ssh # knockd will open the ssh port ufw allow http ufw allow https + +# TODO ask for allowing ssh for some ip + ufw enable ufw status verbose echo "\033[92;1mufw installed and firwall configured\033[Om" diff --git a/bin/ftp.sh b/bin/ftp.sh index 8ba2d56..91c2e4b 100755 --- a/bin/ftp.sh +++ b/bin/ftp.sh @@ -15,6 +15,17 @@ if [ "$EUID" -ne 0 ] exit fi +# get the current position +_cwd="$(pwd)" +# check for assets forlder +_assets="$_cwd/assets" +if [ ! -d "$_assets" ]; then + _assets="$_cwd/../assets" + if [ ! -d "$_assets" ]; then + echo "!! can't find assets directory !!" + exit + fi +fi echo "installing proftpd" apt-get --yes --force-yes install proftpd @@ -32,7 +43,7 @@ fi done echo "Configuring proftpd" -cp "$_cwd"/assets/proftpd.conf /etc/proftpd/conf.d/"$_server_name".conf +cp "$_assets"/proftpd.conf /etc/proftpd/conf.d/"$_server_name".conf sed -ir "s/example/$_server_name/g" /etc/proftpd/conf.d/"$_server_name".conf ufw allow ftp diff --git a/bin/gitbarrerepos.sh b/bin/gitbarrerepos.sh index 92689d1..a6f4494 100755 --- a/bin/gitbarrerepos.sh +++ b/bin/gitbarrerepos.sh @@ -9,10 +9,22 @@ echo -e '\033[35m / ____(_) /_ / / __/ / __/ / /_/ / / /_ -\____/_/\__/ +\____/_/\__/ \033[0m' echo -e "\033[35;1mCreate new git barre repos and deploy script\033[0m" +# get the current position +_cwd="$(pwd)" +# check for assets forlder +_assets="$_cwd/assets" +if [ ! -d "$_assets" ]; then + _assets="$_cwd/../assets" + if [ ! -d "$_assets" ]; then + echo "!! can't find assets directory !!" + exit + fi +fi + while [ "$_bare_name" = "" ] do @@ -56,9 +68,9 @@ git init --bare # add deploy script if [ "$_drupal" = "yes" ]; then - cp "$_cwd"/assets/deploy-drupal.sh "$_prod_folder_path"/deploy.sh + cp "$_assets"/deploy-drupal.sh "$_prod_folder_path"/deploy.sh else - cp "$_cwd"/assets/deploy-simple.sh "$_prod_folder_path"/deploy.sh + cp "$_assets"/deploy-simple.sh "$_prod_folder_path"/deploy.sh fi # setup git repo on site folder @@ -69,8 +81,8 @@ git remote add origin /home/"$USER"/git-repositories/"$_bare_name".git # create hooks that will update the site repo cd ~ -cp "$_cwd"/assets/git-pre-receive /home/"$USER"/git-repositories/"$_bare_name".git/hooks/pre-receive -cp "$_cwd"/assets/git-post-receive /home/"$USER"/git-repositories/"$_bare_name".git/hooks/post-receive +cp "$_assets"/git-pre-receive /home/"$USER"/git-repositories/"$_bare_name".git/hooks/pre-receive +cp "$_assets"/git-post-receive /home/"$USER"/git-repositories/"$_bare_name".git/hooks/post-receive sed -ir "s/PRODDIR=\"www\"/PRODDIR=$_prod_folder_path/g" /home/"$USER"/git-repositories/"$_bare_name".git/hooks/pre-receive sed -ir "s/PRODDIR=\"www\"/PRODDIR=$_prod_folder_path/g" /home/"$USER"/git-repositories/"$_bare_name".git/hooks/post-receive diff --git a/bin/knockd.sh b/bin/knockd.sh index f48ee73..53a2028 100755 --- a/bin/knockd.sh +++ b/bin/knockd.sh @@ -16,11 +16,23 @@ if [ "$EUID" -ne 0 ]; then exit fi +# get the current position +_cwd="$(pwd)" +# check for assets forlder +_assets="$_cwd/assets" +if [ ! -d "$_assets" ]; then + _assets="$_cwd/../assets" + if [ ! -d "$_assets" ]; then + echo "!! can't find assets directory !!" + exit + fi +fi + sleep 2 apt-get --yes --force-yes install knockd mv /etc/knockd.conf /etc/knockd.conf.ori -cp "$_cwd"/assets/knockd.conf /etc/knockd.conf +cp "$_assets"/knockd.conf /etc/knockd.conf echo -n "define a sequence number for opening ssh (as 7000,8000,9000) : " read sq sed -i "s/7000,8000,9000/$sq/g" /etc/knockd.conf diff --git a/bin/lemp.sh b/bin/lemp.sh index d757592..6ac738b 100755 --- a/bin/lemp.sh +++ b/bin/lemp.sh @@ -15,6 +15,18 @@ if [ "$EUID" -ne 0 ]; then exit fi +# get the current position +_cwd="$(pwd)" +# check for assets forlder +_assets="$_cwd/assets" +if [ ! -d "$_assets" ]; then + _assets="$_cwd/../assets" + if [ ! -d "$_assets" ]; then + echo "!! can't find assets directory !!" + exit + fi +fi + sleep 2 echo -e '\033[35m @@ -45,13 +57,13 @@ sleep 3 apt-get --yes --force-yes install php7.0-fpm php7.0-mysql php7.0-opcache php7.0-curl php7.0-mbstring php7.0-zip php7.0-xml php7.0-gd php7.0-mcrypt php-memcached mv /etc/php/7.0/fpm/php.ini /etc/php/7.0/fpm/php.ini.back -cp "$_cwd"/assets/php-fpm.ini /etc/php/7.0/fpm/php.ini +cp "$_assets"/php-fpm.ini /etc/php/7.0/fpm/php.ini echo -e "Configuring PHP" mkdir /var/log/php chown www-data /var/log/php -cp "$_cwd"/assets/logrotate-php /etc/logrotate.d/php +cp "$_assets"/logrotate-php /etc/logrotate.d/php systemctl enable php7.0-fpm systemctl start php7.0-fpm @@ -77,7 +89,7 @@ echo -e "\033[35;1mInstalling Nginx \033[0m" sleep 3 apt-get --yes --force-yes install nginx mv /etc/nginx/sites-available/default /etc/nginx/sites-available/default.ori -cp "$_cwd"/assets/default.nginxconf /etc/nginx/sites-available/default +cp "$_assets"/default.nginxconf /etc/nginx/sites-available/default systemctl enable nginx systemctl restart nginx @@ -94,12 +106,12 @@ echo -e '\033[35m echo -e "\033[35;1mInstalling phpMyAdmin \033[0m" apt-get --yes --force-yes install phpmyadmin ln -s /usr/share/phpmyadmin /var/www/html/ -# cp "$_cwd"/assets/nginx-phpmyadmin.conf > /etc/nginx/sites-available/phpmyadmin.conf +# cp "$_assets"/nginx-phpmyadmin.conf > /etc/nginx/sites-available/phpmyadmin.conf # ln -s /etc/nginx/sites-available/phpmyadmin.conf /etc/nginx/sites-enabled/phpmyadmin.conf # echo -e "\033[35;1msecuring phpMyAdmin \033[0m" # sed -i "s/DirectoryIndex index.php/DirectoryIndex index.php\nAllowOverride all/" -# cp "$_cwd"/assets/phpmyadmin_htaccess > /usr/share/phpmyadmin/.htaccess +# cp "$_assets"/phpmyadmin_htaccess > /usr/share/phpmyadmin/.htaccess # echo -n "define a user name for phpmyadmin : " # read un # htpasswd -c /etc/phpmyadmin/.htpasswd $un @@ -206,7 +218,7 @@ echo -e "\033[92;1mDrush and DrupalConsoleinstalled\033[Om" # # https://www.howtoforge.com/tutorial/server-monitoring-with-munin-and-monit-on-debian/2/ # apt-get --yes --force-yes install monit # # TODO setup monit rc -# cat "$_cwd"/assets/monitrc > /etc/monit/monitrc +# cat "$_assets"/monitrc > /etc/monit/monitrc # # # TODO setup webaccess # passok=0