@@ -78,11 +78,10 @@ usage::
7878
7979 $_cmd build [containers]
8080 $_cmd copy [images]
81− $_cmd remove [containers|<name>|images|subordinate]
82− $_cmd add [subordinate]
81+ $_cmd remove [containers|<name>|images]
8382 $_cmd [start|stop] [containers|<name>]
8483 $_cmd show [info|config|suite|images]
85− $_cmd cmd [--|<name>] ...
84+ $_cmd cmd [--|<name>] '...'
8685 $_cmd install [suite]
8786
8887build
@@ -92,8 +91,6 @@ copy:
9291remove
9392 :containers: delete all 'containers' or only <container-name>
9493 :images: delete local images of the suite
95−add / remove
96− :subordinate: LXD permission to map ${HOST_USER}'s user/group id through
9794start/stop
9895 :containers: start/stop all 'containers' from the suite
9996 :<name>: start/stop conatiner <name> from suite
@@ -103,8 +100,9 @@ show
103100 :suite: show services of all the containers from the LXC suite
104101 :images: show information of local images
105102cmd
106− -- run command ... in all containers of the LXC suite
107− :<name>: run command ... in container <name>
103+ use single qoutes to evaluate in container's bash, e.g. 'echo $(hostname)'
104+ -- run command '...' in all containers of the LXC suite
105+ :<name>: run command '...' in container <name>
108106install
109107 :suite: install LXC suite, includes morty & filtron
110108
@@ -176,7 +174,6 @@ main() {
176174 case $2 in
177175 ''|containers) remove_instances ;;
178176 images) lxc_delete_images_localy ;;
179− subordinate) echo; del_subordinate_ids ;;
180177 ${LXC_HOST_PREFIX}-*)
181178 ! lxc_exists "$2" && usage_containers "unknown container: $2" && exit 42
182179 if ask_yn "Do you really want to delete conatiner $2"; then
@@ -186,13 +183,6 @@ main() {
186183 *) usage "uknown or missing container <name> $2"; exit 42;;
187184 esac
188185 ;;
189− add)
190− sudo_or_exit
191− case $2 in
192− subordinate) echo; add_subordinate_ids ;;
193− *) usage "$_usage"; exit 42;;
194− esac
195− ;;
196186 start|stop)
197187 sudo_or_exit
198188 case $2 in
@@ -274,7 +264,6 @@ main() {
274264build_instances() {
275265 rst_title "Build LXC instances"
276266 echo
277− add_subordinate_ids
278267 lxc_copy_images_localy
279268 echo
280269 rst_title "build containers" section
@@ -400,7 +389,7 @@ lxc_exec_cmd() {
400389 shift
401390 exit_val=
402391 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 "$*"
404393 exit_val=$?
405394 if [[ $exit_val -ne 0 ]]; then
406395 warn_msg "[${_BBlue}${name}${_creset}] exit code (${_BRed}${exit_val}${_creset}) from ${_BGreen}${*}${_creset}"
@@ -435,7 +424,7 @@ lxc_config_containers() {
435424
436425 info_msg "[${_BBlue}${i}${_creset}] map uid/gid from host to container"
437426 # 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"\
439428 | lxc config set "$i" raw.idmap -
440429
441430 info_msg "[${_BBlue}${i}${_creset}] share ${REPO_ROOT} (repo_share) from HOST into container"
@@ -475,48 +464,6 @@ lxc_boilerplate_containers() {
475464 done
476465}
477466
478−# subordinates
479−# ------------
480−#
481−# see man: subgid(5), subuid(5), https://lxd.readthedocs.io/en/latest/userns-idmap
482−#
483−# E.g. in the HOST you have uid=1001(user) and/or gid=1001(user) ::
484−#
485−# root:1001:1
486−#
487−# in the CONTAINER::
488−#
489−# config:
490−# raw.idmap: |
491−# uid 1001 1000
492−# gid 1001 1000
493−
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"
497− else
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
501− fi
502−}
503−
504−del_subordinate_ids() {
505− local out
506− local exit_val
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)
511− exit_val=$?
512− if [ $exit_val -ne 0 ]; then
513− err_msg "$out"
514− fi
515− else
516− info_msg "lxd does not have permission to map ${HOST_USER_ID}'s user/group id through"
517− fi
518−}
519−
520467
521468# ----------------------------------------------------------------------------
522469main "$@"