#!/bin/bash # A LinHES development script to start container #--------- #container_name='linhes_build_root_x86_64' container_name='linhes_container_root.REPLACE_ARCH.REPLACE_TS' container_dir=$(pwd) dev_tools='linhes_dev' package_build_dir='linhes_pkgbuild' repo_base_dir='pkg_repo' repo_base_dir_source='../pkg_repo' templates="$dev_tools/templates" #-------- copy_files(){ if [ ! -f $container_name/etc/profile.d/kmdev.sh ] then echo " Missing kmdev.sh, copy in setup files" cp -f $templates/etc/.bashrc $container_name/root/.bashrc cp -f $templates/etc/.bash_profile $container_name/root/ cp -f $templates/etc/bashrc $container_name/etc/bashrc_linhes cp -f $templates/etc/kmdev.sh $container_name/etc/profile.d/ chmod 0755 $container_name/etc/profile.d/kmdev.sh cp -f $templates/container-getty\@.service $container_name/etc/systemd/system/ grep -q pts $container_name/etc/securetty rc=$? if [ ! $rc -eq 0 ] then for i in `seq 5` do echo pts\/$i >> $container_name/etc/securetty done fi fi } pre_checks(){ # must be root: if [ $EUID -ne 0 ] then echo -e "Must be run as the root user" 1>&2 exit 1 fi # must have the chroot subdirectory: if [ ! -d $BROOT ] then echo $BROOT directory not found fi } main(){ pre_checks #copy in linhes files copy_files #Start container #check for to see if start it with nspawn or machinectl login machinectl list | grep -q $container_name rc=$? if [ $rc -eq 0 ] then echo "Trying machinectl" machinectl login $container_name else systemd-nspawn -bD $container_name\ --bind=$container_dir/$package_build_dir:/data/$package_build_dir \ --bind=$container_dir/$dev_tools/build_tools:/build_tools \ --bind=$container_dir/$repo_base_dir_source:/data/$repo_base_dir fi } main