Skip to content

Commit 7863943

Browse files
authored
Code Cleanup
1 parent cf32471 commit 7863943

5 files changed

Lines changed: 34 additions & 26 deletions

File tree

scripts/functions/cron/uploads-php-scan.sh

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ source /home/EngineScript/enginescript-install-options.txt
3232
# Store sites with errors
3333
ERRORS=""
3434

35-
for i in ${SITES[@]}
35+
for i in "${SITES[@]}"
3636
do
3737
cd "/var/www/sites/$i/html"
3838
# Verify checksums
@@ -49,6 +49,13 @@ do
4949
cd "/var/www/sites/$i/html"
5050
done
5151

52+
# Trim leading space if ERRORS is not empty
53+
ERRORS=$(echo "$ERRORS" | sed 's/^ *//')
54+
5255
if [ -n "$ERRORS" ]; then
53-
curl -u $PUSHBULLET_TOKEN: https://api.pushbullet.com/v2/pushes -d type=note -d title="Server: $IP_ADDRESS" -d body="Found PHP in the uploads directory for the following sites: $ERRORS"
56+
# Use multiple -d options for clarity and proper quoting
57+
curl -u "$PUSHBULLET_TOKEN": https://api.pushbullet.com/v2/pushes \
58+
-d type=note \
59+
-d "title=Server: $IP_ADDRESS" \
60+
-d "body=Found PHP in the uploads directory for the following sites: $ERRORS"
5461
fi

scripts/functions/logs/domain-logs.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ cd /var/www/sites
2626
printf "Please select the site you want to scan for vulnerabilities:\n"
2727
select d in *; do test -n "$d" && break; echo ">>> Invalid Selection"; done
2828
echo "${BOLD}Showing last 20 lines of Nginx error log for ${d}.${NORMAL}" | boxes -a c -d shell -p a1l2
29-
tail -n20 /var/log/domains/${d}/${d}-nginx-error.log
29+
tail -n20 "/var/log/domains/${d}/${d}-nginx-error.log"
3030
echo "${BOLD}Showing last 20 lines of WordPress error log for ${d}.${NORMAL}" | boxes -a c -d shell -p a1l2
31-
tail -n20 /var/log/domains/${d}/${d}-wp-error.log
31+
tail -n20 "/var/log/domains/${d}/${d}-wp-error.log"
3232

3333
# Ask user to acknowledge that the scan has completed before moving on
3434
echo ""

scripts/install/liburing/liburing-install.sh

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,13 @@ fi
2525
# Return to /usr/src
2626
cd /usr/src
2727

28-
# Official zlib Download
29-
wget -O /usr/src/liburing-${LIBURING_VER}.tar.gz https://github.com/axboe/liburing/archive/refs/tags/liburing-${LIBURING_VER}.tar.gz --no-check-certificate
30-
tar -xzvf /usr/src/liburing-${LIBURING_VER}.tar.gz
31-
cd /usr/src/liburing-liburing-${LIBURING_VER}
28+
# Official liburing Download
29+
wget -O "/usr/src/liburing-${LIBURING_VER}.tar.gz" "https://github.com/axboe/liburing/archive/refs/tags/liburing-${LIBURING_VER}.tar.gz" --no-check-certificate
30+
tar -xzvf "/usr/src/liburing-${LIBURING_VER}.tar.gz"
31+
cd "/usr/src/liburing-liburing-${LIBURING_VER}"
3232

3333
# Compile liburing
34-
make -j${CPU_COUNT}
34+
make -j"${CPU_COUNT}"
3535

3636
# Install liburing
3737
make install
@@ -40,7 +40,7 @@ make install
4040
#rm -rf /usr/src/liburing
4141
#git clone --depth 1 https://github.com/axboe/liburing -b master /usr/src/liburing
4242
#cd /usr/src/liburing
43-
#make -j${CPU_COUNT}
43+
#make -j"${CPU_COUNT}"
4444
#make test
4545
#make install
4646

scripts/install/ufw/ufw-cloudflare.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ echo "Adding UFW rules for Cloudflare IPs (TCP & UDP)..."
2929
# Allow all TCP and UDP traffic from Cloudflare IPs (no ports restriction)
3030
# Using brace expansion for conciseness
3131
for cfip in $(curl -s https://www.cloudflare.com/ips-v{4,6}); do
32-
ufw allow proto tcp from $cfip comment 'Cloudflare IP (TCP)' > /dev/null
33-
ufw allow proto udp from $cfip comment 'Cloudflare IP (UDP)' > /dev/null
32+
ufw allow proto tcp from "$cfip" comment 'Cloudflare IP (TCP)' > /dev/null
33+
ufw allow proto udp from "$cfip" comment 'Cloudflare IP (UDP)' > /dev/null
3434
done
3535

3636
echo "Reloading UFW rules..."

scripts/update/php-config-update.sh

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -77,27 +77,28 @@ calculate_php() {
7777
fi
7878

7979
# Apply calculated values to PHP-FPM configuration
80-
sed -i "s|pm.start_servers = .*|pm.start_servers = ${PHP_FPM_START_SERVERS}|g" /etc/php/${PHP_VER}/fpm/pool.d/www.conf
81-
sed -i "s|pm.min_spare_servers = .*|pm.min_spare_servers = ${PHP_FPM_MIN_SPARE_SERVERS}|g" /etc/php/${PHP_VER}/fpm/pool.d/www.conf
82-
sed -i "s|pm.max_spare_servers = .*|pm.max_spare_servers = ${PHP_FPM_MAX_SPARE_SERVERS}|g" /etc/php/${PHP_VER}/fpm/pool.d/www.conf
83-
sed -i "s|pm.max_children = .*|pm.max_children = ${PHP_FPM_MAX_CHILDREN}|g" /etc/php/${PHP_VER}/fpm/pool.d/www.conf
80+
sed -i "s|pm.start_servers = .*|pm.start_servers = \"${PHP_FPM_START_SERVERS}\"|g" "/etc/php/${PHP_VER}/fpm/pool.d/www.conf"
81+
sed -i "s|pm.min_spare_servers = .*|pm.min_spare_servers = \"${PHP_FPM_MIN_SPARE_SERVERS}\"|g" "/etc/php/${PHP_VER}/fpm/pool.d/www.conf"
82+
sed -i "s|pm.max_spare_servers = .*|pm.max_spare_servers = \"${PHP_FPM_MAX_SPARE_SERVERS}\"|g" "/etc/php/${PHP_VER}/fpm/pool.d/www.conf"
83+
sed -i "s|pm.max_children = .*|pm.max_children = \"${PHP_FPM_MAX_CHILDREN}\"|g" "/etc/php/${PHP_VER}/fpm/pool.d/www.conf"
8484

8585
# Apply memory and OpCache settings to php.ini
86-
sed -i "s|SEDPHPMEMLIMIT|${PHP_MEMORY_LIMIT}|g" /etc/php/${PHP_VER}/fpm/php.ini
87-
sed -i "s|SEDOPCACHEJITBUFFER|${OPCACHE_JIT_BUFFER}|g" /etc/php/${PHP_VER}/fpm/php.ini
88-
sed -i "s|SEDOPCACHEINTBUF|${OPCACHE_INT_BUFFER}|g" /etc/php/${PHP_VER}/fpm/php.ini
89-
sed -i "s|SEDOPCACHEMEM|$((AVAILABLE_MEMORY / 8))M|g" /etc/php/${PHP_VER}/fpm/php.ini
86+
sed -i "s|SEDPHPMEMLIMIT|\"${PHP_MEMORY_LIMIT}\"|g" "/etc/php/${PHP_VER}/fpm/php.ini"
87+
sed -i "s|SEDOPCACHEJITBUFFER|\"${OPCACHE_JIT_BUFFER}\"|g" "/etc/php/${PHP_VER}/fpm/php.ini"
88+
sed -i "s|SEDOPCACHEINTBUF|\"${OPCACHE_INT_BUFFER}\"|g" "/etc/php/${PHP_VER}/fpm/php.ini"
89+
# Arithmetic expansion result is unlikely to need quoting, but added for consistency
90+
sed -i "s|SEDOPCACHEMEM|\"$((AVAILABLE_MEMORY / 8))M\"|g" "/etc/php/${PHP_VER}/fpm/php.ini"
9091
}
9192

9293
# Update PHP config
93-
cp -rf /usr/local/bin/enginescript/config/etc/php/php.ini /etc/php/${PHP_VER}/fpm/php.ini
94-
sed -i "s|SEDPHPVER|${PHP_VER}|g" /etc/php/${PHP_VER}/fpm/php.ini
94+
cp -rf /usr/local/bin/enginescript/config/etc/php/php.ini "/etc/php/${PHP_VER}/fpm/php.ini"
95+
sed -i "s|SEDPHPVER|\"${PHP_VER}\"|g" "/etc/php/${PHP_VER}/fpm/php.ini"
9596

96-
cp -rf /usr/local/bin/enginescript/config/etc/php/php-fpm.conf /etc/php/${PHP_VER}/fpm/php-fpm.conf
97-
sed -i "s|SEDPHPVER|${PHP_VER}|g" /etc/php/${PHP_VER}/fpm/php-fpm.conf
97+
cp -rf /usr/local/bin/enginescript/config/etc/php/php-fpm.conf "/etc/php/${PHP_VER}/fpm/php-fpm.conf"
98+
sed -i "s|SEDPHPVER|\"${PHP_VER}\"|g" "/etc/php/${PHP_VER}/fpm/php-fpm.conf"
9899

99-
cp -rf /usr/local/bin/enginescript/config/etc/php/www.conf /etc/php/${PHP_VER}/fpm/pool.d/www.conf
100-
sed -i "s|SEDPHPVER|${PHP_VER}|g" /etc/php/${PHP_VER}/fpm/pool.d/www.conf
100+
cp -rf /usr/local/bin/enginescript/config/etc/php/www.conf "/etc/php/${PHP_VER}/fpm/pool.d/www.conf"
101+
sed -i "s|SEDPHPVER|\"${PHP_VER}\"|g" "/etc/php/${PHP_VER}/fpm/pool.d/www.conf"
101102

102103
# Tune PHP Configuration
103104
calculate_php

0 commit comments

Comments
 (0)