2024-03-20 21:05:51 +00:00
|
|
|
function addProfileStatement() {
|
|
|
|
name="$1";
|
|
|
|
title="$2";
|
|
|
|
shellBin="$3";
|
2024-03-25 17:07:40 +00:00
|
|
|
extension="$4";
|
|
|
|
profileRoot="$5";
|
2024-03-20 21:05:51 +00:00
|
|
|
|
2024-03-25 17:07:40 +00:00
|
|
|
if [ ! -z "${@:6}" ]
|
2024-03-20 21:05:51 +00:00
|
|
|
then
|
2024-03-25 17:07:40 +00:00
|
|
|
statement="${@:6}";
|
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";
|
2024-03-25 17:07:40 +00:00
|
|
|
} > "profile.$extension";
|
2024-03-20 21:05:51 +00:00
|
|
|
|
2024-03-25 17:07:40 +00:00
|
|
|
sudo install -Dm755 profile.$extension "$profileRoot/$name.$extension"
|
2024-03-20 21:05:51 +00:00
|
|
|
|
|
|
|
popd > /dev/null;
|
|
|
|
rm -rf "$contextRoot";
|
|
|
|
}
|