Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
W
Warden - archive
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
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
713
Warden
Warden - archive
Commits
262ff7d0
Commit
262ff7d0
authored
11 years ago
by
Tomáš Plesník
Browse files
Options
Downloads
Patches
Plain Diff
aplha 1: port na warden-server-2.2; zapracovany poznamky z Auditu shellovych skriptu
parent
474f5e1f
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/warden-server/sh/uninstall.sh
+91
-85
91 additions, 85 deletions
src/warden-server/sh/uninstall.sh
with
91 additions
and
85 deletions
src/warden-server/sh/uninstall.sh
+
91
−
85
View file @
262ff7d0
...
@@ -4,23 +4,25 @@
...
@@ -4,23 +4,25 @@
#
#
# Copyright (C) 2011-2013 Cesnet z.s.p.o
# Copyright (C) 2011-2013 Cesnet z.s.p.o
#
#
# Use of this source is governed by a BSD-style license, see LICENSE file.
VERSION
=
"2.1"
VERSION
=
"2.2"
#-------------------------------------------------------------------------------
#-------------------------------------------------------------------------------
#
FUNCTIONS
#
Script functions
#-------------------------------------------------------------------------------
#-------------------------------------------------------------------------------
usage
()
usage
()
{
{
echo
"Usage:
`
basename
$0
`
[-d <directory>] [-hV]"
echo
"Usage:
${
0
##*/
}
-d <directory> [-s <directory>] [-hV]"
echo
"-d <directory> uninstallation directory (default: /opt)"
echo
"-d <directory> uninstallation directory of Warden server"
echo
"-s <directory> directory for symlinks to Warden server control scripts (optional)"
echo
"-h print this help"
echo
"-h print this help"
echo
"-V print script version number and exit"
echo
"-V print script version number and exit"
echo
echo
echo
"Example:
# ./
`
basename
$0
`
-
d
/
opt
"
echo
"Example:
$
${
0
##*/
}
-d /opt/warden-server
-
s
/
usr/local/bin
"
echo
echo
echo
"Note: You must be root for running this script."
echo
"For more information about uninstallation process, see README file (section Uninstallation)."
echo
" For more information about uninstallation process, see README file (section Uninstallation)."
echo
echo
exit
0
exit
0
}
}
...
@@ -28,7 +30,7 @@ usage()
...
@@ -28,7 +30,7 @@ usage()
version
()
version
()
{
{
echo
"
`
basename
${
0
}
`
- current version is
$VERSION
"
echo
"
${
0
##*/
}
- current version is
$VERSION
"
exit
0
exit
0
}
}
...
@@ -36,8 +38,9 @@ version()
...
@@ -36,8 +38,9 @@ version()
err
()
err
()
{
{
echo
"FAILED!"
echo
"FAILED!"
cat
$err
cat
"
$err
"
rm
-rf
$err
$backup_dir
rm
-f
"
$err
"
rm
-rf
"
$backup
"
echo
echo
echo
"Uninstallation of
$package_version
package FAILED!!!"
echo
"Uninstallation of
$package_version
package FAILED!!!"
exit
1
exit
1
...
@@ -47,55 +50,43 @@ err()
...
@@ -47,55 +50,43 @@ err()
errClean
()
errClean
()
{
{
echo
"FAILED!"
echo
"FAILED!"
echo
" -> Reverting changes of warden server package ... OK"
echo
" -> Reverting changes of warden server package ... "
rm
-rf
${
server_path
}
/
*
>
/dev/null 2>&1
# delete new version
rm
-rf
"
${
basedir
}
/"
*
>
/dev/null 2>&1
cp
-R
${
backup_dir
}
/
*
$server_path
# copy old backuped server
cp
-R
"
${
backup
}
/"
*
"
$basedir
"
for
file
in
`
ls
-1
$bin
`
if
[[
!
-z
"
$symbin
"
]]
&&
[[
-d
"
$symbin
"
]]
&&
[[
-w
"
$symbin
"
]]
;
then
do
for
file
in
"
${
bin
}
/"
*
ln
-s
${
bin
}
/
$file
${
local_bin
}
/
$file
# create symlinks to /usr/local/bin
do
done
ln
-s
"
${
bin
}
/
${
file
##*/
}
"
"
${
symbin
}
/
${
file
##*/
}
"
cat
$err
done
rm
-rf
$err
$backup_dir
fi
cat
"
$err
"
rm
-f
"
$err
"
rm
-rf
"
$backup
"
echo
echo
echo
"Uninstallation of
$package_version
package FAILED!!!"
echo
"Uninstallation of
$package_version
package FAILED!!!"
exit
1
exit
1
}
}
rootChck
()
{
if
[
$UID
-ne
0
]
;
then
echo
"You must be root for running this script!"
exit
1
fi
}
paramsChck
()
paramsChck
()
{
{
if
[
-z
$prefix
]
;
then
if
[
-z
"
$basedir
"
]
;
then
echo
"Parameter -d <directory> is not set!"
echo
"Parameter -d <directory> is not set!"
exit
1
exit
1
fi
fi
}
}
obtainPackageVersion
()
#-------------------------------------------------------------------------------
{
# Uninstallation functions
if
[
-f
$old_package_version_file
]
;
then
#-------------------------------------------------------------------------------
package_version
=
`
cat
$old_package_version_file
`
else
package_version
=
"unknown"
fi
}
wardenDirChck
()
wardenDirChck
()
{
{
echo
-n
"Checking Warden server directory ... "
echo
-n
"Checking Warden server directory ... "
if
[
!
-d
$server_path
]
;
then
if
[
[
!
-d
"
$basedir
"
]]
&&
[[
!
-w
"
$basedir
"
]
]
;
then
echo
"FAILED!"
echo
"FAILED!"
ls
$server_path
echo
"No version of Warden server is not installed!"
exit
1
exit
1
else
else
echo
"OK"
echo
"OK"
...
@@ -103,11 +94,24 @@ wardenDirChck()
...
@@ -103,11 +94,24 @@ wardenDirChck()
}
}
backup
()
getPackageVersion
()
{
{
echo
-n
"Backing-up Warden server directory ... "
echo
-n
"Checking Warden server version ... "
mkdir
$backup_dir
old_package_version_file
=
$(
find
"
$basedir
"
-name
package_version
)
if
cp
-R
${
server_path
}
/
*
$backup_dir
2>
$err
;
then
if
[
-f
"
$old_package_version_file
"
]
;
then
package_version
=
$(
<
"
$old_package_version_file
"
)
else
package_version
=
"unknown"
fi
echo
"OK"
}
createBackup
()
{
echo
-n
"Creating Warden server backup ... "
[[
-d
"
$backup
"
]]
&&
rm
-rf
"
$backup
"
||
mkdir
"
$backup
"
if
cp
-R
"
${
basedir
}
/"
*
"
$backup
"
2>
"
$err
"
;
then
echo
"OK"
echo
"OK"
else
else
err
err
...
@@ -115,87 +119,89 @@ backup()
...
@@ -115,87 +119,89 @@ backup()
}
}
deleteSymlinks
()
uninstallWardenServer
()
{
{
echo
-n
"Deleting symlinks from /usr/local/bin ..."
echo
-n
"Uninstalling
$package_version
package ... "
for
file
in
`
ls
-1
$bin
`
cp
"
${
doc
}
/UNINSTALL"
"
$uninstall
"
manifest
=
$(
find
"
$basedir
"
-name
MANIFEST
)
||
err
for
file
in
$(
<
"
$manifest
"
)
do
do
rm
-rf
${
local_bin
}
/
$file
2> /dev/null
directory
=
"
${
file
%/*
}
"
rm
-f
"
${
basedir
}
/
$file
"
rmdir
--ignore-fail-on-non-empty
"
${
basedir
}
/
$directory
"
done
done
rm
-f
"
${
basedir
}
/uninstall.sh"
rmdir
--ignore-fail-on-non-empty
"
$basedir
"
echo
"OK"
echo
"OK"
}
}
uninstallWardenServer
()
deleteSymlinks
()
{
{
echo
-n
"Uninstalling
$package_version
package ... "
echo
-n
"Deleting symlinks from
$symbin
..."
cp
${
doc
}
/UNINSTALL
$uninstall_file
for
file
in
"
$symbin
/"
*
if
rm
-rf
$server_path
2>
$err
;
then
do
echo
"OK"
rm
-f
"
${
symbin
}
/
${
file
##*/
}
"
2> /dev/null
else
done
errClean
echo
"OK"
fi
}
}
#-------------------------------------------------------------------------------
#-------------------------------------------------------------------------------
# MAIN
# MAIN
#-------------------------------------------------------------------------------
#-------------------------------------------------------------------------------
# read input
# read input
while
getopts
"d:Vh"
options
;
do
while
getopts
"d:s:Vh"
options
;
do
case
$options
in
case
"
$options
"
in
d
)
prefix
=
$OPTARG
;;
d
)
basedir
=
"
$OPTARG
"
;;
s
)
symbin
=
"
$OPTARG
"
;;
h
)
usage
;;
h
)
usage
;;
V
)
version
;;
V
)
version
;;
*
)
usage
;;
*
)
usage
;;
esac
esac
done
done
# r
oot t
es
t
# r
emove last char (slash) from name of directori
es
rootChck
[[
"
$basedir
"
==
*
/
]]
&&
basedir
=
"
${
basedir
%?
}
"
# params test
# params test
paramsChck
paramsChck
# create variables
# set variables
[[
$prefix
==
*
/
]]
&&
prefix
=
"
${
prefix
%?
}
"
# remove last char (slash) from prefix
bin
=
"
${
basedir
}
/bin"
dirname
=
`
dirname
$0
`
etc
=
"
${
basedir
}
/etc"
server_path
=
"
${
prefix
}
/warden-server"
doc
=
"
${
basedir
}
/doc"
bin
=
"
${
server_path
}
/bin"
local_bin
=
"/usr/local/bin"
etc
=
"
${
server_path
}
/etc"
doc
=
"
${
server_path
}
/doc"
uninstall_file
=
"/tmp/UNINSTALL.warden"
old_package_version_file
=
"
${
etc
}
/package_version"
err
=
"/tmp/warden-err"
err
=
"/tmp/warden-err"
backup_dir
=
"/tmp/warden-backup"
uninstall
=
"/tmp/UNINSTALL.warden"
backup
=
"/tmp/warden-backup"
# obtain version of installed warden-server package
obtainPackageVersion
echo
echo
echo
"------------------------- Uninstallation process --------------------------------"
echo
"------------------------- Uninstallation process --------------------------------"
# check
if $prefix/w
arden
-
server directory exist
# check
W
arden
server directory
if
exist
s
wardenDirChck
wardenDirChck
#
make backup of currently installed w
arden
-
server
package
#
obtain version of existing W
arden
server
(if exists)
backup
getPackageVersion
#
delete symbolic links
#
make backup of currently installed warden-server package
deleteSymlinks
createBackup
#
do
uninstall
ation
# uninstall
Warden server
uninstallWardenServer
uninstallWardenServer
# delete symlinks from $symbin (if -s option is set)
[[
!
-z
"
$symbin
"
]]
&&
[[
-d
"
$symbin
"
]]
&&
[[
-w
"
$symbin
"
]]
&&
deleteSymlinks
echo
echo
echo
"Please follow post-uninstallation steps in
$uninstall
_file
!"
echo
"Please follow post-uninstallation steps in
$uninstall
!"
echo
echo
echo
"Uninstallation of
$package_version
package was SUCCESSFUL!"
echo
"Uninstallation of
$package_version
package was SUCCESSFUL!
!!
"
echo
echo
# cleanup section
# cleanup section
rm
-rf
$err
$backup_dir
rm
-r
"
$err
"
rm
-rf
"
$backup
"
exit
0
exit
0
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