summaryrefslogtreecommitdiffstats
path: root/templates/enter_dev_container.sh
diff options
context:
space:
mode:
authorJames Meyer <james.meyer@operamail.com>2014-09-03 23:10:16 (GMT)
committerJames Meyer <james.meyer@operamail.com>2014-09-03 23:10:16 (GMT)
commit8bef8020a022c52a8d1d4bb373b5c8cdc256284f (patch)
treeb4ff9cf1c0cbddbc751d93ad18cae4f9b6aaa676 /templates/enter_dev_container.sh
parentf93d353b9b47120e0ed102342ab4b66f314aff70 (diff)
downloadlinhes_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/enter_dev_container.sh')
-rwxr-xr-xtemplates/enter_dev_container.sh95
1 files changed, 95 insertions, 0 deletions
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