openlitespeed 1.7.15 upgrage broken

#1
Unpacking openlitespeed (1.7.15-1+bullseye) over (1.7.14-1+bullseye) ...
/var/lib/dpkg/info/openlitespeed.postrm: 8: Syntax error: "(" unexpected
dpkg: warning: old openlitespeed package post-removal script subprocess returned error exit status 2
dpkg: trying script from the new package instead ...
/var/lib/dpkg/tmp.ci/postrm: 8: Syntax error: "(" unexpected
dpkg: error processing archive /tmp/apt-dpkg-install-Buj6Iq/00-openlitespeed_1.7.15-1+bullseye_amd64.deb (--unpack):
new openlitespeed package post-removal script subprocess returned error exit status 2
/var/lib/dpkg/tmp.ci/postrm: 8: Syntax error: "(" unexpected
dpkg: error while cleaning up:
new openlitespeed package post-removal script subprocess returned error exit status 2
 
#4
changed /bin/sh -> bash

but still w/o luck.

Unpacking openlitespeed (1.7.15-1+bullseye) over (1.7.14-1+bullseye) ...
dpkg: warning: old openlitespeed package post-removal script subprocess returned error exit status 1
dpkg: trying script from the new package instead ...
dpkg: error processing archive /var/cache/apt/archives/openlitespeed_1.7.15-1+bullseye_amd64.deb (--unpack):
new openlitespeed package post-removal script subprocess returned error exit status 1
dpkg: error while cleaning up:
new openlitespeed package post-removal script subprocess returned error exit status 1
Errors were encountered while processing:
/var/cache/apt/archives/openlitespeed_1.7.15-1+bullseye_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)


yestoday we solved it though temporary fix:

```
#fix for broken openlitespeed 1.7.15 installation
/var/lib/dpkg/info/openlitespeed.postrm:
file.managed:
- user: root
- group: root
- mode: '755'
- contents: |
#!/bin/sh
# postrm script for openlitespeed
#
# see: dh_installdeb(1)

set -e

exit 0

litespeed_pkgs:
pkg:
- latest
- refresh: True
- pkgs:
- openlitespeed
- ols-pagespeed
- ols-modsecurity
```

and installed new version + restored all deleted configs, because all our openlitespeed installation where down after night autoupgrade
 
#5
tried fresh install with both shells:

Setting up openlitespeed (1.7.15-1+bullseye) ...
dpkg: error processing package openlitespeed (--configure):
installed openlitespeed package post-installation script subprocess was killed by signal (Killed)
dpkg: dependency problems prevent configuration of ols-pagespeed:
ols-pagespeed depends on openlitespeed (>= 1.7.15-1+bullseye); however:
Package openlitespeed is not configured yet.

dpkg: error processing package ols-pagespeed (--configure):
dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of ols-modsecurity:
ols-modsecurity depends on openlitespeed (>= 1.7.15-1+bullseye); however:
Package openlitespeed is not configured yet.

dpkg: error processing package ols-modsecurity (--configure):
dependency problems - leaving unconfigured
Errors were encountered while processing:
openlitespeed
ols-pagespeed
ols-modsecurity
E: Sub-process /usr/bin/dpkg returned an error code (1)
 
#7
Read lsws logs. I think you have no configs. Admin config file and main config file.
If I just install openlitespeed, installation have to setup everything. I do not need to have any configs to make installation working.
Our salt reciptes configure everything, and we have really big number of installation working on 1.7.14 and now even 1.7.15. I just do not want to have broken openlitespeed in production any more.
 

vaka

New Member
#8
I have the same issue while install 1.7.15 because lack of configs.
When 1.7.14 was removed, postrm script delete all configs. Because you (and mee too) placed exit 0 in the postrm script.

The main problem is bash-isms in installation scripts on debian-like platforms.
 
#9
I have the same issue while install 1.7.15 because lack of configs.
When 1.7.14 was removed, postrm script delete all configs. Because you (and mee too) placed exit 0 in the postrm script.

The main problem is bash-isms in installation scripts on debian-like platforms.
It wasnt problem for us, configs were deleted already after night auto install. But we have 4 salt litespeed recipes that complely install desired installation w/o web admin (actually it is turned off by recipes), so we restored everything.
 
#11
tested 1.7.15-3, postrm script works ok. But still there are problems with postinstall script:

#!/bin/bash
# postinst script for openlitespeed
#
# see: dh_installdeb(1)

set -ex <-- set -e is headache in post install script. If something goes wrong... installation never ends. If it is first install.... but if it is upgrade.... you never know at what state current openlitespeed is...... maybe it is totally broken..... and if so..... installation never ends.....

#change file permissions
#DIR_MOD=755
#SDIR_MOD=700
#EXEC_MOD=555
#CONF_MOD=600
#DOC_MOD=644

DEFAULT_USER="nobody"
DEFAULT_GROUP="nogroup"

grep -q nobody: "/etc/group" <-------- we dont have nobody in /etc/group only nogroup - so code break on this line

if [ $? != 0 ] ; then <---- never works
DEFAULT_GROUP="nogroup"
fi

WS_USER=$DEFAULT_USER
WS_GROUP=$DEFAULT_GROUP

OLD_USER=$DEFAULT_USER
OLD_GROUP=$DEFAULT_GROUP

ADMIN_USER="lsadm"
LSWS_HOME="/usr/local/lsws"

if [ -f "$LSWS_HOME/conf/httpd_config.conf" ] ; then
#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*\)'`
OLD_GROUP=`expr "$OLD_GROUP_CONF" : '\s*group\s*\(\S*\)'`
fi

WS_USER=$OLD_USER
WS_GROUP=$OLD_GROUP

DIR_OWN=$WS_USER:$WS_GROUP
CONF_OWN=$WS_USER:$WS_GROUP
LOGDIR_OWN="root:$WS_GROUP"

grep "^lsadm:" /etc/passwd 1>/dev/null 2>&1
if [ $? -eq 0 ]; then
CONF_OWN="lsadm:lsadm"
fi

SDIR_OWN="root:root"

chown "$SDIR_OWN" "$LSWS_HOME" >/dev/null 2>&1

chown "$CONF_OWN" -R "$LSWS_HOME/conf" >/dev/null 2>&1
chown "$CONF_OWN" -R "$LSWS_HOME/phpbuild" >/dev/null 2>&1

if [ -d "$LSWS_HOME/autoupdate" ]; then
chown "$DIR_OWN" -R "$LSWS_HOME/autoupdate" >/dev/null 2>&1
fi

chmod 0755 "$LSWS_HOME/autoupdate" >/dev/null 2>&1

if [ -d "$LSWS_HOME/DEFAULT/conf" ]; then
chown "$CONF_OWN" -R "$LSWS_HOME/DEFAULT/conf" >/dev/null 2>&1
fi

if [ -d "$LSWS_HOME/Example/conf" ]; then
chown "$CONF_OWN" -R "$LSWS_HOME/Example/conf" >/dev/null 2>&1
fi

chown "$CONF_OWN" -R "$LSWS_HOME/admin/conf" >/dev/null 2>&1
chown "$CONF_OWN" -R "$LSWS_HOME/admin/tmp" >/dev/null 2>&1

chgrp $WS_GROUP "$LSWS_HOME/admin/cgid" >/dev/null 2>&1
chgrp $WS_GROUP "$LSWS_HOME/admin/tmp" >/dev/null 2>&1

chown "$CONF_OWN" "$LSWS_HOME/admin/tmp/sess_*" 1>/dev/null 2>&1 <-------- webadmin disabled so we dont have any sessions... error
chown "$DIR_OWN" "$LSWS_HOME/cachedata" >/dev/null 2>&1

chown "$DIR_OWN" "$LSWS_HOME/tmp/ocspcache" >/dev/null 2>&1

chown "$SDIR_OWN" "$LSWS_HOME/fcgi-bin/lsphp" >/dev/null 2>&1 <----- if constants commented - code returns '' and there is error
chmod "$EXEC_MOD" "$LSWS_HOME/fcgi-bin/lsphp" >/dev/null 2>&1

chown "$CONF_OWN" "$LSWS_HOME/admin/conf/jcryption_keypair" >/dev/null 2>&1
chmod 0600 "$LSWS_HOME/admin/conf/jcryption_keypair" >/dev/null 2>&1

chown "$CONF_OWN" "$LSWS_HOME/admin/conf/htpasswd" >/dev/null 2>&1
chmod 0600 "$LSWS_HOME/admin/conf/htpasswd" >/dev/null 2>&1

chown "$LOGDIR_OWN" "$LSWS_HOME/logs" "$LSWS_HOME/admin/logs" >/dev/null 2>&1
chmod 0750 "$LSWS_HOME/logs" "$LSWS_HOME/admin/logs" >/dev/null 2>&1

#end of changing file permissions

SSL_COUNTRY='US'
SSL_STATE="New Jersey"
SSL_LOCALITY='Virtual'
SSL_ORG='LiteSpeedCommunity'
SSL_ORGUNIT='Testing'
SSL_HOSTNAME='webadmin'
COMMNAME='openlitespeed.host'
SSL_COUNTRY=US
SSL_STATE="New Jersey"
csr="${SSL_HOSTNAME}.csr"
key="${SSL_HOSTNAME}.key"
cert="${SSL_HOSTNAME}.crt"

sslcert=/usr/local/lsws/admin/conf/${cert}
sslkey=/usr/local/lsws/admin/conf/${key}

cat << EOF > ${csr}
[req]
prompt=no
distinguished_name=openlitespeed
[openlitespeed]
commonName = ${COMMNAME}
countryName = ${SSL_COUNTRY}
localityName = Virtual
organizationName = LiteSpeedCommunity
organizationalUnitName = Testing
stateOrProvinceName = NJ
emailAddress = mail@${COMMNAME}
name = openlitespeed
initials = CP
dnQualifier = openlitespeed
[server_exts]
extendedKeyUsage=1.3.6.1.5.5.7.3.1
EOF

if [ ! -f ${sslcert} ]; then
openssl req -x509 -config $csr -extensions 'server_exts' -nodes -days 820 -newkey rsa:2048 -keyout $sslkey -out $sslcert
chown lsadm.lsadm $sslcert; chmod 400 $sslcert;
chown lsadm.lsadm $sslkey; chmod 400 $sslkey;
fi

# echo "lsws service set to auto start"
/usr/local/lsws/admin/misc/rc-inst.sh >/dev/null 2>&1

# echo "now start lsws"
#/usr/local/lsws/bin/lswsctrl start >/dev/null 2>&1

if [ -e /etc/systemd/system ] || [ -e /usr/lib/systemd/system ] || [ -e /lib/systemd/system ] ; then
systemctl status lsws > /dev/null 2>&1
if [ $? -eq 3 ] ; then
/usr/local/lsws/bin/lswsctrl stop > /dev/null 2>&1
fi
systemctl restart lsws > /dev/null 2>&1 <--------------------- if something wrong with server we getting process killed (why)....
else
service lsws restart >/dev/null 2>&1 || :
fi

# Cleanup .dpkg files that match the currently installed ones
if [[ "$1" == 'configure' ]]; then
FILES_TO_IGNORE=(
'/usr/local/lsws/conf/httpd_config.conf'
'/usr/local/lsws/conf/mime.properties'
'/usr/local/lsws/conf/vhosts/Example/htgroup'
'/usr/local/lsws/conf/vhosts/Example/htpasswd'
'/usr/local/lsws/conf/vhosts/Example/vhconf.conf'
'/usr/local/lsws/conf/templates/ccl.conf'
'/usr/local/lsws/conf/templates/phpsuexec.conf'
'/usr/local/lsws/conf/templates/rails.conf'
'/usr/local/lsws/fcgi-bin/lsphp'
'/usr/local/lsws/admin/conf/admin_config.conf'
'/usr/local/lsws/admin/conf/htpasswd'
'/usr/local/lsws/admin/conf/jcryption_keypair'
'/usr/local/lsws/admin/conf/webadmin.crt'
'/usr/local/lsws/admin/conf/webadmin.key'
'/usr/local/lsws/Example/cgi-bin/helloworld'
'/usr/local/lsws/Example/html/error404.html'
'/usr/local/lsws/Example/html/index.html'
'/usr/local/lsws/Example/html/phpinfo.php'
'/usr/local/lsws/Example/html/upload.html'
'/usr/local/lsws/Example/html/upload.php'
'/usr/local/lsws/Example/html/blocked/index.html'
'/usr/local/lsws/Example/html/css/bootstrap.min.css'
'/usr/local/lsws/Example/html/css/custom.css'
'/usr/local/lsws/Example/html/img/404-icon.png'
'/usr/local/lsws/Example/html/img/blocked_content-icon.png'
'/usr/local/lsws/Example/html/img/cgi-icon.png'
'/usr/local/lsws/Example/html/img/file_upload-icon.png'
'/usr/local/lsws/Example/html/img/olsws_logo.png'
'/usr/local/lsws/Example/html/img/php-icon.png'
'/usr/local/lsws/Example/html/img/powered_by_ols-new.png'
'/usr/local/lsws/Example/html/img/pwd_protect-icon.png'
'/usr/local/lsws/Example/html/protected/index.html'
'/usr/local/lsws/Example/logs/access.log'
)

for FILE_TO_IGNORE in ${FILES_TO_IGNORE[@]}; do
if [[ -f "${FILE_TO_IGNORE}.dpkg" ]]; then
MD5_OLD=$(/usr/bin/md5sum ${FILE_TO_IGNORE} | awk '{print $1}')
MD5_NEW=$(/usr/bin/md5sum ${FILE_TO_IGNORE}.dpkg | awk '{print $1}')
if [[ "${MD5_OLD}" == "${MD5_NEW}" ]]; then
/bin/rm -rf "${FILE_TO_IGNORE}.dpkg"
fi
fi
done
fi

# dh_installdeb will replace this with shell code automatically
# generated by other debhelper scripts.


exit 0
 
Last edited:
#12
thanks for fixing issue - 1.7.15-4 postinstall runs w/o errors.

there is last issue we have after every update:
We have dpkg configuration:
```
/etc/dpkg/dpkg.cfg.d/50_litespeed:
file.managed:
- user: root
- group: root
- mode: '644'
- contents: |
path-exclude /usr/local/lsws/conf/*
```

The goal is - keep our configs unchanged.
But after night update 1.7.15-4 all our configs were deleted again.
 
Last edited:
Top