#!/bin/bash if [ "$EUID" -ne 0 ]; then /usr/bin/echo "Please run as root!" exit fi pushd build || exit 2 generate_password() { # Define character sets for the password uppercase="ABCDEFGHIJKLMNOPQRSTUVWXYZ" lowercase="abcdefghijklmnopqrstuvwxyz" numbers="0123456789" special_chars="!@#$%-^&*(_)+=?" # Combine character sets all_chars="${uppercase}${lowercase}${numbers}${special_chars}" # Use /dev/urandom to generate random bytes and base64 encode them password=$(head /dev/urandom | tr -dc "$all_chars" | head -c 16) echo "$password" > sumfiles.sig } if [ ! -f "sumfiles.sig" ]; then generate_password fi if ! which "openssl" >/dev/null 2>&1; then echo "openssl is not installed!" exit 3 fi if [ ! -f "private.pem" ]; then openssl genrsa -out private.pem 4096 openssl rsa -in private.pem -pubout -out neatoDeploy.phar.pubkey fi /usr/bin/php -c neato_php_cli_phar.ini -f compile-phar.php if [ $? -eq 0 ]; then echo "Cool -> Created PHAR file!" else echo "ERROR: Unable to make PHAR file!" exit 1 fi file_to_sign="neatoDeploy.phar" private_key_file="private.pem" signature_output_file="neatoDeploy.phar.sig" # Sign the file openssl dgst -sha256 -sign "$private_key_file" -out "$signature_output_file" "$file_to_sign" if [ $? -eq 0 ]; then echo "Made signature." else echo "Unable to make signature!!" fi /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 sumfiles.sig neatoDeploy.phar.sig neatoDeploy.phar.pubkey neatoDeploy.phar neato_deploy_php_cli.ini neato_deploy.sh ../deploy_files/deploy_*.php EXIT_COMMAND="./install_neato.sh" SELF_EXTRACTABLE="$TAR_FILE.self" /usr/bin/echo '#!/bin/bash' > $SELF_EXTRACTABLE /usr/bin/echo 'dd bs=1 skip=`head -3 $0 | wc -c` if=$0 | gunzip -c | tar -x' >> $SELF_EXTRACTABLE /usr/bin/echo "$EXIT_COMMAND; exit" >> $SELF_EXTRACTABLE /usr/bin/cat $TAR_FILE >> $SELF_EXTRACTABLE /usr/bin/chmod a+x $SELF_EXTRACTABLE /usr/bin/mv $SELF_EXTRACTABLE .. popd || exit 2