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

Bugfix/packages correction #583

Merged
merged 13 commits into from
Mar 14, 2022
Merged
61 changes: 10 additions & 51 deletions build/install/OneClickInstall/install-Debian/install-app.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,11 @@ if [ "$DOCUMENT_SERVER_INSTALLED" = "false" ]; then

echo ${package_sysname}-documentserver $DS_COMMON_NAME/ds-port select $DS_PORT | sudo debconf-set-selections
echo ${package_sysname}-documentserver $DS_COMMON_NAME/db-pwd select $DS_DB_PWD | sudo debconf-set-selections
echo ${package_sysname}-documentserver $DS_COMMON_NAME/db-user $DS_DB_USER | sudo debconf-set-selections
echo ${package_sysname}-documentserver $DS_COMMON_NAME/db-name $DS_DB_NAME | sudo debconf-set-selections
echo ${package_sysname}-documentserver-de $DS_COMMON_NAME/jwt-enabled select ${DS_JWT_ENABLED} | sudo debconf-set-selections
echo ${package_sysname}-documentserver-de $DS_COMMON_NAME/jwt-secret select ${DS_JWT_SECRET} | sudo debconf-set-selections
echo ${package_sysname}-documentserver-de $DS_COMMON_NAME/jwt-header select ${DS_JWT_HEADER} | sudo debconf-set-selections
echo ${package_sysname}-documentserver-ee $DS_COMMON_NAME/jwt-enabled select ${DS_JWT_ENABLED} | sudo debconf-set-selections
echo ${package_sysname}-documentserver-ee $DS_COMMON_NAME/jwt-secret select ${DS_JWT_SECRET} | sudo debconf-set-selections
echo ${package_sysname}-documentserver-ee $DS_COMMON_NAME/jwt-header select ${DS_JWT_HEADER} | sudo debconf-set-selections
echo ${package_sysname}-documentserver $DS_COMMON_NAME/db-user select $DS_DB_USER | sudo debconf-set-selections
echo ${package_sysname}-documentserver $DS_COMMON_NAME/db-name select $DS_DB_NAME | sudo debconf-set-selections
echo ${package_sysname}-documentserver $DS_COMMON_NAME/jwt-enabled select ${DS_JWT_ENABLED} | sudo debconf-set-selections
echo ${package_sysname}-documentserver $DS_COMMON_NAME/jwt-secret select ${DS_JWT_SECRET} | sudo debconf-set-selections
echo ${package_sysname}-documentserver $DS_COMMON_NAME/jwt-header select ${DS_JWT_HEADER} | sudo debconf-set-selections

apt-get install -yq ${package_sysname}-documentserver
elif [ "$UPDATE" = "true" ] && [ "$DOCUMENT_SERVER_INSTALLED" = "true" ]; then
Expand All @@ -65,55 +62,17 @@ else
systemctl reload nginx
fi

APPSERVER_INSTALLED_VERSION=$(apt-cache policy ${product} | awk 'NR==2{print $2}')
APPSERVER_LATEST_VERSION=$(apt-cache policy ${product} | awk 'NR==3{print $2}')
if [ "$APPSERVER_INSTALLED_VERSION" != "$APPSERVER_LATEST_VERSION" ]; then
APPSERVER_NEED_UPDATE="true"
fi

if [ "$APPSERVER_INSTALLED" = "false" ]; then
echo ${product} ${product}/db-pwd select $MYSQL_SERVER_PASS | sudo debconf-set-selections
echo ${product} ${product}/db-user select $MYSQL_SERVER_USER | sudo debconf-set-selections
echo ${product} ${product}/db-name select $MYSQL_SERVER_DB_NAME | sudo debconf-set-selections

apt-get install -y ${product} || true #Fix error 'Failed to fetch'
apt-get install -y ${product}
elif [ "$APPSERVER_NEED_UPDATE" = "true" ]; then
ENVIRONMENT="$(cat /lib/systemd/system/${product}-api.service | grep -oP 'ENVIRONMENT=\K.*')"
USER_CONNECTIONSTRING=$(json -f /etc/onlyoffice/${product}/appsettings.$ENVIRONMENT.json ConnectionStrings.default.connectionString)
MYSQL_SERVER_HOST=$(echo $USER_CONNECTIONSTRING | grep -oP 'Server=\K.*' | grep -o '^[^;]*')
MYSQL_SERVER_DB_NAME=$(echo $USER_CONNECTIONSTRING | grep -oP 'Database=\K.*' | grep -o '^[^;]*')
MYSQL_SERVER_USER=$(echo $USER_CONNECTIONSTRING | grep -oP 'User ID=\K.*' | grep -o '^[^;]*')
MYSQL_SERVER_PORT=$(echo $USER_CONNECTIONSTRING | grep -oP 'Port=\K.*' | grep -o '^[^;]*')
MYSQL_SERVER_PASS=$(echo $USER_CONNECTIONSTRING | grep -oP 'Password=\K.*' | grep -o '^[^;]*')

elif [ "$UPDATE" = "true" ] && [ "$APPSERVER_INSTALLED" = "true" ]; then
apt-get install -o DPkg::options::="--force-confnew" -y --only-upgrade ${product} elasticsearch=${ELASTIC_VERSION}
fi

if [ "${APPSERVER_INSTALLED}" = "false" ] || [ "${APPSERVER_NEED_UPDATE}" = "true" ]; then
expect << EOF
set timeout -1
log_user 1

if { "${UPDATE}" == "true" } {
spawn ${product}-configuration.sh -e ${ENVIRONMENT}
} else {
spawn ${product}-configuration.sh
}

expect -re "Database host:"
send "\025$MYSQL_SERVER_HOST\r"

expect -re "Database name:"
send "\025$MYSQL_SERVER_DB_NAME\r"

expect -re "Database user:"
send "\025$MYSQL_SERVER_USER\r"

expect -re "Database password:"
send "\025$MYSQL_SERVER_PASS\r"

expect eof
EOF
APPSERVER_INSTALLED="true";
fi

echo ""
echo "$RES_INSTALL_SUCCESS"
echo "$RES_QUESTIONS"
Expand Down
4 changes: 3 additions & 1 deletion build/install/OneClickInstall/install-Debian/install-preq.sh
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ if [ "$(ls "$PRODUCT_DIR/services/kafka" 2> /dev/null)" == "" ]; then
KAFKA_ARCHIVE=$(curl https://downloads.apache.org/kafka/$KAFKA_VERSION/ | grep -Eo "kafka_2.[0-9][0-9]-$KAFKA_VERSION.tgz" | tail -1)
curl https://downloads.apache.org/kafka/$KAFKA_VERSION/$KAFKA_ARCHIVE -O
tar xzf $KAFKA_ARCHIVE --strip 1 && rm -rf $KAFKA_ARCHIVE
chown -R kafka ${PRODUCT_DIR}/services/kafka
chown -R kafka ${PRODUCT_DIR}/services/kafka/
cd -
fi

Expand All @@ -83,6 +83,7 @@ Restart=on-abnormal
[Install]
WantedBy=multi-user.target
END
systemctl start zookeeper
fi

if [ ! -e /lib/systemd/system/kafka.service ]; then
Expand All @@ -99,6 +100,7 @@ Restart=on-abnormal
[Install]
WantedBy=multi-user.target
END
systemctl start kafka
fi

if ! dpkg -l | grep -q "mysql-server"; then
Expand Down
67 changes: 44 additions & 23 deletions build/install/common/appserver-configuration.sh
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,13 @@ while [ "$1" != "" ]; do
fi
;;

-ess | --elasticsheme )
if [ "$2" != "" ]; then
ELK_SHEME=$2
shift
fi
;;

-esh | --elastichost )
if [ "$2" != "" ]; then
ELK_HOST=$2
Expand All @@ -106,7 +113,7 @@ while [ "$1" != "" ]; do

-esp | --elasticport )
if [ "$2" != "" ]; then
ELK_HOST=$2
ELK_PORT=$2
shift
fi
;;
Expand All @@ -118,6 +125,34 @@ while [ "$1" != "" ]; do
fi
;;

-mysqlh | --mysqlhost )
if [ "$2" != "" ]; then
DB_HOST=$2
shift
fi
;;

-mysqld | --mysqldatabase )
if [ "$2" != "" ]; then
DB_NAME=$2
shift
fi
;;

-mysqlu | --mysqluser )
if [ "$2" != "" ]; then
DB_USER=$2
shift
fi
;;

-mysqlp | --mysqlpassword )
if [ "$2" != "" ]; then
DB_PWD=$2
shift
fi
;;

-? | -h | --help )
echo " Usage: bash ${PRODUCT}-configuration.sh [PARAMETER] [[PARAMETER], ...]"
echo
Expand All @@ -132,6 +167,10 @@ while [ "$1" != "" ]; do
echo " -zkp, --zookeeperport zookeeper port (default 2181)"
echo " -esh, --elastichost elasticsearch ip"
echo " -esp, --elasticport elasticsearch port (default 9200)"
echo " -mysqlh, --mysqlhost mysql server host"
echo " -mysqld, --mysqldatabase ${PRODUCT} database name"
echo " -mysqlu, --mysqluser ${PRODUCT} database user"
echo " -mysqlp, --mysqlpassword ${PRODUCT} database password"
echo " -e, --environment environment (default 'production')"
echo " -?, -h, --help this help"
echo
Expand Down Expand Up @@ -203,24 +242,10 @@ input_db_params(){
local def_DB_NAME=$(echo $user_connectionString | grep -oP 'Database=\K.*' | grep -o '^[^;]*')
local def_DB_USER=$(echo $user_connectionString | grep -oP 'User ID=\K.*' | grep -o '^[^;]*')

read -e -p "Database host: " -i "$DB_HOST" DB_HOST
read -e -p "Database name: " -i "$DB_NAME" DB_NAME
read -e -p "Database user: " -i "$DB_USER" DB_USER
read -e -p "Database password: " -s DB_PWD

if [ -z $DB_HOST ]; then
DB_HOST="${def_DB_HOST}";
fi

if [ -z $DB_NAME ]; then
DB_NAME="${def_DB_NAME}";
fi

if [ -z $DB_USER ]; then
DB_USER="${def_DB_USER}";
fi

echo
if [ -z $def_DB_HOST ] && [ -z $DB_HOST ]; then read -e -p "Database host: " -i "$DB_HOST" DB_HOST; fi
if [ -z $def_DB_NAME ] && [ -z $DB_NAME ]; then read -e -p "Database name: " -i "$DB_NAME" DB_NAME; fi
if [ -z $def_DB_USER ] && [ -z $DB_USER ]; then read -e -p "Database user: " -i "$DB_USER" DB_USER; fi
if [ -z $DB_PWD ]; then read -e -p "Database password: " -i "$DB_PWD" DB_PWD; fi
}

establish_mysql_conn(){
Expand Down Expand Up @@ -575,10 +600,6 @@ elif command -v apt >/dev/null 2>&1; then
DIST="Debian"
PACKAGE_MANAGER="dpkg -l"
MYSQL_PACKAGE="mysql"
mkdir -p /var/log/onlyoffice/appserver/ /etc/onlyoffice/appserver/.private/
chown -R onlyoffice:onlyoffice /var/www/appserver/ /var/log/onlyoffice/appserver/ /etc/onlyoffice/appserver/
chown -R kafka /var/www/appserver/services/kafka/
systemctl restart kafka zookeeper
fi

install_json
Expand Down
2 changes: 2 additions & 0 deletions build/install/deb/debian/appserver-common.dirs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/var/log/onlyoffice/appserver
/etc/onlyoffice/appserver/.private
1 change: 1 addition & 0 deletions build/install/deb/debian/appserver-common.postinst
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@ if ! cat /etc/passwd | grep -q "nginx:"; then
fi

usermod -aG onlyoffice,nginx onlyoffice
chown onlyoffice:onlyoffice /var/log/onlyoffice/appserver /var/www/appserver /etc/onlyoffice/appserver
24 changes: 24 additions & 0 deletions build/install/deb/debian/config
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/sh -e

set -e

. /usr/share/debconf/confmodule

db_input medium appserver/environment || true
db_input medium appserver/host || true
db_input medium appserver/port || true
db_input medium appserver/kafka-host || true
db_input medium appserver/kafka-port || true
db_input medium appserver/zookeeper-host || true
db_input medium appserver/zookeeper-port || true
db_input medium appserver/elasticsearch-sheme || true
db_input medium appserver/elasticsearch-host || true
db_input medium appserver/elasticsearch-port || true

db_input medium appserver/db-host || true
db_input medium appserver/db-name || true
db_input medium appserver/db-user || true
db_go

db_input critical appserver/db-pwd || true
db_go
3 changes: 0 additions & 3 deletions build/install/deb/debian/configure

This file was deleted.

65 changes: 65 additions & 0 deletions build/install/deb/debian/postinst
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
#!/bin/sh -e

set -e

. /usr/share/debconf/confmodule

case "$1" in
configure)
db_get appserver/environment || true
ENVIRONMENT="$RET"
db_get appserver/host || true
APP_HOST="$RET"
db_get appserver/port || true
APP_PORT="$RET"

db_get appserver/db-host || true
DB_HOST="$RET"
db_get appserver/db-name || true
DB_NAME="$RET"
db_get appserver/db-user || true
DB_USER="$RET"
db_get appserver/db-pwd || true
DB_PWD="$RET"

db_get appserver/kafka-host || true
KAFKA_HOST="$RET"
db_get appserver/kafka-port || true
KAFKA_PORT="$RET"

db_get appserver/zookeeper-host || true
ZOOKEEPER_HOST="$RET"
db_get appserver/zookeeper-port || true
ZOOKEEPER_PORT="$RET"

db_get appserver/elasticsearch-sheme || true
ELK_SHEME="$RET"
db_get appserver/elasticsearch-host || true
ELK_HOST="$RET"
db_get appserver/elasticsearch-port || true
ELK_PORT="$RET"

db_get onlyoffice/db-host || true
DOCUMENT_SERVER_HOST="$RET"
db_get onlyoffice/ds-port || true
DOCUMENT_SERVER_PORT="$RET"

bash /usr/bin/appserver-configuration.sh -e $ENVIRONMENT -mysqlh $DB_HOST -mysqld $DB_NAME -mysqlu $DB_USER -mysqlp $DB_PWD -ash $APP_HOST -asp $APP_PORT \
-dsh $DOCUMENT_SERVER_HOST -dsp $DOCUMENT_SERVER_PORT -kh $KAFKA_HOST -kp $KAFKA_PORT -zkh $ZOOKEEPER_HOST -zkp $ZOOKEEPER_PORT -ess $ELK_SHEME -esh $ELK_HOST -esp $ELK_PORT
;;

abort-upgrade|abort-remove|abort-deconfigure)
;;

*)
echo "postinst called with unknown argument \`$1'" >&2
exit 1
;;
esac

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

#DEBHELPER#

exit 0
5 changes: 5 additions & 0 deletions build/install/deb/debian/rules
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,13 @@ override_dh_auto_build:
sed -i "s@var/www@var/www/${PRODUCT}@g" ${SRC_PATH}/config/nginx/*.conf
sed -i "s@var/www@var/www/${PRODUCT}@g" ${SRC_PATH}/config/nginx/includes/*.conf

override_dh_fixperms:
dh_fixperms

override_dh_auto_install:
dh_installinit
dh_systemd_enable
dh_systemd_start --no-start

override_dh_strip:
# dh_strip --exclude=/site-packages/
Expand Down
Loading