ajout fonction pour sed_in_place a travers podman unshare

This commit is contained in:
Gitouche 2023-07-28 16:24:51 +02:00
parent 7f48f4b300
commit 884e85cca2

View file

@ -44,15 +44,20 @@ ensure_systemd_as_user_dir_exists () {
# sed or die trying
sed_in_place () {
grep -q "${1}" "${3}"
${podman_unshare} grep -q "${1}" "${3}"
if [ $? -eq 0 ]; then
sed -i -e "s|${1}|${2}|g" ${3}
${podman_unshare} sed -i -e "s|${1}|${2}|g" ${3}
else
echo "Pattern ${1} not found in file ${3}, exiting."
exit 1
fi
}
podman_unshare_sed_in_place () {
podman_unshare='podman unshare'
sed_in_place "${1}" "${2}" "${3}"
}
# check: systemd unit exists
check_systemd_unit_exists () {
systemctl --user cat -- ${1} &> /dev/null