Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
S
script-repo
Project
Project
Details
Activity
Releases
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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Alynna Trypnotk
script-repo
Commits
145424c7
Commit
145424c7
authored
Feb 26, 2020
by
root
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add mkoverlay
parent
8bb30efe
Pipeline
#32
failed with stages
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
60 additions
and
0 deletions
+60
-0
mkoverlay
mkoverlay
+60
-0
No files found.
mkoverlay
0 → 100755
View file @
145424c7
#!/bin/bash
if
[
"
$1
"
=
""
]
;
then
cat
<<
EOF
mkoverlay [_corezone] [targetzone] [copyopts]
Converts a flat dir zone to an overlay zone based on the specified core zone.
EOF
exit
0
fi
COREZONE
=
""
if
[
"
$2
"
!=
""
]
;
then
COREZONE
=
$1
shift
fi
if
[
"
$COREZONE
"
!=
""
]
;
then
zone start
$COREZONE
||
true
inzones
$COREZONE
"apt -y update; apt -y upgrade"
zone stop
$COREZONE
||
true
fi
zone start
$1
;
sleep
1
||
true
inzones
$1
"apt -y update; apt -y upgrade"
zone stop
$1
;
sleep
1
||
true
cp
-avu
/zone/
$1
/. /zone/
${
1
}
.bak/
zfs umount Z/zone/
$1
zfs list
-t
all
rm
-rf
/zone/
$1
if
[
"
$COREZONE
"
=
""
]
;
then
lxc-destroy
-l
DEBUG
-fs
-n
$1
;
sleep
1
||
true
zfs destroy
-R
$(
zfs list
-t
snapshot |
grep
@
$1
|
cut
-d
' '
-f1
)
||
true
lxc-create
-l
DEBUG
-n
$1
-B
zfs
-t
none
;
sleep
1
||
true
zfs create
-o
mountpoint
=
/zone/
$1
/rootfs Z/zone/
$1
||
true
lxc-stop
-l
DEBUG
-n
$1
||
true
else
lxc-destroy
-l
DEBUG
-fs
-n
$1
;
sleep
1
||
true
zfs destroy
-R
$(
zfs list
-t
snapshot |
grep
@
$1
|
cut
-d
' '
-f1
)
||
true
lxc-copy
-l
DEBUG
-n
$COREZONE
-N
$1
-p
/zone/
-B
zfs
-s
if
[
$?
-ne
0
]
;
then
mv
/zone/
${
1
}
.bak /zone/
$1
exit
1
fi
lxc-stop
-l
DEBUG
-n
$1
||
true
fi
zfs mount Z/zone/
$1
mkdir
-p
/opt/zone/
$1
sed
-i
"s/=
\/
zone
\/
/= zfs:
\/
zone
\/
/"
/zone/
$1
/config
sed
-i
"s/dir:
\/
zone
\/
/zfs:
\/
zone
\/
/"
/zone/
$1
/config
sed
-i
"s/zone
\/\@
/zone
\/\_
/"
/zone/
$1
/config
zone start
$1
rsync
-av
--progress
/zone/
$1
.bak/rootfs/. /zone/
$1
/rootfs/
cp
-v
/zone/
$1
.bak/
*
/zone/
$1
/
zone restart
$1
echo
""
echo
"Verify the functionality of the zone, then"
echo
" rm -rf /zone/
$1
.bak"
echo
"if you are satisfied."
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