Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2.x.x Minor Fixes #172

Merged
merged 10 commits into from
Jul 8, 2024
2 changes: 1 addition & 1 deletion lib/lemper-adduser.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#CMD_NAME="adduser"

# Make sure only root can access and not direct access.
if ! declare -F "requires_root" &>/dev/null; then
if [[ "$(type -t requires_root)" != "function" ]]; then
echo "Direct access to this script is not permitted."
exit 1
fi
Expand Down
18 changes: 5 additions & 13 deletions scripts/bench.sh → lib/lemper-bench.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ echo ""
# Network speed test benchmark.
echo "### Network Speedtest Benchmark ###"

cachefly=$( wget -q -O /dev/null http://cachefly.cachefly.net/100mb.test 2>&1 | awk '/\/dev\/null/ {speed=$3 $4} END {gsub(/\(|\)/,"",speed); print speed}' )
cachefly=$( wget -q -O /dev/null https://cachefly.cachefly.net/100mb.test 2>&1 | awk '/\/dev\/null/ {speed=$3 $4} END {gsub(/\(|\)/,"",speed); print speed}' )
echo "Download speed from CacheFly: $cachefly "
leaseweb=$( wget -q -O /dev/null http://mirror.leaseweb.com/speedtest/100mb.bin 2>&1 | awk '/\/dev\/null/ {speed=$3 $4} END {gsub(/\(|\)/,"",speed); print speed}' )
echo "Download speed from Leaseweb, Haarlem, NL: $leaseweb "
ovh=$( wget -q -O /dev/null https://proof.ovh.net/files/100Mb.dat 2>&1 | awk '/\/dev\/null/ {speed=$3 $4} END {gsub(/\(|\)/,"",speed); print speed}' )
echo "Download speed from OVH: $ovh "

linodeatl=$( wget -q -O /dev/null http://speedtest.atlanta.linode.com/100MB-atlanta.bin 2>&1 | awk '/\/dev\/null/ {speed=$3 $4} END {gsub(/\(|\)/,"",speed); print speed}' )
echo "Download speed from Linode, Atlanta, GA: $linodeatl "
Expand All @@ -49,13 +49,5 @@ echo "Download speed from Linode, Tokyo, JP: $linodejp "
linodesgp=$( wget -q -O /dev/null http://speedtest.singapore.linode.com/100MB-singapore.bin 2>&1 | awk '/\/dev\/null/ {speed=$3 $4} END {gsub(/\(|\)/,"",speed); print speed}' )
echo "Download speed from Linode, Singapore, SGP: $linodesgp "

slsea=$( wget -q -O /dev/null http://speedtest.sea01.softlayer.com/downloads/test100.zip 2>&1 | awk '/\/dev\/null/ {speed=$3 $4} END {gsub(/\(|\)/,"",speed); print speed}' )
echo "Download speed from Softlayer, Seattle, WA: $slsea "
slsjc=$( wget -q -O /dev/null http://speedtest.sjc01.softlayer.com/downloads/test100.zip 2>&1 | awk '/\/dev\/null/ {speed=$3 $4} END {gsub(/\(|\)/,"",speed); print speed}' )
echo "Download speed from Softlayer, San Jose, CA: $slsjc "
sldal=$( wget -q -O /dev/null http://speedtest.dal05.softlayer.com/downloads/test100.zip 2>&1 | awk '/\/dev\/null/ {speed=$3 $4} END {gsub(/\(|\)/,"",speed); print speed}' )
echo "Download speed from Softlayer, Dallas, TX: $sldal "
slwdc=$( wget -q -O /dev/null http://speedtest.wdc01.softlayer.com/downloads/test100.zip 2>&1 | awk '/\/dev\/null/ {speed=$3 $4} END {gsub(/\(|\)/,"",speed); print speed}' )
echo "Download speed from Softlayer, Washington, DC: $slwdc "
slsng=$( wget -q -O /dev/null http://speedtest.sng01.softlayer.com/downloads/test100.zip 2>&1 | awk '/\/dev\/null/ {speed=$3 $4} END {gsub(/\(|\)/,"",speed); print speed}' )
echo "Download speed from Softlayer, Singapore: $slsng "
vodafone=$( wget -q -O /dev/null http://212.183.159.230/100MB.zip 2>&1 | awk '/\/dev\/null/ {speed=$3 $4} END {gsub(/\(|\)/,"",speed); print speed}' )
echo "Download speed from Vodafone: $vodafone "
25 changes: 15 additions & 10 deletions lib/lemper-create.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ CMD_PARENT="lemper-cli"
CMD_NAME="create"

# Make sure only root can access and not direct access.
if ! declare -F "requires_root" &>/dev/null; then
if [[ "$(type -t requires_root)" != "function" ]]; then
echo "Direct access to this script is not permitted."
exit 1
fi
Expand Down Expand Up @@ -120,6 +120,7 @@ function create_vhost_default() {
server {
listen 80;
listen [::]:80;
http2 off;

server_name ${SERVERNAME};

Expand Down Expand Up @@ -239,6 +240,7 @@ function create_vhost_drupal() {
server {
listen 80;
listen [::]:80;
http2 off;

server_name ${SERVERNAME};

Expand Down Expand Up @@ -352,6 +354,7 @@ function create_vhost_laravel() {
server {
listen 80;
listen [::]:80;
http2 off;

server_name ${SERVERNAME};

Expand Down Expand Up @@ -466,6 +469,7 @@ function create_vhost_phalcon() {
server {
listen 80;
listen [::]:80;
http2 off;

server_name ${SERVERNAME};

Expand Down Expand Up @@ -1061,15 +1065,16 @@ function init_lemper_create() {
create_fpm_pool_conf "${USERNAME}" "${PHP_VERSION}" > "/etc/php/${PHP_VERSION}/fpm/pool.d/${USERNAME}.conf"

# Create default directories & log files.
run mkdir -p "/home/${USERNAME}/.lemper/tmp"
run mkdir -p "/home/${USERNAME}/.lemper/php/opcache"
run mkdir -p "/home/${USERNAME}/.lemper/php/sessions"
run mkdir -p "/home/${USERNAME}/.lemper/php/wsdlcache"
run mkdir -p "/home/${USERNAME}/cgi-bin"
run mkdir -p "/home/${USERNAME}/logs/php"
run touch "/home/${USERNAME}/logs/php/php${PHP_VERSION}-fpm_slow.log"
run touch "/home/${USERNAME}/logs/php/php${PHP_VERSION}-fpm_error.log"
run touch "/home/${USERNAME}/logs/php/php${PHP_VERSION}-opcache_error.log"
run mkdir -p "/home/${USERNAME}/.lemper/tmp" && \
run mkdir -p "/home/${USERNAME}/.lemper/php/opcache" && \
run mkdir -p "/home/${USERNAME}/.lemper/php/sessions" && \
run mkdir -p "/home/${USERNAME}/.lemper/php/wsdlcache" && \
run mkdir -p "/home/${USERNAME}/cgi-bin" && \
run mkdir -p "/home/${USERNAME}/logs/php" && \
run touch "/home/${USERNAME}/logs/php/php${PHP_VERSION}-fpm_slow.log" && \
run touch "/home/${USERNAME}/logs/php/php${PHP_VERSION}-fpm_error.log" && \
run touch "/home/${USERNAME}/logs/php/php${PHP_VERSION}-opcache_error.log" && \
run chmod 755 "/home/${USERNAME}" && \
run chown -hR "${USERNAME}:${USERNAME}" "/home/${USERNAME}/.lemper" "/home/${USERNAME}/cgi-bin" "/home/${USERNAME}/logs"

# Restart PHP FPM.
Expand Down
26 changes: 26 additions & 0 deletions lib/lemper-fixpermission.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/usr/bin/env bash

# Fix file permission
# Min. Requirement : GNU/Linux Ubuntu 18.04
# Last Build : 07/07/2024
# Author : MasEDI.Net ([email protected])
# Since Version : 1.0.0

# Make sure only root can access and not direct access.
if [[ "$(type -t requires_root)" != "function" ]]; then
echo "Direct access to this script is not permitted."
exit 1
fi

# Usage: fixpermission path
function fixpermission() {
# Path file / directory
[ "${1}" = "" ] && return 0

find "${1}" -type d -print0 | xargs -0 chmod 755
find "${1}" -type f -print0 | xargs -0 chmod 644
}

# Start running things from a call at the end so if this script is executed
# after a partial download it doesn't do anything.
fixpermission "$@"
15 changes: 8 additions & 7 deletions lib/lemper-manage.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ CMD_PARENT="lemper-cli"
CMD_NAME="manage"

# Make sure only root can access and not direct access.
if ! declare -F "requires_root" &>/dev/null; then
if [[ "$(type -t requires_root)" != "function" ]]; then
echo "Direct access to this script is not permitted."
exit 1
fi
Expand Down Expand Up @@ -485,21 +485,22 @@ function enable_ssl() {
# Update vhost config.
if [[ "${DRYRUN}" != true ]]; then
# Ensure there is no HTTPS enabled server block.
if ! grep -qwE "^\ listen\ (\b[0-9]{1,3}\.){3}[0-9]{1,3}\b:443\ ssl\ http2" "/etc/nginx/sites-available/${DOMAIN}.conf"; then
if ! grep -qwE "^\ listen\ (\b[0-9]{1,3}\.){3}[0-9]{1,3}\b:443\ ssl" "/etc/nginx/sites-available/${DOMAIN}.conf"; then

# Make backup first.
run cp -f "/etc/nginx/sites-available/${DOMAIN}.conf" "/etc/nginx/sites-available/${DOMAIN}.nonssl-conf"

# Change listening port to 443.
if grep -qwE "^\ listen\ (\b[0-9]{1,3}\.){3}[0-9]{1,3}\b:80" "/etc/nginx/sites-available/${DOMAIN}.conf"; then
run sed -i "s/\:80/\:443\ ssl\ http2/g" "/etc/nginx/sites-available/${DOMAIN}.conf"
run sed -i "s/\:80/\:443\ ssl/g" "/etc/nginx/sites-available/${DOMAIN}.conf"
else
run sed -i "s/listen\ 80/listen\ 443\ ssl\ http2/g" "/etc/nginx/sites-available/${DOMAIN}.conf"
fi

run sed -i "s/listen\ \[::\]:80/listen\ \[::\]:443\ ssl\ http2/g" "/etc/nginx/sites-available/${DOMAIN}.conf"

# Enable SSL configs.
run sed -i "s/http2\ off/http2\ on/g" "/etc/nginx/sites-available/${DOMAIN}.conf"
run sed -i "s/#ssl_certificate/ssl_certificate/g" "/etc/nginx/sites-available/${DOMAIN}.conf"
run sed -i "s/#ssl_certificate_key/ssl_certificate_key/g" "/etc/nginx/sites-available/${DOMAIN}.conf"
run sed -i "s/#ssl_trusted_certificate/ssl_trusted_certificate/g" "/etc/nginx/sites-available/${DOMAIN}.conf"
Expand Down Expand Up @@ -989,22 +990,22 @@ function init_lemper_manage() {
;;
-s | --enable-ssl)
enable_ssl "${2}"
exit
exit 0
shift 2
;;
--disable-ssl)
disable_ssl "${2}"
exit
exit 0
shift 2
;;
--remove-ssl)
remove_ssl "${2}"
exit
exit 0
shift 2
;;
--renew-ssl)
renew_ssl "${2}"
exit
exit 0
shift 2
;;
-b | --enable-brotli)
Expand Down
2 changes: 1 addition & 1 deletion lib/lemper-sslgen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#CMD_NAME="sslgen"

# Make sure only root can access and not direct access.
if ! declare -F "requires_root" &>/dev/null; then
if [[ "$(type -t requires_root)" != "function" ]]; then
echo "Direct access to this script is not permitted."
exit 1
fi
Expand Down
29 changes: 0 additions & 29 deletions scripts/createssl.sh

This file was deleted.

13 changes: 0 additions & 13 deletions scripts/fixpermission.sh

This file was deleted.

6 changes: 3 additions & 3 deletions scripts/install_mariadb.sh
Original file line number Diff line number Diff line change
Expand Up @@ -133,13 +133,13 @@ function init_mariadb_install() {
run cp etc/systemd/mariadb.service /lib/systemd/system/

[[ ! -f /etc/systemd/system/multi-user.target.wants/mariadb.service && -f /lib/systemd/system/mariadb.service ]] && \
run ln -s /lib/systemd/system/mariadb.service /etc/systemd/system/multi-user.target.wants/mariadb.service
run ln -sf /lib/systemd/system/mariadb.service /etc/systemd/system/multi-user.target.wants/mariadb.service

[[ ! -f /etc/systemd/system/mysqld.service && -f /lib/systemd/system/mariadb.service ]] && \
run ln -s /lib/systemd/system/mariadb.service /etc/systemd/system/mysqld.service
run ln -sf /lib/systemd/system/mariadb.service /etc/systemd/system/mysqld.service

[[ ! -f /etc/systemd/system/mysql.service && -f /lib/systemd/system/mariadb.service ]] && \
run ln -s /lib/systemd/system/mariadb.service /etc/systemd/system/mysql.service
run ln -sf /lib/systemd/system/mariadb.service /etc/systemd/system/mysql.service

# Install default table.
if [[ -n $(command -v mysql_install_db) ]]; then
Expand Down
4 changes: 2 additions & 2 deletions scripts/install_php.sh
Original file line number Diff line number Diff line change
Expand Up @@ -821,7 +821,7 @@ function install_sourceguardian_loader() {

if curl -sLI "${SG_ZIP_URL}" | grep -q "HTTP/[.12]* [2].."; then
run wget "${SG_ZIP_URL}" && \
run tar -xzf "${SG_ZIP_FILENAME}" && \
run tar -xf "${SG_ZIP_FILENAME}" && \
run mv -f "${BUILD_DIR}/sourceguardian" /usr/lib/php/loaders/
else
error "Cannot download SourceGuardian PHP loader: 'sourceguardian_loaders.linux-${SG_ARCH}.tar.gz'."
Expand Down Expand Up @@ -1050,7 +1050,7 @@ function init_php_install() {
;;
9 | "all")
# Select all PHP versions (except EOL & Beta).
SELECTED_PHP_VERSIONS=("5.6" "7.0" "7.1" "7.2" "7.3" "7.4" "8.0" "8.1" "8.2")
SELECTED_PHP_VERSIONS=("7.1" "7.2" "7.3" "7.4" "8.0" "8.1" "8.2" "8.3")
;;
*)
error "Your selected PHP version ${SELECTED_PHP} is not supported yet."
Expand Down
17 changes: 13 additions & 4 deletions scripts/install_tools.sh
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,15 @@ function init_tools_install() {
run cp -f lib/lemper-db.sh /etc/lemper/cli-plugins/lemper-db && \
run chmod ugo+x /etc/lemper/cli-plugins/lemper-db

run cp -f lib/lemper-sslgen.sh /etc/lemper/cli-plugins/lemper-selfssl && \
run chmod ugo+x /etc/lemper/cli-plugins/lemper-selfssl

run cp -f lib/lemper-fixpermission.sh /etc/lemper/cli-plugins/lemper-fixpermission && \
run chmod ugo+x /etc/lemper/cli-plugins/lemper-fixpermission

run cp -f lib/lemper-bench.sh /etc/lemper/cli-plugins/lemper-bench && \
run chmod ugo+x /etc/lemper/cli-plugins/lemper-bench

# Remove old LEMPer CLI tool.
[ -d /usr/local/lib/lemper ] && run rm -fr /usr/local/lib/lemper/lemper-*

Expand All @@ -72,7 +81,6 @@ function init_tools_install() {

# Install PHP Info
run bash -c 'echo "<?php phpinfo(); ?>" > /usr/share/nginx/html/lcp/phpinfo.php'
run bash -c 'echo "<?php phpinfo(); ?>" > /usr/share/nginx/html/lcp/phpinfo.php56'
run bash -c 'echo "<?php phpinfo(); ?>" > /usr/share/nginx/html/lcp/phpinfo.php70'
run bash -c 'echo "<?php phpinfo(); ?>" > /usr/share/nginx/html/lcp/phpinfo.php71'
run bash -c 'echo "<?php phpinfo(); ?>" > /usr/share/nginx/html/lcp/phpinfo.php72'
Expand All @@ -81,6 +89,7 @@ function init_tools_install() {
run bash -c 'echo "<?php phpinfo(); ?>" > /usr/share/nginx/html/lcp/phpinfo.php80'
run bash -c 'echo "<?php phpinfo(); ?>" > /usr/share/nginx/html/lcp/phpinfo.php81'
run bash -c 'echo "<?php phpinfo(); ?>" > /usr/share/nginx/html/lcp/phpinfo.php82'
run bash -c 'echo "<?php phpinfo(); ?>" > /usr/share/nginx/html/lcp/phpinfo.php83'

# Install Adminer for Web-based MySQL Administration Tool.
[ ! -d /usr/share/nginx/html/lcp/dbadmin ] && run mkdir -p /usr/share/nginx/html/lcp/dbadmin
Expand Down Expand Up @@ -225,9 +234,9 @@ EOL
# Assign ownership properly.
run chown -hR www-data:www-data /usr/share/nginx/html

#if [[ -x /usr/local/bin/lemper-cli && -d /usr/share/nginx/html/lcp ]]; then
# success "LEMPer CLI & web tools successfully installed."
#fi
if [[ -x /usr/local/bin/lemper-cli && -d /usr/share/nginx/html/lcp ]]; then
success "LEMPer CLI & web tools successfully installed."
fi
}

echo "[LEMPer CLI & Web Tools Installation]"
Expand Down
1 change: 1 addition & 0 deletions scripts/utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -693,6 +693,7 @@ function create_account() {
run chmod 700 "/home/${LEMPER_USERNAME}/.ssh" && \
run touch "/home/${LEMPER_USERNAME}/.ssh/authorized_keys" && \
run chmod 600 "/home/${LEMPER_USERNAME}/.ssh/authorized_keys" && \
run chmod 755 "/home/${LEMPER_USERNAME}" && \
run chown -hR "${LEMPER_USERNAME}:${LEMPER_USERNAME}" "/home/${LEMPER_USERNAME}"

# Add account credentials to /srv/.htpasswd.
Expand Down
Loading