diff options
author | James Meyer <james.meyer@operamail.com> | 2014-09-03 23:10:16 (GMT) |
---|---|---|
committer | James Meyer <james.meyer@operamail.com> | 2014-09-03 23:10:16 (GMT) |
commit | 8bef8020a022c52a8d1d4bb373b5c8cdc256284f (patch) | |
tree | b4ff9cf1c0cbddbc751d93ad18cae4f9b6aaa676 /templates | |
parent | f93d353b9b47120e0ed102342ab4b66f314aff70 (diff) | |
download | linhes_dev-8bef8020a022c52a8d1d4bb373b5c8cdc256284f.zip |
Convert dev chroot to a container.
This was needed to play nice with systemd and the way it mounts /dev/pts inside the chroot as public (breaking the default kernel policy). When public after /dev/pts inside the chroot is unmounted it also unmounts /dev/pts for the host.
Same general steps as before.
- Create new container with ./setup_env_container.sh
- Enter container using ./enter_dev_container.$ARCH.$TS
Diffstat (limited to 'templates')
-rw-r--r-- | templates/container-getty@.service | 26 | ||||
-rwxr-xr-x | templates/developers/jams/custom_chroot.sh | 14 | ||||
-rwxr-xr-x | templates/developers/jams/loginrun.sh | 4 | ||||
-rwxr-xr-x | templates/enter_dev_container.sh | 95 | ||||
-rwxr-xr-x | templates/etc/.bashrc | 3 |
5 files changed, 133 insertions, 9 deletions
diff --git a/templates/container-getty@.service b/templates/container-getty@.service new file mode 100644 index 0000000..3f6d643 --- /dev/null +++ b/templates/container-getty@.service @@ -0,0 +1,26 @@ +# This file is part of systemd. +# +# systemd is free software; you can redistribute it and/or modify it +# under the terms of the GNU Lesser General Public License as published by +# the Free Software Foundation; either version 2.1 of the License, or +# (at your option) any later version. + +[Unit] +Description=Container Getty on /dev/pts/%I +Documentation=man:agetty(8) man:machinectl(1) +After=systemd-user-sessions.service plymouth-quit-wait.service +Before=getty.target +IgnoreOnIsolate=yes + +[Service] +ExecStart=-/sbin/agetty --noclear --keep-baud pts/%I 115200,38400,9600 $TERM +Type=idle +Restart=always +RestartSec=0 +UtmpIdentifier=%I +TTYPath=/dev/%I +TTYReset=yes +TTYVHangup=yes +KillMode=process +IgnoreSIGPIPE=no +SendSIGHUP=yes diff --git a/templates/developers/jams/custom_chroot.sh b/templates/developers/jams/custom_chroot.sh index 75fe866..f8e6bce 100755 --- a/templates/developers/jams/custom_chroot.sh +++ b/templates/developers/jams/custom_chroot.sh @@ -1,11 +1,13 @@ #!/bin/bash -set -x -build_root="../../../../build_root" + +build_root=$BROOT + #copy in the ssh keys -cp -rp /home/jams/.ssh $build_root.${1}/root -chown root.root $build_root.${1}/root/.ssh +cp -rp /home/jams/.ssh $build_root/root +chown -R root.root $build_root/root/.ssh #copy in display -cp display.sh $build_root.${1}/etc/profile.d +cp display.sh $build_root/etc/profile.d + #copy in .gtkrc -cp .gtkrc-2.0 $build_root.${1}/root
\ No newline at end of file +#cp .gtkrc-2.0 $build_root/root diff --git a/templates/developers/jams/loginrun.sh b/templates/developers/jams/loginrun.sh index dbd5d5c..ebe3c94 100755 --- a/templates/developers/jams/loginrun.sh +++ b/templates/developers/jams/loginrun.sh @@ -1,4 +1,4 @@ #!/bin/bash -thunar & -terminal & +#thunar & +#terminal & diff --git a/templates/enter_dev_container.sh b/templates/enter_dev_container.sh new file mode 100755 index 0000000..cd098a6 --- /dev/null +++ b/templates/enter_dev_container.sh @@ -0,0 +1,95 @@ +#!/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
\ No newline at end of file diff --git a/templates/etc/.bashrc b/templates/etc/.bashrc index 9abf8d0..2874bab 100755 --- a/templates/etc/.bashrc +++ b/templates/etc/.bashrc @@ -1,3 +1,4 @@ #!/bin/bash . /etc/profile -. /etc/bashrc +. /etc/bash.bashrc +. /etc/bashrc_linhes |