mirror of
https://codeberg.org/scip/jaildk.git
synced 2025-12-16 20:21:05 +01:00
added -v and -b to reinstall command
This commit is contained in:
18
README.md
18
README.md
@@ -350,8 +350,9 @@ Next create a new base version:
|
||||
```
|
||||
jaildk base -b `uname -r`
|
||||
```
|
||||
But of course you can update a jail with the current base as well.
|
||||
|
||||
Now you can create clone of your jail with a new version:
|
||||
Now you can clone of your jail with a new version:
|
||||
```
|
||||
jaildk clone -s myjail -d myjail -o 20201106 -n 20210422
|
||||
```
|
||||
@@ -368,9 +369,20 @@ pkg update
|
||||
...
|
||||
```
|
||||
|
||||
The last step is to remove the current running jail, change the version in `etc/myjail.conf`, install and start the new version.
|
||||
The last step is to remove the current running jail, change the
|
||||
version in `etc/myjail.conf`, install and start the new version. This
|
||||
can be easily done with the following command:
|
||||
```
|
||||
jaildk reinstall myjail -b `uname -r` -v 20210422
|
||||
```
|
||||
|
||||
If there's anything wrong you can always go back to the previous version using the above steps.
|
||||
This command also creates a copy of the current jail.conf.
|
||||
|
||||
If there's anything wrong you can always go back to the previous
|
||||
version using the following command (using the previous base and version):
|
||||
```
|
||||
jaildk reinstall myjail -b 12.2-RELEASE-p1 -v 20201106
|
||||
```
|
||||
|
||||
## Advanced Features
|
||||
|
||||
|
||||
47
jaildk
47
jaildk
@@ -1,6 +1,6 @@
|
||||
#!/bin/sh
|
||||
|
||||
version=1.12
|
||||
version=1.13
|
||||
|
||||
usage_jaildk() {
|
||||
beg=`tput -T ${TERM:-cons25} md`
|
||||
@@ -21,7 +21,8 @@ ${beg}Installing Jails:${end}
|
||||
install <jail> <mode> [-r function] - install a jail (prepare mounts, devfs etc)
|
||||
uninstall <jail> [-w] - uninstall a jail
|
||||
remove <jail> - remove a jail or a jail version
|
||||
reinstall <jail> - stop, remove, install and start a jail
|
||||
reinstall <jail> [-b <base>] [-v <version>] - stop, remove, install and start a jail, if
|
||||
-b and/or -v is set, update the jail config
|
||||
|
||||
${beg}Maintaining Jails:${end}
|
||||
start <jail> - start a jail
|
||||
@@ -1219,13 +1220,26 @@ jaildk_login() {
|
||||
}
|
||||
|
||||
usage_reinstall() {
|
||||
fin "Usage: $0 reinstall <jail>
|
||||
Stop, uninstall, install and start <jail>.
|
||||
fin "Usage: $0 reinstall <jail> [-b <base>] [-v <version>]
|
||||
Stop, uninstall, install and start <jail>. If <base> and/or
|
||||
<version> is given, modify the jail config before reinstalling.
|
||||
"
|
||||
}
|
||||
|
||||
jaildk_reinstall() {
|
||||
jail=$1
|
||||
shift
|
||||
|
||||
NEWBASE=''
|
||||
NEWVERSION=''
|
||||
|
||||
while getopts "b:v:" arg; do
|
||||
case $arg in
|
||||
b) NEWBASE=${OPTARG};;
|
||||
v) NEWVERSION=${OPTARG};;
|
||||
*) usage_reinstall;;
|
||||
esac
|
||||
done
|
||||
|
||||
if test -z "$jail"; then
|
||||
usage_reinstall
|
||||
@@ -1242,6 +1256,31 @@ jaildk_reinstall() {
|
||||
sleep 0.2
|
||||
sync
|
||||
|
||||
if test -n "$NEWBASE" -o -n "$NEWVERSION"; then
|
||||
load-jail-config $jail
|
||||
ts=`date +%Y%m%d%H%M`
|
||||
change=''
|
||||
if test $NEWBASE != $base; then
|
||||
base=$NEWBASE
|
||||
change=1
|
||||
fi
|
||||
|
||||
if test $NEWVERSION != $version; then
|
||||
version=$NEWVERSION
|
||||
change=1
|
||||
fi
|
||||
|
||||
if test -n "$change"; then
|
||||
bold "Saving current $jail config"
|
||||
ex cp -p $j/etc/$jail/jail.conf $j/etc/$jail/jail.conf-$ts
|
||||
|
||||
bold "Creating new $jail config"
|
||||
cat $j/etc/$jail/jail.conf-$ts \
|
||||
| sed -e "s/^base=.*/base=$base/" -e "s/^version=.*/version=$version/" \
|
||||
> $j/etc/$jail/jail.conf
|
||||
fi
|
||||
fi
|
||||
|
||||
jaildk_install $jail start
|
||||
jaildk_jail start $jail
|
||||
|
||||
|
||||
Reference in New Issue
Block a user