Add an abstract script for adding profile settings

This commit is contained in:
Manuel Thalmann 2024-03-20 22:05:51 +01:00
commit b81b034287
2 changed files with 32 additions and 21 deletions
scripts/Common/Scripts

View file

@ -0,0 +1,27 @@
function addProfileStatement() {
name="$1";
title="$2";
shellBin="$3";
profileRoot="$4";
if [ -t 1 ]
then
statement="$(cat)";
else
statement="${@:5}";
fi;
contextRoot="$(mktemp -d)";
pushd "$contextRoot" > /dev/null;
{
echo '#!'"$shellBin";
echo "# $title";
echo "$statement";
} > "profile.sh";
sudo install -Dm755 profile.sh "$profileRoot/$name.sh"
popd > /dev/null;
rm -rf "$contextRoot";
}