-
Notifications
You must be signed in to change notification settings - Fork 94
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
50 changed files
with
1,205 additions
and
187 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
package_sysname="onlyoffice"; | ||
DS_COMMON_NAME="onlyoffice"; | ||
product="appserver" | ||
RES_APP_INSTALLED="is already installed"; | ||
RES_APP_CHECK_PORTS="uses ports" | ||
RES_CHECK_PORTS="please, make sure that the ports are free."; | ||
RES_INSTALL_SUCCESS="Thank you for installing ONLYOFFICE ${product^^}."; | ||
RES_QUESTIONS="In case you have any questions contact us via http://support.onlyoffice.com or visit our forum at http://dev.onlyoffice.org" | ||
|
||
while [ "$1" != "" ]; do | ||
case $1 in | ||
|
||
-u | --update ) | ||
if [ "$2" != "" ]; then | ||
UPDATE=$2 | ||
shift | ||
fi | ||
;; | ||
|
||
-ls | --localscripts ) | ||
if [ "$2" != "" ]; then | ||
LOCAL_SCRIPTS=$2 | ||
shift | ||
fi | ||
;; | ||
|
||
-? | -h | --help ) | ||
echo " Usage $0 [PARAMETER] [[PARAMETER], ...]" | ||
echo " Parameters:" | ||
echo " -it, --installation_type installation type (COMMUNITY|ENTERPRISE|DEVELOPER)" | ||
echo " -u, --update use to update existing components (true|false)" | ||
echo " -ls, --local_scripts use 'true' to run local scripts (true|false)" | ||
echo " -?, -h, --help this help" | ||
echo | ||
exit 0 | ||
;; | ||
|
||
esac | ||
shift | ||
done | ||
|
||
if [ -z "${UPDATE}" ]; then | ||
UPDATE="false"; | ||
fi | ||
|
||
if [ -z "${LOCAL_SCRIPTS}" ]; then | ||
LOCAL_SCRIPTS="false"; | ||
fi | ||
|
||
if [ $(dpkg-query -W -f='${Status}' curl 2>/dev/null | grep -c "ok installed") -eq 0 ]; then | ||
apt-get update; | ||
apt-get install -yq curl; | ||
fi | ||
|
||
DOWNLOAD_URL_PREFIX="https://raw.githubusercontent.com/ONLYOFFICE/${product}/develop/build/install/OneClickInstall/install-Debian" | ||
if [ "${LOCAL_SCRIPTS}" == "true" ]; then | ||
source install-Debian/bootstrap.sh | ||
else | ||
source <(curl ${DOWNLOAD_URL_PREFIX}/bootstrap.sh) | ||
fi | ||
|
||
# add onlyoffice repo | ||
echo "deb http://download.onlyoffice.com/repo/debian squeeze main" | tee /etc/apt/sources.list.d/onlyoffice.list | ||
apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys CB2DE8E5 | ||
echo "deb http://static.teamlab.info.s3.amazonaws.com/repo/4testing/debian stable main" | sudo tee /etc/apt/sources.list.d/onlyoffice4testing.list | ||
|
||
declare -x LANG="en_US.UTF-8" | ||
declare -x LANGUAGE="en_US:en" | ||
declare -x LC_ALL="en_US.UTF-8" | ||
|
||
if [ "${LOCAL_SCRIPTS}" == "true" ]; then | ||
source install-Debian/tools.sh | ||
source install-Debian/check-ports.sh | ||
source install-Debian/install-preq.sh | ||
source install-Debian/install-app.sh | ||
else | ||
source <(curl ${DOWNLOAD_URL_PREFIX}/tools.sh) | ||
source <(curl ${DOWNLOAD_URL_PREFIX}/check-ports.sh) | ||
source <(curl ${DOWNLOAD_URL_PREFIX}/install-preq.sh) | ||
source <(curl ${DOWNLOAD_URL_PREFIX}/install-app.sh) | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
cat<<EOF | ||
####################################### | ||
# BOOTSTRAP | ||
####################################### | ||
EOF | ||
|
||
if ! dpkg -l | grep -q "sudo"; then | ||
apt-get install -yq sudo | ||
fi | ||
|
||
if ! dpkg -l | grep -q "net-tools"; then | ||
apt-get install -yq net-tools | ||
fi | ||
|
||
if ! dpkg -l | grep -q "dirmngr"; then | ||
apt-get install -yq dirmngr | ||
fi |
39 changes: 39 additions & 0 deletions
39
build/install/OneClickInstall/install-Debian/check-ports.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
cat<<EOF | ||
####################################### | ||
# CHECK PORTS | ||
####################################### | ||
EOF | ||
|
||
if dpkg -l | grep -q "${product}"; then | ||
echo "${product} $RES_APP_INSTALLED" | ||
APPSERVER_INSTALLED="true"; | ||
elif [ $UPDATE != "true" ] && netstat -lnp | awk '{print $4}' | grep -qE ":80$|:8081$|:8083$|:5001$|:5002$|:8080$|:80$"; then | ||
echo "${product} $RES_APP_CHECK_PORTS: 80, 8081, 8083, 5001, 5002"; | ||
echo "$RES_CHECK_PORTS" | ||
exit | ||
else | ||
APPSERVER_INSTALLED="false"; | ||
fi | ||
|
||
if dpkg -l | grep -q "${package_sysname}-documentserver"; then | ||
echo "${package_sysname}-documentserver $RES_APP_INSTALLED" | ||
DOCUMENT_SERVER_INSTALLED="true"; | ||
elif [ $UPDATE != "true" ] && netstat -lnp | awk '{print $4}' | grep -qE ":8083$|:5432$|:5672$|:6379$|:8000$|:8080$"; then | ||
echo "${package_sysname}-documentserver $RES_APP_CHECK_PORTS: 8083, 5432, 5672, 6379, 8000, 8080"; | ||
echo "$RES_CHECK_PORTS" | ||
exit | ||
else | ||
DOCUMENT_SERVER_INSTALLED="false"; | ||
fi | ||
|
||
if [ "$APPSERVER_INSTALLED" = "true" ] || [ "$DOCUMENT_SERVER_INSTALLED" = "true" ]; then | ||
if [ "$UPDATE" != "true" ]; then | ||
exit; | ||
fi | ||
fi |
144 changes: 144 additions & 0 deletions
144
build/install/OneClickInstall/install-Debian/install-app.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,144 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
cat<<EOF | ||
####################################### | ||
# INSTALL APP | ||
####################################### | ||
EOF | ||
apt-get -y update | ||
|
||
if [ "$DOCUMENT_SERVER_INSTALLED" = "false" ]; then | ||
DS_PORT=${DS_PORT:-8083}; | ||
|
||
DS_DB_HOST=localhost; | ||
DS_DB_NAME=$DS_COMMON_NAME; | ||
DS_DB_USER=$DS_COMMON_NAME; | ||
DS_DB_PWD=$DS_COMMON_NAME; | ||
|
||
DS_JWT_ENABLED=${DS_JWT_ENABLED:-true}; | ||
DS_JWT_SECRET="$(cat /dev/urandom | tr -dc A-Za-z0-9 | head -c 12)"; | ||
DS_JWT_HEADER="AuthorizationJwt"; | ||
|
||
if ! su - postgres -s /bin/bash -c "psql -lqt" | cut -d \| -f 1 | grep -q ${DS_DB_NAME}; then | ||
su - postgres -s /bin/bash -c "psql -c \"CREATE DATABASE ${DS_DB_NAME};\"" | ||
su - postgres -s /bin/bash -c "psql -c \"CREATE USER ${DS_DB_USER} WITH password '${DS_DB_PWD}';\"" | ||
su - postgres -s /bin/bash -c "psql -c \"GRANT ALL privileges ON DATABASE ${DS_DB_NAME} TO ${DS_DB_USER};\"" | ||
fi | ||
|
||
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 | ||
|
||
apt-get install -yq ${package_sysname}-documentserver | ||
elif [ "$UPDATE" = "true" ] && [ "$DOCUMENT_SERVER_INSTALLED" = "true" ]; then | ||
apt-get install -y --only-upgrade ${package_sysname}-documentserver | ||
fi | ||
|
||
NGINX_ROOT_DIR="/etc/nginx" | ||
|
||
NGINX_WORKER_PROCESSES=${NGINX_WORKER_PROCESSES:-$(grep processor /proc/cpuinfo | wc -l)}; | ||
NGINX_WORKER_CONNECTIONS=${NGINX_WORKER_CONNECTIONS:-$(ulimit -n)}; | ||
|
||
sed 's/^worker_processes.*/'"worker_processes ${NGINX_WORKER_PROCESSES};"'/' -i ${NGINX_ROOT_DIR}/nginx.conf | ||
sed 's/worker_connections.*/'"worker_connections ${NGINX_WORKER_CONNECTIONS};"'/' -i ${NGINX_ROOT_DIR}/nginx.conf | ||
|
||
if ! id "nginx" &>/dev/null; then | ||
systemctl stop nginx | ||
|
||
rm -dfr /var/log/nginx/* | ||
rm -dfr /var/cache/nginx/* | ||
useradd -s /bin/false nginx | ||
|
||
systemctl start nginx | ||
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 | ||
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 '^[^;]*') | ||
|
||
expect << EOF || true | ||
set timeout -1 | ||
log_user 1 | ||
spawn apt-get install -y --only-upgrade ${product} elasticsearch=${ELASTIC_VERSION} | ||
expect { | ||
"*** elasticsearch.yml (Y/I/N/O/D/Z)" { | ||
send "\025Y\r" | ||
expect { | ||
"*** jvm.options (Y/I/N/O/D/Z)" { | ||
send "\025Y\r" | ||
} | ||
"/etc/elasticsearch/elasticsearch.yml" {} | ||
} | ||
} | ||
"*** jvm.options (Y/I/N/O/D/Z)" { | ||
send "\025Y\r" | ||
} | ||
} | ||
expect eof | ||
EOF | ||
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" | ||
echo "" |
Oops, something went wrong.