@@ -78,11 +78,10 @@ usage::
79 $_cmd build [containers]
79 $_cmd build [containers]
80 $_cmd copy [images]
80 $_cmd copy [images]
81− $_cmd remove [containers|<name>|images|subordinate]
81+ $_cmd remove [containers|<name>|images]
82− $_cmd add [subordinate]
83 $_cmd [start|stop] [containers|<name>]
82 $_cmd [start|stop] [containers|<name>]
84 $_cmd show [info|config|suite|images]
83 $_cmd show [info|config|suite|images]
85− $_cmd cmd [--|<name>] ...
84+ $_cmd cmd [--|<name>] '...'
86 $_cmd install [suite]
85 $_cmd install [suite]
@@ -92,8 +91,6 @@ copy:
93 :containers: delete all 'containers' or only <container-name>
92 :containers: delete all 'containers' or only <container-name>
94 :images: delete local images of the suite
93 :images: delete local images of the suite
96− :subordinate: LXD permission to map ${HOST_USER}'s user/group id through
98 :containers: start/stop all 'containers' from the suite
95 :containers: start/stop all 'containers' from the suite
99 :<name>: start/stop conatiner <name> from suite
96 :<name>: start/stop conatiner <name> from suite
@@ -103,8 +100,9 @@ show
103 :suite: show services of all the containers from the LXC suite
100 :suite: show services of all the containers from the LXC suite
104 :images: show information of local images
101 :images: show information of local images
103+ use single qoutes to evaluate in container's bash, e.g. 'echo $(hostname)'
106− -- run command ... in all containers of the LXC suite
104+ -- run command '...' in all containers of the LXC suite
107− :<name>: run command ... in container <name>
105+ :<name>: run command '...' in container <name>
109 :suite: install LXC suite, includes morty & filtron
107 :suite: install LXC suite, includes morty & filtron
@@ -176,7 +174,6 @@ main() {
176 case $2 in
174 case $2 in
177 ''|containers) remove_instances ;;
175 ''|containers) remove_instances ;;
178 images) lxc_delete_images_localy ;;
176 images) lxc_delete_images_localy ;;
179− subordinate) echo; del_subordinate_ids ;;
180 ${LXC_HOST_PREFIX}-*)
177 ${LXC_HOST_PREFIX}-*)
181 ! lxc_exists "$2" && usage_containers "unknown container: $2" && exit 42
178 ! lxc_exists "$2" && usage_containers "unknown container: $2" && exit 42
182 if ask_yn "Do you really want to delete conatiner $2"; then
179 if ask_yn "Do you really want to delete conatiner $2"; then
@@ -186,13 +183,6 @@ main() {
186 *) usage "uknown or missing container <name> $2"; exit 42;;
183 *) usage "uknown or missing container <name> $2"; exit 42;;
192− subordinate) echo; add_subordinate_ids ;;
193− *) usage "$_usage"; exit 42;;
196 start|stop)
186 start|stop)
197 sudo_or_exit
187 sudo_or_exit
198 case $2 in
188 case $2 in
@@ -274,7 +264,6 @@ main() {
274build_instances() {
264build_instances() {
275 rst_title "Build LXC instances"
265 rst_title "Build LXC instances"
278 lxc_copy_images_localy
267 lxc_copy_images_localy
280 rst_title "build containers" section
269 rst_title "build containers" section
@@ -400,7 +389,7 @@ lxc_exec_cmd() {
401 exit_val=
390 exit_val=
402 info_msg "[${_BBlue}${name}${_creset}] ${_BGreen}${*}${_creset}"
391 info_msg "[${_BBlue}${name}${_creset}] ${_BGreen}${*}${_creset}"
403− lxc exec --cwd "${LXC_REPO_ROOT}" "${name}" -- "$@"
392+ lxc exec --cwd "${LXC_REPO_ROOT}" "${name}" -- bash -c "$*"
404 exit_val=$?
393 exit_val=$?
405 if [[ $exit_val -ne 0 ]]; then
394 if [[ $exit_val -ne 0 ]]; then
406 warn_msg "[${_BBlue}${name}${_creset}] exit code (${_BRed}${exit_val}${_creset}) from ${_BGreen}${*}${_creset}"
395 warn_msg "[${_BBlue}${name}${_creset}] exit code (${_BRed}${exit_val}${_creset}) from ${_BGreen}${*}${_creset}"
@@ -435,7 +424,7 @@ lxc_config_containers() {
436 info_msg "[${_BBlue}${i}${_creset}] map uid/gid from host to container"
425 info_msg "[${_BBlue}${i}${_creset}] map uid/gid from host to container"
437 # https://lxd.readthedocs.io/en/latest/userns-idmap/#custom-idmaps
426 # https://lxd.readthedocs.io/en/latest/userns-idmap/#custom-idmaps
438− echo -e -n "uid $HOST_USER_ID 1000\\ngid $HOST_GROUP_ID 1000"\
427+ echo -e -n "uid $HOST_USER_ID 0\\ngid $HOST_GROUP_ID 0"\
439 | lxc config set "$i" raw.idmap -
428 | lxc config set "$i" raw.idmap -
441 info_msg "[${_BBlue}${i}${_creset}] share ${REPO_ROOT} (repo_share) from HOST into container"
430 info_msg "[${_BBlue}${i}${_creset}] share ${REPO_ROOT} (repo_share) from HOST into container"
@@ -475,48 +464,6 @@ lxc_boilerplate_containers() {
481−# see man: subgid(5), subuid(5), https://lxd.readthedocs.io/en/latest/userns-idmap
483−# E.g. in the HOST you have uid=1001(user) and/or gid=1001(user) ::
494−add_subordinate_ids() {
495− if grep "root:${HOST_USER_ID}:1" /etc/subuid -qs; then
496− info_msg "lxd already has permission to map ${HOST_USER_ID}'s user/group id through"
498− info_msg "add lxd permission to map ${HOST_USER_ID}'s user/group id through"
499− usermod --add-subuids "${HOST_USER_ID}-${HOST_USER_ID}" \
500− --add-subgids "${HOST_GROUP_ID}-${HOST_GROUP_ID}" root
504−del_subordinate_ids() {
507− if grep "root:${HOST_USER_ID}:1" /etc/subuid -qs; then
508− # TODO: root user is always in use by process 1, how can we remove subordinates?
509− info_msg "remove lxd permission to map ${HOST_USER_ID}'s user/group id through"
510− out=$(usermod --del-subuids "${HOST_USER_ID}-${HOST_USER_ID}" --del-subgids "${HOST_GROUP_ID}-${HOST_GROUP_ID}" root 2>&1)
512− if [ $exit_val -ne 0 ]; then
516− info_msg "lxd does not have permission to map ${HOST_USER_ID}'s user/group id through"
521# ----------------------------------------------------------------------------
468# ----------------------------------------------------------------------------