summaryrefslogtreecommitdiffstats
path: root/templates/enter_dev_container.sh
diff options
context:
space:
mode:
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