diff --git a/.gitignore b/.gitignore index 500e047..4bdf173 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,6 @@ vendor/ +app/deploy_files +sums/ run/*.lck log/*.txt *.pub diff --git a/README.md b/README.md index 86c2686..6751fa6 100644 --- a/README.md +++ b/README.md @@ -38,4 +38,4 @@ $ sudo ./neato_deploy.sh security_audit Note that deployment files are named with the prefix of deploy_ and end with .php, they must be a valid PHP script... -A few example deployments are given from the config_files directory and will be extracted upon running the file: neato_deploy.tar.gz.self to the /opt/neatoDemployments ROOT DIR. \ No newline at end of file +A few example deployments are given from the deploy_files directory and will be extracted upon running the file: neato_deploy.tar.gz.self to the /opt/neatoDemployments ROOT DIR. diff --git a/app/just_testing.sh b/app/just_testing.sh new file mode 100755 index 0000000..782209e --- /dev/null +++ b/app/just_testing.sh @@ -0,0 +1,6 @@ +#!/bin/bash +if [ ! -L deploy_files ]; then + ln -s ../deploy_files . +fi + +php -c build/neatoDeploy.ini -f neato.php $@ diff --git a/app/neato.php b/app/neato.php index 1a6e2af..e9c451b 100644 --- a/app/neato.php +++ b/app/neato.php @@ -53,7 +53,7 @@ if (is_string_found($argv[1], 'http://') || is_string_found($argv[1], 'https://' $file = str_replace(".txt", "", $file); clean_file_name($file); } - \utils\curl::save($argv[1], "deploy_{$file}.php"); + \utils\curl::save($argv[1], "/deploy_files/deploy_{$file}.php"); } function save_sha($shasum) { @@ -63,7 +63,7 @@ function save_sha($shasum) { function do_harm_checker($shasum) { require 'neato_danger_checker.php'; - if ( is_file_dangerious($GLOBALS['cwd'] . '/deploy_' . $GLOBALS['file'].'.php') ) { + if ( is_file_dangerious($GLOBALS['cwd'] . '/deploy_files/deploy_' . $GLOBALS['file'].'.php') ) { if (! $GLOBALS['auto']) { $answer = readline("Do you wish to execute this Script, anyways!! ? "); if ( strtolower( trim($answer) ) === "yes" ) { @@ -76,9 +76,9 @@ function do_harm_checker($shasum) { } /* Keep as last lines */ -if (file_exists($cwd . '/deploy_' . $file.'.php')) { +if (file_exists($cwd . '/deploy_files/deploy_' . $file.'.php')) { $check_for_harm = true; - $shasum = shasum($cwd . '/deploy_' . $file.'.php'); + $shasum = shasum($cwd . '/deploy_files/deploy_' . $file.'.php'); if ($shasum === false) { echo "Unable to SHA sum script!"; exit(1); @@ -111,9 +111,9 @@ if (file_exists($cwd . '/deploy_' . $file.'.php')) { do_harm_checker($shasum); } - require($cwd . '/deploy_' . $file.'.php'); + require($cwd . '/deploy_files/deploy_' . $file.'.php'); } else { - echo 'PHP Script deploy_'. $file . '.php does not exist!!' . PHP_EOL; + echo 'PHP Script deploy_files/deploy_'. $file . '.php does not exist!!' . PHP_EOL; exit(1); } diff --git a/build/compile-phar.php b/build/compile-phar.php index 13dd9e7..620d0b2 100644 --- a/build/compile-phar.php +++ b/build/compile-phar.php @@ -21,7 +21,10 @@ $phar->startBuffering(); $defaultStub = $phar->createDefaultStub('neato.php'); // Add the rest of the apps files -$phar->buildFromDirectory(__DIR__ . '/../app'); +$phar->buildFromDirectory( + __DIR__ . '/../app', // Base APP folder + '/\.php$/', // Regular expression to include only PHP files +); // Customize the stub to add the shebang $stub = "\n" . $defaultStub; diff --git a/build/install_neato.sh b/build/install_neato.sh index 8c0dffa..3478d79 100755 --- a/build/install_neato.sh +++ b/build/install_neato.sh @@ -16,13 +16,13 @@ if [ "$current_directory" == "$target_directory" ]; then exit 1 fi -/usr/bin/mkdir -p /opt/neatoDeployments +/usr/bin/mkdir -p /opt/neatoDeployments/deploy_files /usr/bin/mv neato_deploy_php_cli.ini /opt/neatoDeployments/ /usr/bin/mv neatoDeploy.phar /opt/neatoDeployments/ /usr/bin/mv neato_deploy.sh /opt/neatoDeployments/ /usr/bin/mv make-sums.sh /opt/neatoDeployments/ -/usr/bin/mv config_files/deploy_*.php /opt/neatoDeployments/ -/usr/bin/rmdir config_files +/usr/bin/mv deploy_files/deploy_*.php /opt/neatoDeployments/deploy_files/ +/usr/bin/rmdir deploy_files pushd /opt/neatoDeployments @@ -35,13 +35,13 @@ pushd /opt/neatoDeployments /usr/bin/chown www-data:www-data neato* /usr/bin/chown www-data:www-data make-sums.sh -/usr/bin/chown www-data:www-data deploy_*.php +/usr/bin/chown -R www-data:www-data deploy_files /usr/bin/chmod 775 neatoDeploy.phar /usr/bin/chmod 775 neato_deploy.sh /usr/bin/chmod 775 make-sums.sh /usr/bin/chmod 664 neato_deploy_php_cli.ini -/usr/bin/chmod 664 deploy_*.php +/usr/bin/chmod 664 deploy_files/deploy_*.php popd diff --git a/build/make-sums.sh b/build/make-sums.sh index bf42114..29dbe49 100644 --- a/build/make-sums.sh +++ b/build/make-sums.sh @@ -2,7 +2,7 @@ if [ ! -d sums ]; then mkdir sums fi -for file in deploy_*.php; do +for file in deploy_files/deploy_*.php; do if [ -f "$file" ]; then echo -e "Making sum file for: $file \r\n" diff --git a/build/view_phar_file_contents.php b/build/view_phar_file_contents.php new file mode 100644 index 0000000..ac51614 --- /dev/null +++ b/build/view_phar_file_contents.php @@ -0,0 +1,17 @@ +getPathname() . PHP_EOL; + } +} catch (PharException $e) { + echo "Error reading Phar archive: " . $e->getMessage(); +} diff --git a/config_files/deploy_example.php b/deploy_files/deploy_example.php similarity index 100% rename from config_files/deploy_example.php rename to deploy_files/deploy_example.php diff --git a/config_files/deploy_mysql_ex1.php b/deploy_files/deploy_mysql_ex1.php similarity index 100% rename from config_files/deploy_mysql_ex1.php rename to deploy_files/deploy_mysql_ex1.php diff --git a/config_files/deploy_mysql_ex2.php b/deploy_files/deploy_mysql_ex2.php similarity index 100% rename from config_files/deploy_mysql_ex2.php rename to deploy_files/deploy_mysql_ex2.php diff --git a/config_files/deploy_podman.php b/deploy_files/deploy_podman.php similarity index 100% rename from config_files/deploy_podman.php rename to deploy_files/deploy_podman.php diff --git a/config_files/deploy_security_audit.php b/deploy_files/deploy_security_audit.php similarity index 100% rename from config_files/deploy_security_audit.php rename to deploy_files/deploy_security_audit.php diff --git a/config_files/deploy_ssh_client.php b/deploy_files/deploy_ssh_client.php similarity index 100% rename from config_files/deploy_ssh_client.php rename to deploy_files/deploy_ssh_client.php diff --git a/config_files/deploy_sshd.php b/deploy_files/deploy_sshd.php similarity index 100% rename from config_files/deploy_sshd.php rename to deploy_files/deploy_sshd.php diff --git a/config_files/deploy_test1.php b/deploy_files/deploy_test1.php similarity index 100% rename from config_files/deploy_test1.php rename to deploy_files/deploy_test1.php diff --git a/make-installer.sh b/make-installer.sh index ac170c7..04c4f57 100755 --- a/make-installer.sh +++ b/make-installer.sh @@ -5,7 +5,7 @@ pushd build /usr/bin/chmod +x install_neato.sh TAR_FILE=neato_deploy.tar.gz -/usr/bin/tar -czvf $TAR_FILE install_neato.sh make-sums.sh neatoDeploy.phar neato_deploy_php_cli.ini neato_deploy.sh ../config_files/deploy_*.php +/usr/bin/tar -czvf $TAR_FILE install_neato.sh make-sums.sh neatoDeploy.phar neato_deploy_php_cli.ini neato_deploy.sh ../deploy_files/deploy_*.php EXIT_COMMAND="./install_neato.sh"