change names and location of rc scripts
This commit is contained in:
44
to_system/home/l_samenv/.config/linse_setuser
Normal file
44
to_system/home/l_samenv/.config/linse_setuser
Normal file
@@ -0,0 +1,44 @@
|
||||
function setuser() {
|
||||
if [[ $# -eq 0 ]]; then
|
||||
cat << EOF
|
||||
|
||||
Usage:
|
||||
setuser <personal linux username>
|
||||
|
||||
set author for git commit and get gitea token from linse-c if available
|
||||
|
||||
EOF
|
||||
if [[ ! -z "$LC_IDENTIFICATION" ]]; then
|
||||
local id=($LC_IDENTIFICATION)
|
||||
echo "you are already identified as ${id[@]:2:9} <${id[1]}>"
|
||||
echo " "
|
||||
fi
|
||||
return 1
|
||||
fi
|
||||
local isuser=$(ssh l_samenv@linse-c "test -d ~$1 && echo OK" 2>/dev/null)
|
||||
if [[ "$isuser" == "OK" ]]; then
|
||||
local id=($LC_IDENTIFICATION)
|
||||
echo " "
|
||||
if [[ ! -z "$id" ]]; then
|
||||
echo "you are already identified as: ${id[@]:2:9} <${id[1]}> - you may press ctrl-c to abort"
|
||||
fi
|
||||
echo "get token from $1@linse-c"
|
||||
export LC_IDENTIFICATION=$(ssh $1@linse-c 'echo $LC_IDENTIFICATION' 2>/dev/null)
|
||||
if [[ -z "$LC_IDENTIFICATION" ]]; then
|
||||
echo "LC_IDENTIFICATION is not defined in your rc file on $1@linse-c"
|
||||
else
|
||||
local id=($LC_IDENTIFICATION)
|
||||
echo "you are identified as ${id[@]:2:9} <${id[1]}>"
|
||||
fi
|
||||
echo " "
|
||||
else
|
||||
host=($(hostname -A))
|
||||
export GIT_AUTHOR_NAME="$1"
|
||||
export GIT_AUTHOR_EMAIL="$1@$host"
|
||||
echo " "
|
||||
echo "$1 is no valid linux user on linse-c -> not gitea token available for git push"
|
||||
echo " "
|
||||
echo "however, you are identified as $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL> for git commit"
|
||||
echo " "
|
||||
fi
|
||||
}
|
||||
Reference in New Issue
Block a user