Skip to content

Commit

Permalink
Add a delete option to the OCI docker (#67)
Browse files Browse the repository at this point in the history
Co-authored-by: Evgeniy Antonyuk <[email protected]>
Reviewed-on: https://git.onlyoffice.com/ONLYOFFICE/DocSpace-buildtools/pulls/67
Reviewed-by: Evgeniy Antonyuk <[email protected]>
Co-authored-by: Valeria Bagisheva <[email protected]>
Co-committed-by: Valeria Bagisheva <[email protected]>
  • Loading branch information
lemmav and evgeniy-antonyuk committed Nov 26, 2024
1 parent 7053464 commit 61760d6
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 8 deletions.
4 changes: 2 additions & 2 deletions install/OneClickInstall/install-Debian.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ while [ "$1" != "" ]; do
fi
;;

-un | --uninstall )
-uni | --uninstall )
if [ "$2" != "" ]; then
UNINSTALL=$2
shift
Expand Down Expand Up @@ -115,7 +115,7 @@ while [ "$1" != "" ]; do
echo " Parameters:"
echo " -it, --installation_type installation type (community|developer|enterprise)"
echo " -u, --update use to update existing components (true|false)"
echo " -un, --uninstall uninstall existing installation (true|false)"
echo " -uni, --uninstall uninstall existing installation (true|false)"
echo " -je, --jwtenabled specifies the enabling the JWT validation (true|false)"
echo " -jh, --jwtheader defines the http header that will be used to send the JWT"
echo " -js, --jwtsecret defines the secret key to validate the JWT in the request"
Expand Down
50 changes: 46 additions & 4 deletions install/OneClickInstall/install-Docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ INSTALL_ELASTICSEARCH="true";
INSTALL_FLUENT_BIT="true";
INSTALL_PRODUCT="true";
UPDATE="false";

UNINSTALL="false";
HUB="";
USERNAME="";
PASSWORD="";
Expand Down Expand Up @@ -500,7 +500,15 @@ while [ "$1" != "" ]; do
shift
fi
;;


-uni | --uninstall)
if [ "$2" != "" ]; then
UNINSTALL=$2
shift
fi

;;

-off | --offline )
if [ "$2" != "" ]; then
OFFLINE_INSTALLATION=$2
Expand Down Expand Up @@ -564,6 +572,7 @@ while [ "$1" != "" ]; do
echo " -noni, --noninteractive auto confirm all questions (true|false)"
echo " -dbm, --databasemigration database migration (true|false)"
echo " -ms, --makeswap make swap file (true|false)"
echo " -uni, --uninstall uninstall existing installation (true|false)"
echo " -?, -h, --help this help"
echo
echo " Install all the components without document server:"
Expand Down Expand Up @@ -593,6 +602,39 @@ while [ "$1" != "" ]; do
shift
done

uninstall() {
read -p "Uninstall all dependencies (mysql, opensearch and others)? (Y/n): " REMOVE_DATA_SERVICES

if [[ "${REMOVE_DATA_SERVICES,,}" =~ ^(y|yes)?$ ]]; then
SERVICES=("db" "rabbitmq" "redis" "opensearch" "dashboards" "fluent")
fi

SERVICES+=("${PRODUCT}" "ds" "identity" "proxy" "healthchecks" "notify" "migration-runner")

for SERVICE in "${SERVICES[@]}"; do
if [[ -f "$BASE_DIR/$SERVICE.yml" ]]; then
echo "Uninstallation of $SERVICE and its volumes..."
docker-compose -f "$BASE_DIR/$SERVICE.yml" down -v || echo "Failed to remove $SERVICE."
fi
done

docker network rm "${NETWORK_NAME}" 2>/dev/null && NETWORK_REMOVED=true || echo "Failed to remove network ${NETWORK_NAME}."


read -p "Do you want to retain data (keep .env file)? (Y/n): " KEEP_DATA

if [[ "$NETWORK_REMOVED" == "true" && -d "$BASE_DIR" ]]; then
if [[ "${KEEP_DATA,,}" =~ ^(y|yes)?$ ]]; then
find "$BASE_DIR" -mindepth 1 ! -name ".env" -exec rm -rf {} +
else
rm -rf "$BASE_DIR" || echo "Failed to remove directory $BASE_DIR."
fi
fi

echo -e "Uninstallation of $PRODUCT_NAME" \
"$( [[ "${REMOVE_DATA_SERVICES,,}" =~ ^(y|yes)?$ ]] && echo "and all dependencies" ) \e[32mcompleted.\e[0m"
}

root_checking () {
PID=$$
if [ ! $( id -u ) -eq 0 ]; then
Expand Down Expand Up @@ -1191,7 +1233,7 @@ install_mysql_server () {
reconfigure MYSQL_ROOT_PASSWORD ${MYSQL_ROOT_PASSWORD}

if [[ -z ${MYSQL_HOST} ]] && [ "$INSTALL_MYSQL_SERVER" == "true" ]; then
docker-compose -f $BASE_DIR/db.yml up -d
docker-compose -f $BASE_DIR/db.yml up -d --force-recreate
elif [ "$INSTALL_MYSQL_SERVER" == "pull" ]; then
docker-compose -f $BASE_DIR/db.yml pull
fi
Expand Down Expand Up @@ -1528,4 +1570,4 @@ start_installation () {
exit 0;
}

start_installation
[[ $UNINSTALL != true ]] && start_installation || uninstall
4 changes: 2 additions & 2 deletions install/OneClickInstall/install-RedHat.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ while [ "$1" != "" ]; do
fi
;;

-un | --uninstall )
-uni | --uninstall )
if [ "$2" != "" ]; then
UNINSTALL=$2
shift
Expand Down Expand Up @@ -124,7 +124,7 @@ while [ "$1" != "" ]; do
echo " Parameters:"
echo " -it, --installation_type installation type (community|developer|enterprise)"
echo " -u, --update use to update existing components (true|false)"
echo " -un, --uninstall uninstall existing installation (true|false)"
echo " -uni, --uninstall uninstall existing installation (true|false)"
echo " -je, --jwtenabled specifies the enabling the JWT validation (true|false)"
echo " -jh, --jwtheader defines the http header that will be used to send the JWT"
echo " -js, --jwtsecret defines the secret key to validate the JWT in the request"
Expand Down

0 comments on commit 61760d6

Please sign in to comment.