PortValhalla/scripts/Common/Scripts/profile-base.sh

29 lines
551 B
Bash
Raw Normal View History

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