Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
Imldeployment Client
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
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
IML Open Source
Imldeployment Client
Commits
f54bd38a
Commit
f54bd38a
authored
4 years ago
by
Hahn Axel (hahn)
Browse files
Options
Downloads
Patches
Plain Diff
add preinstall cleanup
parent
be7b2c67
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
bin/preinstall_cleanup.sh
+120
-0
120 additions, 0 deletions
bin/preinstall_cleanup.sh
deploy_app.sh
+11
-1
11 additions, 1 deletion
deploy_app.sh
profiles/example/config.sh.dist
+5
-4
5 additions, 4 deletions
profiles/example/config.sh.dist
readme.md
+8
-3
8 additions, 3 deletions
readme.md
with
144 additions
and
8 deletions
bin/preinstall_cleanup.sh
0 → 100755
+
120
−
0
View file @
f54bd38a
#!/bin/bash
# ======================================================================
#
# CLEANUP BEFORE DEPLOYING A TGZ ON A SERVER
#
# ----------------------------------------------------------------------
#
# This script compares the content of a tgz with the data in
# the webroot. Additional files will be deleted
#
# SYNTAX:
# with 2 parameters it show infos only
# preinstall_cleanup.sh /var/www/preview.mmmu.iml.unibe.ch/ /var/puppet-tgz/mmmu.tgz
#
# with (any) 3rd parameter deletion will be activated
# preinstall_cleanup.sh /var/www/preview.mmmu.iml.unibe.ch/ /var/puppet-tgz/mmmu.tgz forcedelete
#
# ----------------------------------------------------------------------
# 2013-11-06 axel.hahn@iml.unibe.ch
# ======================================================================
# ----------------------------------------------------------------------
# CONFIG
# ----------------------------------------------------------------------
prjdir
=
$1
tgz
=
$2
bForceDelete
=
$3
filelist
=
/tmp/keepdirslist_
$$
filetgz
=
/tmp/list_in_tgz_
$$
fileprj
=
/tmp/list_in_webroot_
$$
keepfile
=
".htkeep"
# ----------------------------------------------------------------------
# HEADER
# ----------------------------------------------------------------------
echo
echo
=====
CLEANUP BEFORE DEPLOYING A TGZ
=====
echo
if
[
$#
-lt
2
]
;
then
echo
Syntax is
echo
`
basename
$0
`
[
webroot]
[
tgz-archive]
[[
deleteflag]]
exit
1
fi
# ----------------------------------------------------------------------
# CHECKS
# ----------------------------------------------------------------------
# check $prjdir to prevent deletetion of a complete server
# the directory must exist, must have a subdir "public_html" or
# "public" and a part must be "/www/" (i.e. /var/www/)
cd
$prjdir
||
exit
2
# see #2235 - for nodejs apps the target dir is different
# ls -ld $prjdir/public_html/ || ls -ld $prjdir/public/ || exit 2
# echo $prjdir | fgrep "/www/" || exit 2
ls
-l
$prjdir
/
*
.json
||
exit
2
# check tgz
file
$tgz
| fgrep
"gzip compressed"
||
exit
3
# ----------------------------------------------------------------------
# MAIN
# ----------------------------------------------------------------------
echo
---
scanning
for
$keepfile
in
$prjdir
...
cd
$prjdir
find
.
-type
f
-name
$keepfile
|
sort
|
sed
"s#/
$keepfile
##g"
>
$filelist
ls
-l
$filelist
cat
$filelist
echo
echo
---
scanning archive
$tgz
tar
-tzf
$tgz
|
sed
's#/$##g'
|
sort
>
$filetgz
ls
-l
$filetgz
wc
-l
$filetgz
head
$filetgz
echo
echo
---
scanning web
$prjdir
cd
$prjdir
find
.
-print
|
sort
>
$fileprj
ls
-l
$fileprj
wc
-l
$fileprj
head
$fileprj
echo
echo
---
compare ...
# diff $filetgz $fileprj | grep "^>" | cut -f 2 -d " " | while read delfile
diff
$filetgz
$fileprj
|
grep
"^>"
|
cut
-f
2
-d
" "
|
grep
-vf
$filelist
|
while
read
delfile
do
bDelete
=
1
testfile
=
$delfile
if
[
!
-d
$delfile
]
;
then
testfile
=
`
dirname
$delfile
`
fi
echo
$testfile
| fgrep
-f
$filelist
>
/dev/null
if
[
$?
-eq
0
]
;
then
echo
KEEP:
$delfile
else
if
[
-z
$bForceDelete
]
;
then
echo
WILL-BE-DELETED:
$delfile
else
echo
DELETE:
$delfile
rm
-rf
$delfile
fi
fi
done
# ----------------------------------------------------------------------
# CLEANUP
# ----------------------------------------------------------------------
rm
-f
$filelist
$filetgz
$fileprj
echo
done
.
This diff is collapsed.
Click to expand it.
deploy_app.sh
+
11
−
1
View file @
f54bd38a
...
@@ -112,7 +112,8 @@ if [ $# -eq 0 ]; then
...
@@ -112,7 +112,8 @@ if [ $# -eq 0 ]; then
rc
=
$?
rc
=
$?
profile
=
profile
=
header
"loop over projects is finished"
header
"loop over projects is finished"
exit
$?
echo
exiting with statuscode
$rc
exit
$rc
fi
fi
echo
echo
...
@@ -168,6 +169,15 @@ header "PRE tasks"
...
@@ -168,6 +169,15 @@ header "PRE tasks"
run_task
"
${
profiledir
}
/tasks_preinstall.sh"
run_task
"
${
profiledir
}
/tasks_preinstall.sh"
# ----------------------------------------------------------------------
header
"PRE tasks II - cleanup"
test
"
$cleanup_preview
"
-eq
"1"
||
echo
"SKIP: preview of cleanup is disabled."
test
"
$cleanup_preview
"
-eq
"1"
&&
"
${
selfdir
}
/bin/preinstall_cleanup.sh"
"
${
installdir
}
"
"
${
downloadfile
}
"
test
"
$cleanup_force
"
-eq
"1"
||
echo
"SKIP: cleanup files is disabled."
test
"
$cleanup_force
"
-eq
"1"
&&
"
${
selfdir
}
/bin/preinstall_cleanup.sh"
"
${
installdir
}
"
"
${
downloadfile
}
"
"force"
# ----------------------------------------------------------------------
# ----------------------------------------------------------------------
header
"Extract
${
downloadfile
}
$(
pwd
)
"
header
"Extract
${
downloadfile
}
$(
pwd
)
"
tar
-xzf
"
${
downloadfile
}
"
.
||
exit
3
tar
-xzf
"
${
downloadfile
}
"
.
||
exit
3
...
...
This diff is collapsed.
Click to expand it.
profiles/example/config.sh.dist
+
5
−
4
View file @
f54bd38a
...
@@ -10,9 +10,10 @@ installdir=/var/www/FQDN
...
@@ -10,9 +10,10 @@ installdir=/var/www/FQDN
# ----- settings for CI server software package
# ----- settings for CI server software package
# override global value
IMLCI_PROJECT=example
# export IMLCI_PHASE=preview
#
see output of
#
override global value
export
IMLCI_P
ROJECT=example
#
IMLCI_P
HASE=preview
cleanup_preview=0
cleanup_force=0
\ No newline at end of file
This diff is collapsed.
Click to expand it.
readme.md
+
8
−
3
View file @
f54bd38a
...
@@ -46,11 +46,16 @@ installdir=/var/www/myapp
...
@@ -46,11 +46,16 @@ installdir=/var/www/myapp
# ----- settings for CI server software package
# ----- settings for CI server software package
IMLCI_PROJECT=id-in-ci-server
# override global value
# override global value
#
export
IMLCI_PHASE=preview
# IMLCI_PHASE=preview
# see output of
# cleanup after pre install tasks and bevore extracting data
export IMLCI_PROJECT=id-in-ci-server
# set both to 0 .. or only one of them to 1
cleanup_preview=0
cleanup_force=0
```
```
Make a testrun:
`./deploy_app.sh`
in application root.
Make a testrun:
`./deploy_app.sh`
in application root.
...
...
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