introduce 'to_home' and systemd user services

- frappy is now a systemd user service
- add 'frappy' and 'boxweb' bash function
This commit is contained in:
2025-05-28 11:54:21 +02:00
parent 1a6b133afa
commit 99580aad78
5 changed files with 134 additions and 82 deletions

12
to_home/.bash_profile Normal file
View File

@ -0,0 +1,12 @@
# helper for adding to PATH without duplicates
pathadd() {
if [ -d "$1" ] && [[ ":$PATH:" != *":$1:"* ]]; then
PATH="${PATH:+"$PATH:"}$1"
fi
}
pathadd ~/bin
pathadd ~/.local/bin
pathadd ~/frappy/bin
. ~/.config/linse_profile

View File

@ -0,0 +1,13 @@
alias dir='ls -alF'
export EDITOR=nano
. ~/.config/linse_setuser
function gitea_git() (
for repo in "$@"; do
cd ~/$repo
scp -q -r -o BatchMode=yes -o StrictHostKeyChecking=no l_samenv@linse-c:gitea/hooks .git/
grep -q 'https://gitea.psi.ch' .git/config || git remote set-url origin https://gitea.psi.ch/linse/${repo}.git
grep -q "$PWD/.git/hooks/get_gitea_token" .git/config || git config credential.helper "$PWD/.git/hooks/get_gitea_token"
done
)

View File

@ -0,0 +1,66 @@
if [[ -z "$GIT_AUTHOR_EMAIL" || -z "$GIT_AUTHOR_NAME" ]]; then
export GIT_AUTHOR_NAME=PREVENT_DEFAULT
else
export GIT_COMMITTER_EMAIL=$GIT_AUTHOR_EMAIL
export GIT_COMMITTER_NAME=$GIT_AUTHOR_NAME
fi
function sigint_handler() {
trap - INT
}
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 [[ "$GIT_AUTHOR_NAME" != "PREVENT_DEFAULT" ]]; then
echo "you are already identified as $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL>"
echo " "
fi
else
local isuser=$(ssh l_samenv@linse-c "test -d ~$1 && echo OK" 2>/dev/null)
if [[ "$isuser" == "OK" ]]; then
echo " "
if [[ "$GIT_AUTHOR_NAME" != "PREVENT_DEFAULT" && ! -z "$GITEA_TOKEN" ]]; then
echo "you are already identified as $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL> - you may press ctrl-c to abort"
echo "get token again from $1@linse-c"
else
echo "get token from $1@linse-c"
fi
trap sigint_handler SIGINT
local all=($(ssh $1@linse-c 'echo _ $GITEA_TOKEN $GIT_AUTHOR_EMAIL $GIT_AUTHOR_NAME' 2>/dev/null))
if [[ -z "$all" ]]; then
return 1
fi
local token=${all[1]}
local email=${all[2]}
local name=${all[@]:3:9}
if [[ -z "$token" || -z "$email" || -z "$name" ]]; then
echo "GITEA_TOKEN, GIT_AUTHOR_EMAIL and GIT_AUTHOR_NAME are not defined in your rc file on $1@linse-c"
else
export GITEA_TOKEN=$token
export GIT_AUTHOR_EMAIL=$email
export GIT_AUTHOR_NAME=$name
echo "you are identified as $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL>"
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 -> no gitea token available for git push"
echo " "
echo "however, you are identified as $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL> for git commit"
echo " "
fi
fi
export GIT_COMMITTER_EMAIL=$GIT_AUTHOR_EMAIL
export GIT_COMMITTER_NAME=$GIT_AUTHOR_NAME
}