mrrl-logincaps

MRRL version of logincaps
git clone https://ccx.te2000.cz/git/mrrl-logincaps
Log | Files | Refs

commit a196d0835522cb12713588a46f3f04191463b523
parent 1628c6a80ebf4a6a9a6bbd438408dd275243027e
Author: Jan Pobrislo <ccx@webprojekty.cz>
Date:   Fri, 18 Dec 2020 07:41:36 +0100

Helper scripts for linking between containers.
Diffstat:
Abin/link-to-container-inbox | 26++++++++++++++++++++++++++
1 file changed, 26 insertions(+), 0 deletions(-)

diff --git a/bin/link-to-container-inbox b/bin/link-to-container-inbox @@ -0,0 +1,26 @@ +#!/bin/zsh + +# usage: src_container dst_container path/to/file [path/to/another ...] + +setopt no_unset no_chase_links + +(( $# >= 3 )) || exit 100 +src_container=$1 +dst_container=$2 +shift 2 || exit 100 +[[ -z $src_container || $src_container == */* ]] && exit 100 +[[ -z $dst_container || $dst_container == */* ]] && exit 100 + +containers_dir=/run/containers + +for f in "$@"; do + src=$containers_dir/$src_container/${f#/} + [[ $src == ${src:a} ]] || exit 100 # check for non-canonical path (eg. containing ../) + dst=$containers_dir/$dst_container/inbox/$src_container/$f + mkdir -p ${dst:h} || exit $? + if [[ -d $dst ]]; then + rm -rf $dst || exit $? + fi + cd -s ${src:h} || exit $? # should fail if there is a symlink in the path + ln -f ./${src:t} $dst || exit $? +done