on master help sign in
LXC: add /.lxcenv
d2cfe9cMarkus Heiser
utils/lib.sh+18−5
@@ -1065,18 +1065,31 @@ EOF
1065in_container() {
1065in_container() {
1066 # Test if shell runs in a container.
1066 # Test if shell runs in a container.
1067 #
1067 #
1068− # hint: Reads init process environment, therefore root access is required!
1069− #
1070 # usage: in_container && echo "process running inside a LXC container"
1068 # usage: in_container && echo "process running inside a LXC container"
1071 # in_container || echo "process is not running inside a LXC container"
1069 # in_container || echo "process is not running inside a LXC container"
1072 #
1070 #
1073−
1074− sudo_or_exit
1071+ # sudo_or_exit
1072+ # hint: Reads init process environment, therefore root access is required!
1075 # to be safe, take a look at the environment of process 1 (/sbin/init)
1073 # to be safe, take a look at the environment of process 1 (/sbin/init)
1076− grep -qa 'container=lxc' /proc/1/environ
1074+ # grep -qa 'container=lxc' /proc/1/environ
1075+
1076+ # see lxc_init_container
1077+ [[ -f /.lxcenv ]]
1077}
1078}
1078
1079
1080+lxc_init_container() {
1079
1081
1082+ # Create a /.lxcenv file in the root folder. Call this once after container
1083+ # is inital started.
1084+
1085+ # usage: lxc_create_root_dot_lxcenv <name>
1086+
1087+ info_msg "create /.lxcenv in container $1"
1088+ cat <<EOF | lxc exec "${1}" -- bash | prefix_stdout "[${_BBlue}${1}${_creset}] "
1089+touch "/.lxcenv"
1090+ls -l "/.lxcenv"
1091+EOF
1092+}
1080lxc_exists(){
1093lxc_exists(){
1081
1094
1082 # usage: lxc_exists <name> || echo "container <name> does not exists"
1095 # usage: lxc_exists <name> || echo "container <name> does not exists"
utils/lxc-searx.env+1
@@ -51,6 +51,7 @@ lxc_suite_prepare_buildhost() {
51 (
51 (
52 lxc_set_suite_env
52 lxc_set_suite_env
53 export FORCE_TIMEOUT=0
53 export FORCE_TIMEOUT=0
54+ # "${LXC_REPO_ROOT}/utils/searx.sh* install packages
54 "${LXC_REPO_ROOT}/utils/searx.sh" install buildhost
55 "${LXC_REPO_ROOT}/utils/searx.sh" install buildhost
55 rst_title "buildhost installation finished ($(hostname))" part
56 rst_title "buildhost installation finished ($(hostname))" part
56 echo
57 echo
utils/lxc.sh+4−2
@@ -82,7 +82,7 @@ usage::
82 $_cmd [start|stop] [containers|<name>]
82 $_cmd [start|stop] [containers|<name>]
83 $_cmd show [info|config|suite|images]
83 $_cmd show [info|config|suite|images]
84 $_cmd cmd [--|<name>] '...'
84 $_cmd cmd [--|<name>] '...'
85− $_cmd install [suite]
85+ $_cmd install [suite|buildhost]
86
86
87build
87build
88 :containers: build & launch all LXC containers of the suite
88 :containers: build & launch all LXC containers of the suite
@@ -443,10 +443,12 @@ lxc_boilerplate_containers() {
443 boilerplate_script="${image_name}_boilerplate"
443 boilerplate_script="${image_name}_boilerplate"
444 boilerplate_script="${!boilerplate_script}"
444 boilerplate_script="${!boilerplate_script}"
445
445
446− info_msg "[${_BBlue}${container_name}${_creset}] install /.lxcenv.mk .."
446+ info_msg "[${_BBlue}${container_name}${_creset}] init .."
447 if lxc start -q "${container_name}" &>/dev/null; then
447 if lxc start -q "${container_name}" &>/dev/null; then
448 sleep 5 # guest needs some time to come up and get an IP
448 sleep 5 # guest needs some time to come up and get an IP
449 fi
449 fi
450+ lxc_init_container "${container_name}"
451+ info_msg "[${_BBlue}${container_name}${_creset}] install /.lxcenv.mk .."
450 cat <<EOF | lxc exec "${container_name}" -- bash | prefix_stdout "[${_BBlue}${container_name}${_creset}] "
452 cat <<EOF | lxc exec "${container_name}" -- bash | prefix_stdout "[${_BBlue}${container_name}${_creset}] "
451rm -f "/.lxcenv.mk"
453rm -f "/.lxcenv.mk"
452ln -s "${LXC_REPO_ROOT}/utils/makefile.lxc" "/.lxcenv.mk"
454ln -s "${LXC_REPO_ROOT}/utils/makefile.lxc" "/.lxcenv.mk"