28 lines
498 B
Bash
28 lines
498 B
Bash
|
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";
|
||
|
}
|