IF YOU WOULD LIKE TO GET AN ACCOUNT, please write an email to s dot adaszewski at gmail dot com. User accounts are meant only to report issues and/or generate pull requests. This is a purpose-specific Git hosting for ADARED projects. Thank you for your understanding!
Pārlūkot izejas kodu

Add --non-interactive switch to focker bootstrap.

master
Stanislaw Adaszewski pirms 4 gadiem
vecāks
revīzija
f51e35d3f8
6 mainītis faili ar 221 papildinājumiem un 6 dzēšanām
  1. +2
    -0
      .gitignore
  2. +9
    -4
      focker/bootstrap.py
  3. +1
    -0
      focker/focker.py
  4. +68
    -0
      scripts/focker-bsdinstall
  5. +139
    -0
      scripts/focker-mirrorselect
  6. +2
    -2
      setup.py

+ 2
- 0
.gitignore Parādīt failu

@@ -8,3 +8,5 @@ __pycache__
/example/gitea/x
.pytest_cache/
.coverage
/scripts/jail
/scripts/focker-bsdinstall.not-needed

+ 9
- 4
focker/bootstrap.py Parādīt failu

@@ -7,6 +7,8 @@ from .zfs import zfs_poolname, \
def command_bootstrap(args):
if args.empty and args.non_interactive:
raise ValueError('--empty and --non-interactive are mutually exclusive')
version = subprocess.check_output(['freebsd-version']).decode('utf-8')
print('FreeBSD version:', version)
tags = args.tags or [ 'freebsd-' + version.split('-')[0], 'freebsd-latest' ]
@@ -15,10 +17,13 @@ def command_bootstrap(args):
name = find_prefix(poolname + '/focker/images/', sha256)
subprocess.check_output(['zfs', 'create', '-o', 'focker:sha256=' + sha256, name])
zfs_tag(name, tags)
if not args.empty:
res = None
if args.non_interactive:
res = subprocess.run(['focker-bsdinstall', zfs_mountpoint(name)])
elif not args.empty:
res = subprocess.run(['bsdinstall', 'jail', zfs_mountpoint(name)])
if res.returncode != 0:
zfs_run(['zfs', 'destroy', '-r', '-f', name])
raise ValueError('bsdinstall failed')
if res is not None and res.returncode != 0:
zfs_run(['zfs', 'destroy', '-r', '-f', name])
raise ValueError('bsdinstall failed')
subprocess.check_output(['zfs', 'set', 'rdonly=on', name])
subprocess.check_output(['zfs', 'snapshot', name + '@1'])

+ 1
- 0
focker/focker.py Parādīt failu

@@ -82,6 +82,7 @@ def create_parser():
parser.set_defaults(func=command_bootstrap)
parser.add_argument('--tags', '-t', type=str, nargs='+', default=None)
parser.add_argument('--empty', '-e', action='store_true')
parser.add_argument('--non-interactive', '-ni', action='store_true')
# image
subparsers = ListForwarder([ subparsers_top.add_parser(cmd).add_subparsers(dest='L2_command') \


+ 68
- 0
scripts/focker-bsdinstall Parādīt failu

@@ -0,0 +1,68 @@
#!/bin/sh

if [ -z "$1" ]; then
echo "Usage: focker-bsdinstall chroot_dir"
exit 1
fi

BSDCFG_SHARE="/usr/share/bsdconfig"
. $BSDCFG_SHARE/common.subr || exit 1

: ${BSDINSTALL_TMPETC="/tmp/bsdinstall_etc"}; export BSDINSTALL_TMPETC
: ${BSDINSTALL_TMPBOOT="/tmp/bsdinstall_boot"}; export BSDINSTALL_TMPBOOT
: ${PATH_FSTAB="$BSDINSTALL_TMPETC/fstab"}; export PATH_FSTAB
: ${BSDINSTALL_DISTDIR="/usr/freebsd-dist"}; export BSDINSTALL_DISTDIR
: ${BSDINSTALL_CHROOT="/mnt"}; export BSDINSTALL_CHROOT

echo "Began Installation at" "$( date )"
export BSDINSTALL_CHROOT=$1

error() {
if [ -n "$1" ]; then
echo "$1" >&2
fi
exit $FAILURE
}

rm -rf $BSDINSTALL_TMPETC
mkdir $BSDINSTALL_TMPETC
mkdir -p $1 || error "mkdir failed for $1"

test ! -d $BSDINSTALL_DISTDIR && mkdir -p $BSDINSTALL_DISTDIR

# echo "BSDINSTALL_DISTDIR: $BSDINSTALL_DISTDIR"
# exit

export DISTRIBUTIONS="base.txz"

FETCH_DISTRIBUTIONS=""
for dist in $DISTRIBUTIONS; do
if [ ! -f $BSDINSTALL_DISTDIR/$dist ]; then
FETCH_DISTRIBUTIONS="$FETCH_DISTRIBUTIONS $dist"
fi
done
FETCH_DISTRIBUTIONS=`echo $FETCH_DISTRIBUTIONS` # Trim white space

if [ -n "$FETCH_DISTRIBUTIONS" -a -z "$BSDINSTALL_DISTSITE" ]; then
BSDINSTALL_DISTSITE=`focker-mirrorselect`
export BSDINSTALL_DISTSITE
fi

if [ ! -z "$FETCH_DISTRIBUTIONS" ]; then
bsdinstall distfetch || error "Failed to fetch distribution"
fi

bsdinstall checksum || error "Distribution checksum failed"
bsdinstall distextract || error "Distribution extract failed"
# bsdinstall rootpass || error "Could not set root password"
echo "Setting random root password ..."
openssl rand -base64 8 | md5 | head -c32 | chroot "$BSDINSTALL_CHROOT" pw user mod root -h 0

bsdinstall config || error "Failed to save config"
cp /etc/resolv.conf $1/etc
cp /etc/localtime $1/etc

bsdinstall entropy

echo "Installation Completed at" "$(date)"
exit $SUCCESS

+ 139
- 0
scripts/focker-mirrorselect Parādīt failu

@@ -0,0 +1,139 @@
#!/bin/sh

MIRROR1=ftp://ftp.freebsd.org
MIRROR2=ftp://ftp.freebsd.org
MIRROR3=ftp://ftp3.ie.freebsd.org
MIRROR4=ftp://ftp2.jp.freebsd.org
MIRROR5=ftp://ftp4.se.freebsd.org
MIRROR6=ftp://ftp4.us.freebsd.org
MIRROR7=ftp://ftp2.tr.freebsd.org
MIRROR8=ftp://ftp1.freebsd.org
MIRROR9=ftp://ftp2.freebsd.org
MIRROR10=ftp://ftp3.freebsd.org
MIRROR11=ftp://ftp4.freebsd.org
MIRROR12=ftp://ftp5.freebsd.org
MIRROR13=ftp://ftp6.freebsd.org
MIRROR14=ftp://ftp7.freebsd.org
MIRROR15=ftp://ftp10.freebsd.org
MIRROR16=ftp://ftp11.freebsd.org
MIRROR17=ftp://ftp12.freebsd.org
MIRROR18=ftp://ftp13.freebsd.org
MIRROR19=ftp://ftp14.freebsd.org
MIRROR20=ftp://ftp1.am.freebsd.org
MIRROR21=ftp://ftp.au.freebsd.org
MIRROR22=ftp://ftp2.au.freebsd.org
MIRROR23=ftp://ftp3.au.freebsd.org
MIRROR24=ftp://ftp.at.freebsd.org
MIRROR25=ftp://ftp2.br.freebsd.org
MIRROR26=ftp://ftp3.br.freebsd.org
MIRROR27=ftp://ftp4.br.freebsd.org
MIRROR28=ftp://ftp.ca.freebsd.org
MIRROR29=ftp://ftp.cn.freebsd.org
MIRROR30=ftp://ftp.cz.freebsd.org
MIRROR31=ftp://ftp.dk.freebsd.org
MIRROR32=ftp://ftp.ee.freebsd.org
MIRROR33=ftp://ftp.fi.freebsd.org
MIRROR34=ftp://ftp.fr.freebsd.org
MIRROR35=ftp://ftp3.fr.freebsd.org
MIRROR36=ftp://ftp4.fr.freebsd.org
MIRROR37=ftp://ftp5.fr.freebsd.org
MIRROR38=ftp://ftp6.fr.freebsd.org
MIRROR39=ftp://ftp7.fr.freebsd.org
MIRROR40=ftp://ftp8.fr.freebsd.org
MIRROR41=ftp://ftp.de.freebsd.org
MIRROR42=ftp://ftp2.de.freebsd.org
MIRROR43=ftp://ftp4.de.freebsd.org
MIRROR44=ftp://ftp5.de.freebsd.org
MIRROR45=ftp://ftp6.de.freebsd.org
MIRROR46=ftp://ftp7.de.freebsd.org
MIRROR47=ftp://ftp8.de.freebsd.org
MIRROR48=ftp://ftp.gr.freebsd.org
MIRROR49=ftp://ftp2.gr.freebsd.org
MIRROR50=ftp://ftp3.ie.freebsd.org
MIRROR51=ftp://ftp.il.freebsd.org
MIRROR52=ftp://ftp.it.freebsd.org
MIRROR53=ftp://ftp.jp.freebsd.org
MIRROR54=ftp://ftp2.jp.freebsd.org
MIRROR55=ftp://ftp3.jp.freebsd.org
MIRROR56=ftp://ftp4.jp.freebsd.org
MIRROR57=ftp://ftp5.jp.freebsd.org
MIRROR58=ftp://ftp6.jp.freebsd.org
MIRROR59=ftp://ftp7.jp.freebsd.org
MIRROR60=ftp://ftp8.jp.freebsd.org
MIRROR61=ftp://ftp9.jp.freebsd.org
MIRROR62=ftp://ftp.kr.freebsd.org
MIRROR63=ftp://ftp2.kr.freebsd.org
MIRROR64=ftp://ftp.lv.freebsd.org
MIRROR65=ftp://ftp.lt.freebsd.org
MIRROR66=ftp://ftp.nl.freebsd.org
MIRROR67=ftp://ftp2.nl.freebsd.org
MIRROR68=ftp://ftp.nz.freebsd.org
MIRROR69=ftp://ftp.no.freebsd.org
MIRROR70=ftp://ftp.pl.freebsd.org
MIRROR71=ftp://ftp2.pl.freebsd.org
MIRROR72=ftp://ftp.ru.freebsd.org
MIRROR73=ftp://ftp2.ru.freebsd.org
MIRROR74=ftp://ftp4.ru.freebsd.org
MIRROR75=ftp://ftp5.ru.freebsd.org
MIRROR76=ftp://ftp6.ru.freebsd.org
MIRROR77=ftp://ftp.sk.freebsd.org
MIRROR78=ftp://ftp2.sk.freebsd.org
MIRROR79=ftp://ftp.si.freebsd.org
MIRROR80=ftp://ftp.za.freebsd.org
MIRROR81=ftp://ftp2.za.freebsd.org
MIRROR82=ftp://ftp4.za.freebsd.org
MIRROR83=ftp://ftp.es.freebsd.org
MIRROR84=ftp://ftp3.es.freebsd.org
MIRROR85=ftp://ftp.se.freebsd.org
MIRROR86=ftp://ftp2.se.freebsd.org
MIRROR87=ftp://ftp3.se.freebsd.org
MIRROR88=ftp://ftp4.se.freebsd.org
MIRROR89=ftp://ftp6.se.freebsd.org
MIRROR90=ftp://ftp.ch.freebsd.org
MIRROR91=ftp://ftp.tw.freebsd.org
MIRROR92=ftp://ftp2.tw.freebsd.org
MIRROR93=ftp://ftp3.tw.freebsd.org
MIRROR94=ftp://ftp4.tw.freebsd.org
MIRROR95=ftp://ftp6.tw.freebsd.org
MIRROR96=ftp://ftp11.tw.freebsd.org
MIRROR97=ftp://ftp.uk.freebsd.org
MIRROR98=ftp://ftp2.uk.freebsd.org
MIRROR99=ftp://ftp3.uk.freebsd.org
MIRROR100=ftp://ftp4.uk.freebsd.org
MIRROR101=ftp://ftp5.uk.freebsd.org
MIRROR102=ftp://ftp.ua.freebsd.org
MIRROR103=ftp://ftp7.ua.freebsd.org
MIRROR104=ftp://ftp1.us.freebsd.org
MIRROR105=ftp://ftp2.us.freebsd.org
MIRROR106=ftp://ftp3.us.freebsd.org
MIRROR107=ftp://ftp4.us.freebsd.org
MIRROR108=ftp://ftp5.us.freebsd.org
MIRROR109=ftp://ftp6.us.freebsd.org
MIRROR110=ftp://ftp8.us.freebsd.org
MIRROR111=ftp://ftp10.us.freebsd.org
MIRROR112=ftp://ftp11.us.freebsd.org
MIRROR113=ftp://ftp13.us.freebsd.org
MIRROR114=ftp://ftp14.us.freebsd.org
MIRROR115=ftp://ftp15.us.freebsd.org

x=`jot -r 1 1 115`
# echo $x
x=MIRROR${x}
eval MIRROR=\$${x}

_UNAME_R=`uname -r`
_UNAME_R=${_UNAME_R%-p*}

case ${_UNAME_R} in
*-CURRENT|*-STABLE|*-PRERELEASE)
RELDIR="snapshots"
;;
*)
RELDIR="releases"
;;
esac

BSDINSTALL_DISTSITE="$MIRROR/pub/FreeBSD/${RELDIR}/`uname -m`/`uname -p`/${_UNAME_R}"
export BSDINSTALL_DISTSITE

echo $BSDINSTALL_DISTSITE

+ 2
- 2
setup.py Parādīt failu

@@ -2,7 +2,7 @@ from distutils.core import setup
setup(
name='focker',
version='0.91',
version='0.95',
author='Stanislaw Adaszewski',
author_email='s.adaszewski@gmail.com',
url='https://github.com/sadaszewski/focker',
@@ -10,7 +10,7 @@ setup(
license='The GNU General Public License v3.0',
description='Focker is a FreeBSD image orchestration tool in the vein of Docker.',
long_description='Focker is a FreeBSD image orchestration tool in the vein of Docker.',
scripts=['scripts/focker'],
scripts=['scripts/focker', 'scripts/focker-bsdinstall', 'scripts/focker-mirrorselect'],
install_requires=[
"tabulate",
"jailconf",


Notiek ielāde…
Atcelt
Saglabāt