From 5ad597a9f775e1e4e323324be815753cc0dd7cab Mon Sep 17 00:00:00 2001 From: Robert Date: Mon, 11 Dec 2023 14:17:34 -0500 Subject: [PATCH] make-sums --- README.md | 2 +- app/neato.php | 2 +- compile-phar.php => build/compile-phar.php | 2 +- install_neato.sh => build/install_neato.sh | 20 ++++++++++--------- build/make-sums.sh | 13 ++++++++++++ neato_deploy.sh => build/neato_deploy.sh | 0 .../neato_deploy_php_cli.ini | 0 .../neato_php_cli_phar.ini | 0 selftar.sh => make-installer.sh | 5 ++++- 9 files changed, 31 insertions(+), 13 deletions(-) rename compile-phar.php => build/compile-phar.php (94%) rename install_neato.sh => build/install_neato.sh (64%) create mode 100644 build/make-sums.sh rename neato_deploy.sh => build/neato_deploy.sh (100%) rename neato_deploy_php_cli.ini => build/neato_deploy_php_cli.ini (100%) rename neato_php_cli_phar.ini => build/neato_php_cli_phar.ini (100%) rename selftar.sh => make-installer.sh (71%) diff --git a/README.md b/README.md index f3fc90b..5f7f042 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # neatoDeploy -$ ./selftar.sh +$ ./make-installer.sh Then scp over the neato_deploy.tar.gz.self to your sever. diff --git a/app/neato.php b/app/neato.php index 96a5769..e2335ee 100644 --- a/app/neato.php +++ b/app/neato.php @@ -94,7 +94,7 @@ if (file_exists($cwd . '/deploy_' . $file.'.php')) { } if ($skipdeploy) { - echo "Skipping Deploy php file..."; + echo "Skipping Deploy php file...\r\n"; exit(0); } diff --git a/compile-phar.php b/build/compile-phar.php similarity index 94% rename from compile-phar.php rename to build/compile-phar.php index c2aec62..13dd9e7 100644 --- a/compile-phar.php +++ b/build/compile-phar.php @@ -21,7 +21,7 @@ $phar->startBuffering(); $defaultStub = $phar->createDefaultStub('neato.php'); // Add the rest of the apps files -$phar->buildFromDirectory(__DIR__ . '/app'); +$phar->buildFromDirectory(__DIR__ . '/../app'); // Customize the stub to add the shebang $stub = "\n" . $defaultStub; diff --git a/install_neato.sh b/build/install_neato.sh similarity index 64% rename from install_neato.sh rename to build/install_neato.sh index d8c13b7..752767e 100755 --- a/install_neato.sh +++ b/build/install_neato.sh @@ -1,6 +1,6 @@ #!/bin/bash -PHPCLI='php8.2-cli' +PHPCLI='php8.3-cli' if [ "$EUID" -ne 0 ]; then echo "Please run as root!" @@ -11,14 +11,16 @@ current_directory=$(pwd) target_directory="/opt/neatoDeploy" if [ "$current_directory" == "$target_directory" ]; then - echo "Do not run this script inside of source folder /opt/neatoDeploy!" + echo "Do not run this script inside of source folder /opt/neatoDeploy/build!" exit 1 fi mkdir -p /opt/neatoDeployments -cp neato_deploy_php_cli.ini /opt/neatoDeployments/ -cp neatoDeploy.phar /opt/neatoDeployments/ -cp neato_deploy.sh /opt/neatoDeployments/ +mv neato_deploy_php_cli.ini /opt/neatoDeployments/ +mv neatoDeploy.phar /opt/neatoDeployments/ +mv neato_deploy.sh /opt/neatoDeployments/ +mv make-sums.sh /opt/neatoDeployments/ +cp config_files/deploy_*.php /opt/neatoDeployments/ pushd /opt/neatoDeployments @@ -29,16 +31,16 @@ pushd /opt/neatoDeployments /usr/bin/dpkg -s curl 2>/dev/null >/dev/null || /usr/bin/apt-get install -y curl chown www-data:www-data neato* +chown www-data:www-data make-sums.sh +chown www-data:www-data deploy_*.php chmod 775 neatoDeploy.phar chmod 775 neato_deploy.sh +chmod 775 make-sums.sh chmod 664 neato_deploy_php_cli.ini +chmod 664 deploy_*.php popd -rm neato_deploy_php_cli.ini -rm neatoDeploy.phar -rm neato_deploy.sh - echo -e "\nRemove the install_neato.sh file!" echo -e "\nRemove the neato_deploy.tar.gz.self file!" \ No newline at end of file diff --git a/build/make-sums.sh b/build/make-sums.sh new file mode 100644 index 0000000..8f3b218 --- /dev/null +++ b/build/make-sums.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +for file in deploy_*.php; do + if [ -f "$file" ]; then + echo -e "Making sum file for: $file \r\n" + + # Remove "deploy_" from the beginning and ".php" from the end + new_file_name=$(echo "$file" | sed 's/^deploy_//;s/\.php$//') + + php -c /opt/neatoDeployments/neatoDeploy.ini -f /opt/neatoDeployments/neatoDeploy.phar "$new_file_name" -marksafe -skipdeploy + fi +done + diff --git a/neato_deploy.sh b/build/neato_deploy.sh similarity index 100% rename from neato_deploy.sh rename to build/neato_deploy.sh diff --git a/neato_deploy_php_cli.ini b/build/neato_deploy_php_cli.ini similarity index 100% rename from neato_deploy_php_cli.ini rename to build/neato_deploy_php_cli.ini diff --git a/neato_php_cli_phar.ini b/build/neato_php_cli_phar.ini similarity index 100% rename from neato_php_cli_phar.ini rename to build/neato_php_cli_phar.ini diff --git a/selftar.sh b/make-installer.sh similarity index 71% rename from selftar.sh rename to make-installer.sh index 3409e28..29922f4 100755 --- a/selftar.sh +++ b/make-installer.sh @@ -1,10 +1,11 @@ #!/bin/bash +pushd build /usr/bin/php -c neato_php_cli_phar.ini -f compile-phar.php chmod +x install_neato.sh TAR_FILE=neato_deploy.tar.gz -tar -czvf $TAR_FILE install_neato.sh neatoDeploy.phar neato_deploy_php_cli.ini neato_deploy.sh +tar -czvf $TAR_FILE install_neato.sh make-sums.sh neatoDeploy.phar neato_deploy_php_cli.ini neato_deploy.sh ../config_files/deploy_*.php EXIT_COMMAND="./install_neato.sh" @@ -16,3 +17,5 @@ echo "$EXIT_COMMAND; exit" >> $SELF_EXTRACTABLE cat $TAR_FILE >> $SELF_EXTRACTABLE chmod a+x $SELF_EXTRACTABLE +mv $SELF_EXTRACTABLE .. +popd \ No newline at end of file