Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
LakeDropsDrupalDev
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Model registry
Monitor
Service Desk
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Docker
LakeDropsDrupalDev
Commits
1d64069b
Commit
1d64069b
authored
4 years ago
by
jurgenhaas
Browse files
Options
Downloads
Patches
Plain Diff
#84
Allow to delete multiple projects at once
parent
9fc5baf0
No related branches found
Branches containing commit
Tags
v2.3.0
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
run/scripts/delete
+25
-12
25 additions, 12 deletions
run/scripts/delete
with
25 additions
and
12 deletions
run/scripts/delete
+
25
−
12
View file @
1d64069b
#!/bin/bash
function
removecontainer
()
{
docker container
ls
--all
-q
-f
name
=
^
${
PROJECT
}
_
>
/tmp/reset.lst
docker container
ls
--all
-q
-f
name
=
^
${
PROJECT
}
_
>
/tmp/reset.lst
IDS
=
$(
cat
/tmp/reset.lst
)
if
[[
!
-n
${
IDS
}
]]
;
then
echo
"No containers to be removed."
return
fi
echo
"Deleting containers ..."
for
CONTAINERID
in
`
cat
/tmp/reset.lst
`
;
do
for
CONTAINERID
in
$(
cat
/tmp/reset.lst
)
;
do
docker
rm
-f
$CONTAINERID
done
rm
/tmp/reset.lst
...
...
@@ -25,21 +25,34 @@ function removenetwork() {
if
[[
-f
"docker-compose.yml"
]]
;
then
sed
-i
-e
"/-
${
PROJECT
}
$/
d"
docker-compose.yml
sed
-i
-e
"/^
${
PROJECT
}
:
$/
{N;d;}"
docker-compose.yml
docker-compose stop
docker
rm
-f
traefik_traefik_1
docker network
rm
traefik_
${
PROJECT
}
docker-compose
--project-name
traefik up
-d
NETWORKS
=
"
${
NETWORKS
}
traefik_
${
PROJECT
}
"
fi
}
function
rebuildtraefik
()
{
cd
${
HOME
}
/.traefik
||
return
if
[[
-f
"docker-compose.yml"
]]
;
then
docker-compose
--project-name
traefik up
-d
--remove-orphans
fi
if
[[
"
$NETWORKS
"
==
""
]]
;
then
return
fi
docker network
rm
${
NETWORKS
}
}
if
[[
-n
$1
]]
;
then
PROJECT
=
$1
NETWORKS
=
""
while
[[
-n
$1
]]
;
do
PROJECT
=
$1
read
-p
"Are you sure you want to remove the project
${
PROJECT
}
with all containers and network? Type YES to confirm: "
CONFIRM
if
[[
"
$CONFIRM
"
==
YES
]]
;
then
removecontainer
removenetwork
fi
shift
done
rebuildtraefik
else
echo
"Please provide the project name you want to delete."
exit
fi
read
-p
"Are you sure you want to remove the project
${
PROJECT
}
with all containers and network? Type YES to confirm: "
CONFIRM
if
[[
"
$CONFIRM
"
==
YES
]]
;
then
removecontainer
removenetwork
fi
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment