Skip to content

Commit

Permalink
fix(system:destroy): restructure file
Browse files Browse the repository at this point in the history
  • Loading branch information
s4mpl3d committed May 10, 2024
1 parent 1b8bc78 commit 3d0719c
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 8 deletions.
5 changes: 5 additions & 0 deletions commands/_internals/checkProject.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ function _checkProject() {
_logRed "docker-compose.yml not found"
exit 1
fi
if [ -z $(docker network ls --filter=name=${NETWORK_NAME} -q) ]; then
_logRed "dde network not created. Please run dde system:up"
exit 1
fi

mkdir -p .dde
cp -R ${ROOT_DIR}/helper/configure-image.sh .dde/configure-image.sh
}
17 changes: 9 additions & 8 deletions commands/system/destroy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,17 @@
# system-destroy

function system:destroy() {
if [ -z $(docker network ls --filter=name=${NETWORK_NAME} -q) ]; then
_logRed "Already destroyed"
exit 0
fi

_logRed "Removing containers"
docker rm -f $(docker network inspect -f '{{ range $key, $value := .Containers }}{{ printf "%s\n" $key }}{{ end }}' ${NETWORK_NAME}) &>/dev/null
cd ${ROOT_DIR}
${DOCKER_COMPOSE} down --remove-orphans
${DOCKER_COMPOSE} --project-directory ${ROOT_DIR} down --remove-orphans
docker rm -f $(docker network inspect -f '{{ range $key, $value := .Containers }}{{ printf "%s\n" $key }}{{ end }}' ${NETWORK_NAME}) &>/dev/null || true

_logRed "Removing network if created"
if [ "$(docker network ls --filter=name=${NETWORK_NAME} -q)" != "" ]; then
_logRed "Remove network ${NETWORK_NAME}"
docker network rm ${NETWORK_NAME}
fi
_logRed "Remove network ${NETWORK_NAME}"
docker network rm ${NETWORK_NAME}

_logGreen "Finished destroying successfully"
}
Expand Down
5 changes: 5 additions & 0 deletions commands/system/nuke.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ function system:nuke() {
_logRed "Removing dde sytem"
system:destroy

if [ -z ${DATA_DIR} ]; then
_logRed "DATA_DIR is not defined"
exit 1
fi

_logRed "Removing data"
sudo rm -rf ${DATA_DIR}/*

Expand Down
1 change: 1 addition & 0 deletions helper/generate-vhost-cert.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ DIR=$1
VHOST=$2

# Generate
mkdir -p $DIR
cd $DIR
if [ ! -f $VHOST.crt ]; then \
openssl genrsa -out $VHOST.key 2048 && \
Expand Down

0 comments on commit 3d0719c

Please sign in to comment.