diff --git a/README.md b/README.md index 6751fa6..2bdace0 100644 --- a/README.md +++ b/README.md @@ -3,14 +3,19 @@ ``` $ git clone https://git.mysnippetsofcode.com/tts/neatoDeploy.git $ cd neatoDeploy -$ nano app/neato.php -# Change the line that reads $pk = "Passphase"; // XOR for sha256sum, CHANGE ME!! -# Save it, then run: -$ ./make-installer.sh +$ sudo ./make-installer.sh ``` +## Copy to Server Then scp over the neato_deploy.tar.gz.self to your sever. - -on the server: $ sudo ./neato_deploy.tar.gz.self +``` +$ scp neato_deploy.tar.gz.self myservernameHERE:/home/MyUSERNAME_HERE/ +``` +## Run Installer on Server +on the server: +``` +$ cd /home/MyUSERNAME_HERE +$ sudo ./neato_deploy.tar.gz.self +``` ## Clean up ``` $ rm neato_deploy.tar.gz.self @@ -18,21 +23,15 @@ $ rm install_neato.sh ``` ## Make sha256sum (& xor static pwd) on TRUSTED scripts ``` -$ sudo -i -$ cd /opt/neatoDemployments -$ ./make-sums.sh -# if done as ROOT type $ exit -# to exit! +$ sudo /opt/neatoDeployments/make-sums.sh ``` ## Do Deployments... ``` -$ cd /opt/neatoDemployments - # Pull and RUN deployment script from your web site -$ ./neato_deploy.sh http://EXAMPLE_Site.com/MY_Deployment.txt +$ Neato http://EXAMPLE_Site.com/MY_Deployment.txt # OR Run a local file deployment -$ sudo ./neato_deploy.sh security_audit +$ sudo Neato security_audit ``` Note that deployment files are named with the prefix of deploy_ diff --git a/app/neato.php b/app/neato.php index 7b8238f..31c521c 100644 --- a/app/neato.php +++ b/app/neato.php @@ -5,6 +5,9 @@ ini_set('display_errors', 1); error_reporting(E_ALL); $cwd = getcwd(); +if (! str_contains($cwd, "neato")) { + $cwd = "/opt/neatoDeployments"; +} $pk = file_get_contents($cwd . "/sumfiles.sig"); if ($pk === false) { diff --git a/build/install_neato.sh b/build/install_neato.sh index 03b138a..e668e4d 100755 --- a/build/install_neato.sh +++ b/build/install_neato.sh @@ -1,6 +1,13 @@ #!/bin/bash - MY_GROUP=www-data +PHPCLI='php8.3-cli' +PHPMBString='php8.3-mbstring' + +if [ "$EUID" -ne 0 ]; then + /usr/bin/echo "Please run as root!" + exit +fi + # Function to check if a group exists group_exists() { if getent group "$1" >/dev/null 2>&1; then @@ -14,19 +21,11 @@ if ! group_exists "$MY_GROUP"; then groupadd "$MY_GROUP" fi -PHPCLI='php8.3-cli' -PHPMBString='php8.3-mbstring' - -if [ "$EUID" -ne 0 ]; then - /usr/bin/echo "Please run as root!" - exit -fi - current_directory=$(pwd) -target_directory="/opt/neatoDeploy" +avoid_target_directory="neatoDeploy" -if [ "$current_directory" == "$target_directory" ] || [ "$current_directory" == "$target_directory/build" ]; then - /usr/bin/echo "Do not run this script inside of source folder /opt/neatoDeploy/build!" +if [[ $current_directory == *$avoid_target_directory ]] || [[ $current_directory == *$avoid_target_directory/build ]]; then + /usr/bin/echo "Do not run this script inside of source folder ... neatoDeploy* !" exit 1 fi @@ -41,7 +40,7 @@ fi /usr/bin/mv deploy_files/deploy_*.php /opt/neatoDeployments/deploy_files/ /usr/bin/rmdir deploy_files -pushd /opt/neatoDeployments +pushd /opt/neatoDeployments || exit 1 /usr/bin/dpkg -s software-properties-common 2>/dev/null >/dev/null || /usr/bin/apt-get install -y software-properties-common /usr/bin/dpkg -s $PHPCLI 2>/dev/null >/dev/null || /usr/bin/add-apt-repository ppa:ondrej/php -y @@ -60,7 +59,11 @@ pushd /opt/neatoDeployments /usr/bin/chmod 664 neato_deploy_php_cli.ini /usr/bin/chmod 664 deploy_files/deploy_*.php -popd +popd || exit 1 + +if [ ! -L /usr/local/bin/Neato ]; then + ln -s /opt/neatoDeployments/neato_deploy.sh /usr/local/bin/Neato +fi /usr/bin/echo -e "\nRemove the install_neato.sh file!" /usr/bin/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 index 5161328..2d30bfd 100644 --- a/build/make-sums.sh +++ b/build/make-sums.sh @@ -1,4 +1,5 @@ #!/bin/bash +pushd /opt/neatoDeployments || exit 1 if [ ! -d sums ]; then mkdir sums fi @@ -6,7 +7,7 @@ fi if which "openssl" >/dev/null 2>&1; then file_to_verify="/opt/neatoDeployments/neatoDeploy.phar" signature_file="/opt/neatoDeployments/neatoDeploy.phar.sig" - public_key_file="neatoDeploy.phar.pubkey" + public_key_file="/opt/neatoDeployments/neatoDeploy.phar.pubkey" # Verify the signature openssl dgst -sha256 -verify "$public_key_file" -signature "$signature_file" "$file_to_verify" @@ -22,7 +23,6 @@ else echo "openssl is not installed!!" fi - for file in deploy_files/deploy_*.php; do if [ -f "$file" ]; then echo -e "Making sum file for: $file \r\n" @@ -33,4 +33,4 @@ for file in deploy_files/deploy_*.php; do php -c /opt/neatoDeployments/neato_deploy_php_cli.ini -f /opt/neatoDeployments/neatoDeploy.phar "$new_file_name" -marksafe -skipdeploy fi done - +popd || exit 1 diff --git a/build/neato_deploy.sh b/build/neato_deploy.sh index 8defe9e..e9371a3 100755 --- a/build/neato_deploy.sh +++ b/build/neato_deploy.sh @@ -3,7 +3,7 @@ if which "openssl" >/dev/null 2>&1; then file_to_verify="/opt/neatoDeployments/neatoDeploy.phar" signature_file="/opt/neatoDeployments/neatoDeploy.phar.sig" - public_key_file="neatoDeploy.phar.pubkey" + public_key_file="/opt/neatoDeployments/neatoDeploy.phar.pubkey" # Verify the signature openssl dgst -sha256 -verify "$public_key_file" -signature "$signature_file" "$file_to_verify"