compatibilty and cosmetics

#1
Most of below is just cosmetics. But not all:

- In install.sh `source ./functions.sh bla` is a Bash thing. FreeBSD doesn't come with Bash, and if installed it comes with many dependencies. I think less software = less maintainance. The proper POSIX way should be `. ./functions.sh bla`.
Because that creates an error I posted this all in bugs.

- At many places the download detection is inconsistent (and so on FreeBSD you still need to have AND curl AND wget AND fetch).
Inspired by above problem/solution I created a seperate detect-download.sh. Also that uses the full path of a download command, using the result of $DL
Still I wonder if this simply couldn't be in functions.sh's init()

Code:
--- detect-download.sh.orig     2019-01-04 23:49:41 UTC
+++ detect-download.sh
@@ -0,0 +1,14 @@
+#!/bin/sh
+
+DLCMD=    
+
+DL=`which wget`;  if [ $? -eq 0 ]; then DLCMD="$DL -nv -O "; fi
+DL=`which curl`;  if [ $? -eq 0 ]; then DLCMD="$DL -L -o  "; fi
+DL=`which fetch`; if [ $? -eq 0 ]; then DLCMD="$DL -o     "; fi
+
+if [ "x$DLCMD" = "x" ] ; then
+    echo "ERROR: cannot find common download method curl/wget/fetch."
+else
+    echo "DLCMD is $DLCMD"
+fi
+echo
Code:
--- dist/functions.sh.orig      2019-01-04 23:05:47 UTC
+++ dist/functions.sh
@@ -1,7 +1,5 @@
-
 #!/bin/sh
 
-
 init()
 {
        LSINSTALL_DIR=`pwd`
Code:
--- dist/install.sh.orig        2018-12-31 15:14:02 UTC
+++ dist/install.sh
@@ -6,36 +6,9 @@ OSVER=
 OSTYPE=`getconf LONG_BIT`
 MARIADBCPUARCH=
 
-
 inst_admin_php()
 {
-    # detect download method
-    OS=`uname -s`
-
-    DLCMD=
-    DL=`which wget`
-    if [ $? -eq 0 ] ; then
-        DLCMD="wget -nv -O "
-    else
-        DL=`which curl`
-        if [ $? -eq 0 ] ; then
-            DLCMD="curl -L -o "
-        else
-            if [ "x$OS" = "xFreeBSD" ] ; then
-                DL=`which fetch`
-                if [ $? -eq 0 ] ; then
-                    DLCMD="fetch -o "
-                fi
-            fi
-        fi
-    fi
-
-    if [ "x$DLCMD" = "x" ] ; then
-        echo "ERROR: cannot find proper download method curl/wget/fetch."
-    fi
-
-    echo "DLCMD is $DLCMD"
-    echo
+    . ../detect-download.sh
 
     HASADMINPHP=n
     if [ -f "$LSWS_HOME/admin/fcgi-bin/admin_php" ] ; then
@@ -84,7 +57,7 @@ inst_admin_php()
         chmod "$EXEC_MOD" "$LSWS_HOME/admin/fcgi-bin/admin_php"
     fi
 
-    #final checking of existence of admin_php
+    # final checking of existence of admin_php
     if [ ! -f "$LSWS_HOME/admin/fcgi-bin/admin_php" ] ; then
         echo -e "\033[38;5;148mFinal checking found admin_php not exists, installation abort.\033[39m"
         exit 1
@@ -102,8 +75,7 @@ install_lsphp7_centos()
     yum -y $action lsphp$LSPHPVER lsphp$LSPHPVER-common lsphp$LSPHPVER-gd lsphp$LSPHPVER-process lsphp$LSPHPVER-mbstring lsphp$LSPHPVER-mysql$ND lsphp$LSPHPVER-xml lsphp$LSPHPVER-mcrypt lsphp$LSPHPVER-pdo lsphp$LSPHPVER-imap
     
     if [ ! -f "$LSWS_HOME/lsphp$LSPHPVER/bin/lsphp" ] ; then
-        action=reinstall
-        
+        action=reinstall        
         yum -y remove lsphp$LSPHPVER-mysql$ND
         yum -y install lsphp$LSPHPVER-mysql$ND
         yum -y $action lsphp$LSPHPVER lsphp$LSPHPVER-common lsphp$LSPHPVER-gd lsphp$LSPHPVER-process lsphp$LSPHPVER-mbstring lsphp$LSPHPVER-xml lsphp$LSPHPVER-mcrypt lsphp$LSPHPVER-pdo lsphp$LSPHPVER-imap
@@ -122,17 +94,13 @@ install_lsphp7_debian()
     if [ $? != 0 ] ; then
         echo "deb http://rpms.litespeedtech.com/debian/ $OSVER main"  > /etc/apt/sources.list.d/lst_debian_repo.list
     fi
-    
     wget -O /etc/apt/trusted.gpg.d/lst_debian_repo.gpg http://rpms.litespeedtech.com/debian/lst_debian_repo.gpg
     wget -O /etc/apt/trusted.gpg.d/lst_repo.gpg http://rpms.litespeedtech.com/debian/lst_repo.gpg
     apt-get -y update
-    
-    apt-get -y install lsphp$LSPHPVER lsphp$LSPHPVER-mysql lsphp$LSPHPVER-imap lsphp$LSPHPVER-common 
-    
+    apt-get -y install lsphp$LSPHPVER lsphp$LSPHPVER-mysql lsphp$LSPHPVER-imap lsphp$LSPHPVER-common
     if [ ! -f "$LSWS_HOME/lsphp$LSPHPVER/bin/lsphp" ] ; then
-        apt-get -y --reinstall install lsphp$LSPHPVER lsphp$LSPHPVER-mysql lsphp$LSPHPVER-imap lsphp$LSPHPVER-common 
+        apt-get -y --reinstall install lsphp$LSPHPVER lsphp$LSPHPVER-mysql lsphp$LSPHPVER-imap lsphp$LSPHPVER-common
     fi
-    
     if [ -f "$LSWS_HOME/lsphp$LSPHPVER/bin/lsphp" ] ; then
         ln -sf "$LSWS_HOME/lsphp$LSPHPVER/bin/lsphp" "$LSWS_HOME/fcgi-bin/lsphp7"
     fi
@@ -248,9 +216,9 @@ inst_lsphp7()
 }
 
 
-#script start here
+# script start here
 cd `dirname "$0"`
-source ./functions.sh 2>/dev/null
+. ./functions.sh 2>/dev/null
 if [ $? != 0 ]; then
     . ./functions.sh
     if [ $? != 0 ]; then
@@ -259,7 +227,7 @@ if [ $? != 0 ]; then
     fi
 fi
 
-#If install.sh in admin/misc, need to change directory
+# If install.sh in admin/misc, need to change directory
 LSINSTALL_DIR=`dirname "$0"`
 #cd $LSINSTALL_DIR/
 
@@ -373,7 +341,7 @@ fi
 
 if [ -f "$LSWS_HOME/conf/httpd_config.conf" ] ; then
     INSTALL_TYPE="upgrade"
-    #Now check if the user and group match with the conf file
+    # Now check if the user and group match with the conf file
     OLD_USER_CONF=`grep "user" "$LSWS_HOME/conf/httpd_config.conf"`
     OLD_GROUP_CONF=`grep "group" "$LSWS_HOME/conf/httpd_config.conf"`
     OLD_USER=`expr "$OLD_USER_CONF" : '\s*user\s*\(\S*\)'`
@@ -401,7 +369,7 @@ if [ "x$IS_LSCPD" != "xyes" ] ; then 
 fi
 
 
-#Comment out the below two lines
+# Comment out the below two lines
 echo "Target_Dir:$LSWS_HOME User:$WS_USER Group:$WS_GROUP "
 
 if [ "x$IS_LSCPD" != "xyes" ] ; then 
@@ -445,7 +413,7 @@ if [ "x$IS_LSCPD" != "xyes" ] ; then 
         chown "$SDIR_OWN" "$LSWS_HOME/fcgi-bin/lsphp5"
         chmod "$EXEC_MOD" "$LSWS_HOME/fcgi-bin/lsphp5"
         
-        #Set default lsphp5
+        # Set default lsphp5
         ln -sf "$LSWS_HOME/fcgi-bin/lsphp5" "$LSWS_HOME/fcgi-bin/lsphp" 
         
         if [ "x$USE_LSPHP7" = "xyes" ] ; then
@@ -458,7 +426,7 @@ if [ "x$IS_LSCPD" != "xyes" ] ; then 
     fi
 
 
-    #compress_admin_file
+    # compress_admin_file
     if [ ! -f "$LSWS_HOME/admin/conf/jcryption_keypair" ]; then
         $LSWS_HOME/admin/misc/create_admin_keypair.sh
     fi
@@ -470,7 +438,7 @@ if [ "x$IS_LSCPD" != "xyes" ] ; then 
     chmod 0600 "$LSWS_HOME/admin/conf/htpasswd"
 
 
-    #for root user, we'll try to start it automatically
+    # for root user, we'll try to start it automatically
     INST_USER=`id`
     INST_USER=`expr "$INST_USER" : 'uid=.*(\(.*\)) gid=.*'`
     if [ $INST_USER = "root" ]; then
@@ -506,10 +474,6 @@ END
 
 fi
 
-
-
 echo
 echo -e "\033[38;5;148mInstallation finished, Enjoy!\033[39m"
 echo
-
-
Code:
--- dlbrotli.sh.orig    2018-12-31 15:14:02 UTC
+++ dlbrotli.sh
@@ -1,9 +1,8 @@
-#! /bin/sh
+#!/bin/sh
 
 cd `dirname "$0"`
 echo "Checking libbrotli ..."
 
-
 if [ ! -f brotli-master/out/libbrotlidec-static.a ] ; then
     echo -e "\033[38;5;148mDownloading libbrotli latest version and building, it will take several minutes ...\033[39m"
 
@@ -13,7 +12,8 @@ if [ ! -f brotli-master/out/libbrotlidec
         exit 1
     fi
 
-    wget  --no-check-certificate  -O br.zip   https://codeload.github.com/google/brotli/zip/master
+    . detect-download.sh
+    $DLCMD br.zip https://codeload.github.com/google/brotli/zip/master
     unzip br.zip
     cd brotli-master
     
@@ -34,4 +34,3 @@ else
     echo -e "\033[38;5;148mLibbrotli libraries exist.\033[39m"
     exit 0
 fi
-
Code:
--- dlmaxminddb.sh.orig 2018-12-31 15:14:02 UTC
+++ dlmaxminddb.sh
@@ -1,4 +1,4 @@
-#! /bin/sh
+#!/bin/sh
 
 cd `dirname "$0"`
 CURDIR=`pwd`
@@ -11,12 +11,13 @@ URL=https://github.com/maxmind/libmaxmin
 if [ ! -f "libmaxminddb/src/.libs/libmaxminddb.a" ] ; then
     echo -e "\033[38;5;148mDownloading libmaxminddb version $VERSION and building, it will take several minutes ...\033[39m"
 
-    wget  --no-check-certificate  -O mmdb.tgz   $URL
+    . detect-download.sh
+    $DLCMD mmdb.tgz $URL
     tar xf mmdb.tgz
     mv libmaxminddb-$VERSION ../libmaxminddb
     cd ../libmaxminddb
-    
-    ./bootstrap 
+
+    ./bootstrap
     ./configure --disable-tests
     make
Code:
--- dlossl.sh.orig      2018-12-31 15:14:02 UTC
+++ dlossl.sh
@@ -1,13 +1,11 @@
-#! /bin/sh
-#
+#!/bin/sh
+
 # This script is to download openssl latest stable and make the static library ready
-# Or,
-# Use your pre-built boringSSL
+# Or, use your pre-built boringSSL
 
-#For openssl, always use the latest officially released version
+# For openssl, always use the latest officially released version
 VERSION=OpenSSL_1_1_1a
 
-
 if [ "x$1" = "xuse_bssl" ] ; then 
     if [ "x$2" != "x" ] ; then 
         mkdir ssl
@@ -25,10 +23,6 @@ if [ "x$1" = "xuse_bssl" ] ; then 
     exit 0;
 fi
 
-
-
-
-
 cd `dirname "$0"`
 echo "Checking openssl ..."
 
@@ -36,10 +30,8 @@ if [ ! -f ssl/libcrypto.a ] ; then
     echo -e "\033[38;5;148mDownload openssl $VERSION and building, it will take several minutes ...\033[39m"
     echo -e "\033[38;5;148mThe url is https://github.com/openssl/openssl/archive/$VERSION.tar.gz\033[39m"
 
-    DL=`which curl`
-    DLCMD="$DL -k -L -o ossl.tar.gz"
-    
-    $DLCMD https://github.com/openssl/openssl/archive/$VERSION.tar.gz
+    . detect-download.sh
+    $DLCMD ossl.tar.gz https://github.com/openssl/openssl/archive/$VERSION.tar.gz
     tar xf ossl.tar.gz
     rm -rf ssl
     mv openssl-$VERSION ssl
Code:
--- fixtimestamp.sh.orig        2019-01-04 14:55:09 UTC
+++ fixtimestamp.sh
@@ -1,10 +1,9 @@
-#When using git clone to get the source code, the timestamp will be lost.
-#then when run make, it will cause re-config issue.
-
 #!/bin/sh
 
+# When using git clone to get the source code, the timestamp will be lost.
+# then when run make, it will cause re-config issue.
 
-touch  aclocal.m4
+touch aclocal.m4
 sleep 2
 
 touch Makefile.in
Code:
--- installudns.sh.orig 2018-12-31 15:14:02 UTC
+++ installudns.sh
@@ -1,31 +1,12 @@
 #!/bin/sh
 
-#Download udns source code and install it
-
-# detect download method
-DLCMD=
-DL=`which wget`
-if [ $? -eq 0 ] ; then
-    DLCMD="wget -nv -O "
-else
-    DL=`which curl`
-    if [ $? -eq 0 ] ; then
-        DLCMD="curl -L -o "
-    else
-        if [ "x$OS" = "xFreeBSD" ] ; then
-            DL=`which fetch`
-            if [ $? -eq 0 ] ; then
-                DLCMD="fetch -o "
-            fi
-        fi
-    fi
-fi
+VERSION=0.4
+echo "Will download stable version of the udns library $VERSION and install it"
 
-echo Will download stable version of the udns library 0.4 and install it
-$DLCMD ./udns.tar.gz  http://www.corpit.ru/mjt/udns/udns-0.4.tar.gz
+. detect-download.sh
+$DLCMD udns.tar.gz http://www.corpit.ru/mjt/udns/udns-$VERSION.tar.gz
 tar xf udns.tar.gz
-cd udns-0.4/
+cd udns-$VERSION/
 ./configure
 make
 cd ../
-
Code:
--- modverinfo.sh.orig  2019-01-04 15:00:25 UTC
+++ modverinfo.sh
@@ -1,8 +1,6 @@
-#! /bin/sh
-#
+#!/bin/sh
+
 # This script is to gather pre-defined modules version info
-#
-#
 
 OS=`uname -s`
 ALL_VER_INFO=
@@ -19,7 +17,6 @@ if [ "x$OS" = "xLinux" ] ; then
     ALL_VER_INFO="$ALL_VER_INFO\tmodpagespeed $DEFINED_VALUE$MODULESPACE"
 fi
 
-
 get_file_defined_value src/modules/cache/cache.cpp "#define MODULE_VERSION_INFO"
 ALL_VER_INFO="$ALL_VER_INFO\tcache $DEFINED_VALUE$MODULESPACE"
 
@@ -29,11 +26,7 @@ ALL_VER_INFO="$ALL_VER_INFO\tmodinspecto
 get_file_defined_value src/modules/uploadprogress/uploadprogress.cpp "#define MODULE_VERSION_INFO"
 ALL_VER_INFO="$ALL_VER_INFO\tuploadprogress $DEFINED_VALUE$MODULESPACE"
 
-
 get_file_defined_value src/modules/modsecurity-ls/mod_security.cpp "#define VERSIONNUMBER"
 ALL_VER_INFO="$ALL_VER_INFO\tmod_security $DEFINED_VALUE$MODULESPACE"
 
-
-
 echo $ALL_VER_INFO
-
 
#2
Another problem I with shebang's I see at ssl/util/echo.pl which starts with says /usr/bin/perl
while on probably most BSD that's /usr/local/bin/perl
All other .pl files have correctly
Code:
#! /usr/bin/env perl
 
#3
One more that could use the detect-download.sh

Plus in this file another shebang problem; if on FreeBSD there would be Bash, than /bin/bash wont be the path, but /usr/local/bin/bash
So "#! /usr/bin/env bash" would be more compatible.

Code:
--- src/modules/pagespeed/dlpsol.sh.orig        2019-01-05 05:34:41 UTC
+++ src/modules/pagespeed/dlpsol.sh
@@ -1,8 +1,8 @@
-#! /bin/bash
-#
+#! /usr/bin/env bash
+
# This script is to download PSOL and extract it to right location
-#

+PSOLVERSION=1.11.33.4

pushd .
cd `dirname "$0"`
@@ -11,10 +11,7 @@ if [ ! -d ../../../../thirdparty ] ; the
    mkdir ../../../../thirdparty
fi

-PSOLVERSION=1.11.33.4
-
USEOLDLIB=no
-
GCCVER=`gcc -dumpfullversion -dumpversion`
IFS='.';
parts=( $GCCVER )
@@ -38,27 +35,20 @@ if [ "x$1" != "x" ]; then
    ln -sf ../../../../thirdparty/psol-$PSOLVERSION psol
fi

-
cd ../../../../thirdparty

if [ ! -f psol-$PSOLVERSION/include/out/Release/obj/gen/net/instaweb/public/version.h ] ; then

-
     TARGET=$PSOLVERSION.tar.gz

-
-    DL=`which curl`
-    DLCMD="$DL -O -k "
-    if [ ! -f $TARGET ] ; then
-        $DLCMD https://dl.google.com/dl/page-speed/psol/$TARGET
-    fi
+    . ../../../detect-download.sh
+    $DLCMD $TARGET https://dl.google.com/dl/page-speed/psol/$TARGET
     tar -xzvf $TARGET # expands to psol/
     mv psol psol-$PSOLVERSION
-
    
     if [ "x$USEOLDLIB" = "xyes" ] ; then
   
-    #fix a file which stop the compiling of pagespeed module
+    # Fix a file which stop the compiling of pagespeed module
     echo .
     cat << EOF > psol-$PSOLVERSION/include/pagespeed/kernel/base/scoped_ptr.h
/**
 
Last edited:
#4
these files need shebangfix for bash
Code:
#!/usr/bin/env bash
src/modules/modsecurity-ls/dllibmodsecurity.sh
test/asan_run
test/lsr/run_asantest.sh
test/lsr/run_valgrindtest.sh

these files need shebangfix, but I'm yet unable to patch that:
Code:
#!/usr/bin/env perl
ssl/Configurations/unix-checker.pm
ssl/Configurations/windows-checker.pm
ssl/test/README
ssl/test/recipes/06-test-rdrand.t
ssl/test/recipes/80-test_cipherbytes.t
ssl/test/recipes/80-test_cipherlist.t
ssl/test/recipes/80-test_ciphername.t
ssl/test/recipes/90-test_includes.t
ssl/util/echo.pl

AFAIK Doxygen is only used for generating help pages.
But I found these two to:
Code:
--- include/lsiapi.doxc.orig    2019-01-05 06:08:00 UTC
+++ include/lsiapi.doxc
@@ -1983,7 +1983,7 @@ EXTERNAL_PAGES         = YES
# interpreter (i.e. the result of 'which perl').
# The default file (with absolute path) is: /usr/bin/perl.

-PERL_PATH              = /usr/bin/perl
+PERL_PATH              = "/usr/bin/env perl"

#---------------------------------------------------------------------------
# Configuration options related to the dot tool
Code:
--- include/lsr/lsrapi.doxc.orig        2019-01-05 06:08:33 UTC
+++ include/lsr/lsrapi.doxc
@@ -1995,7 +1995,7 @@ EXTERNAL_PAGES         = YES
# interpreter (i.e. the result of 'which perl').
# The default file (with absolute path) is: /usr/bin/perl.

-PERL_PATH              = /usr/bin/perl
+PERL_PATH              = "/usr/bin/env perl"

#---------------------------------------------------------------------------
# Configuration options related to the dot tool
 
Last edited:

David

Active Member
#6
I fixed most of the scripts by using an existing functions.sh to avoid creating a new file and you will see it in the next release.
Thanks.
David
 
#7
Thanks very much.
I almost certainly will have one more request, as I noticed that during the install of the port (pkg) it starts using paths of the staging directory. Though I might solve it with a patch in the package.
Further I will need to make a launch script that suits with the *BSD's standards.
Not a problem, but I will need some time to finalize it - but already seen it's possible.
 
Top