Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
etersoft-admin-essentials
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
etersoft
etersoft-admin-essentials
Commits
153ecd6f
You need to sign in or sign up before continuing.
Commit
153ecd6f
authored
Aug 17, 2016
by
Danil Mikhailov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
create-vz-template added
parent
24d5f54f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
62 additions
and
0 deletions
+62
-0
create-vz-template.sh
vz/create-vz-template.sh
+62
-0
No files found.
vz/create-vz-template.sh
0 → 100755
View file @
153ecd6f
#!/bin/bash
# Создание vz template из контейнера
VZDIR
=
"/var/lib/vz"
VZPRIVATEDIR
=
"
$VZDIR
/private"
TEMPLATEDIR
=
"
$VZDIR
/template/cache"
SCRIPTNAME
=
"
$(
basename
$0
)
"
VERBOSE
=
"true"
RETVAL
=
1
archive_vz
(){
vzid
=
"
$1
"
diskdesc
=
"
${
VZPRIVATEDIR
}
/
${
vzid
}
/root.hdd/DiskDescriptor.xml"
# Если есть второй аргумент, то это имя template
if
!
[
-n
"
$2
"
]
;
then
templatename
=
"
${
vzid
}
"
.tar.gz
else
templatename
=
"
${
2
}
"
.tar.gz
fi
# Монтируем если используется ploop
if
[
-e
"
$diskdesc
"
]
;
then
mountdir
=
"/mnt/
${
vzid
}
"
mkdir
-p
${
mountdir
}
mount
-t
ploop
"
$diskdesc
"
${
mountdir
}
&&
\
tar
--numeric-owner
-czf
"
${
TEMPLATEDIR
}
/
${
templatename
}
"
-C
"
${
mountdir
}
/"
.
else
tar
--numeric-owner
-czf
"
${
TEMPLATEDIR
}
/
${
templatename
}
"
-C
"
${
VZPRIVATEDIR
}
/
$vzid
/"
.
fi
RETVAL
=
"
$?
"
}
my_getopts
(){
if
!
[
-n
"
$1
"
]
||
[
"
$1
"
==
"--help"
]
||
[
"
$1
"
==
"-h"
]
;
then
help
return
1
fi
archive_vz
$@
&&
my_exit
"Template from
$vzid
created:
${
TEMPLATEDIR
}
/
${
templatename
}
"
||
my_exit
"Error! Template not created."
}
help
(){
example
=
etersoft-p8-20160527-systemd-x86_64
echo
"
$SCRIPTNAME
<vz container id> [template name]"
echo
"Create vz template from vz container."
echo
""
echo
"Example: # ./
${
SCRIPTNAME
}
800
$example
"
echo
"Creates template from 800 container and copy it to
$TEMPLATEDIR
/
$example
"
.tar.gz
my_exit
}
my_exit
(){
$VERBOSE
&&
echo
"
$1
"
exit
$RETVAL
}
my_getopts
$@
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment