2024-03-20 21:05:51 +00:00
|
|
|
function addProfileStatement() {
|
|
|
|
name="$1";
|
|
|
|
title="$2";
|
|
|
|
shellBin="$3";
|
|
|
|
profileRoot="$4";
|
|
|
|
|
2024-03-25 00:22:36 +00:00
|
|
|
if [ ! -z "${@:5}" ]
|
2024-03-20 21:05:51 +00:00
|
|
|
then
|
|
|
|
statement="${@:5}";
|
2024-03-25 00:22:36 +00:00
|
|
|
else
|
|
|
|
statement="$(cat)";
|
2024-03-20 21:05:51 +00:00
|
|
|
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";
|
|
|
|
}
|