uncommited

This commit is contained in:
Yuri Zamyatin 2025-10-02 07:46:48 +00:00
parent 4b4d7a684c
commit 316a3ff9e4
No known key found for this signature in database
GPG Key ID: 4009A4CD0333B579
11 changed files with 132 additions and 22 deletions

View File

@ -1,10 +1,6 @@
#!/bin/bash #!/bin/bash
set -e set -e
if [ ! -t 0 ]; then
exec /bin/ssh "$@"
fi
if [ $# -lt 1 ]; then if [ $# -lt 1 ]; then
echo "Usage: $0 <hostname> [ssh-options]" echo "Usage: $0 <hostname> [ssh-options]"
exit 1 exit 1
@ -15,11 +11,7 @@ read -r -d '' init_cmd << WSCOMPAT_EOF_9oqn7IVF || true
export WS_IS_COMPAT=1 export WS_IS_COMPAT=1
export WSCOMPAT_MASTER="$WSCOMPAT_MASTER" export WSCOMPAT_MASTER="$WSCOMPAT_MASTER"
export WSCOMPAT_DIR="/tmp/wscompat_${WSCOMPAT_MASTER}_\$(whoami)" export WSCOMPAT_DIR="/tmp/wscompat_${WSCOMPAT_MASTER}_\$(whoami)"
ws_cleanup() { rm -rf "\$WSCOMPAT_DIR"; }
trap ws_cleanup EXIT
rm -rf "\$WSCOMPAT_DIR" && mkdir -p "\$WSCOMPAT_DIR" && chmod 700 "\$WSCOMPAT_DIR" rm -rf "\$WSCOMPAT_DIR" && mkdir -p "\$WSCOMPAT_DIR" && chmod 700 "\$WSCOMPAT_DIR"
cat << 'WSCOMPAT_EOF_84EbM3la' > "\$WSCOMPAT_DIR/profile" cat << 'WSCOMPAT_EOF_84EbM3la' > "\$WSCOMPAT_DIR/profile"
$( $(
sed 's/WSCOMPAT_EOF_/WSCOMPAT_EOF__/g' "$WSCOMPAT_DIR/profile" sed 's/WSCOMPAT_EOF_/WSCOMPAT_EOF__/g' "$WSCOMPAT_DIR/profile"
@ -31,7 +23,6 @@ $(
) )
WSCOMPAT_EOF_84EbM3la WSCOMPAT_EOF_84EbM3la
. \$WSCOMPAT_DIR/profile . \$WSCOMPAT_DIR/profile
# pam, systemd - wrap in login shell # pam, systemd - wrap in login shell
exec /bin/bash --login --norc --noprofile -c "exec /bin/bash --rcfile \"\$WSCOMPAT_DIR/bashrc\"" exec /bin/bash --login --norc --noprofile -c "exec /bin/bash --rcfile \"\$WSCOMPAT_DIR/bashrc\""
WSCOMPAT_EOF_9oqn7IVF WSCOMPAT_EOF_9oqn7IVF

117
arch-user/bin/wsudo Executable file
View File

@ -0,0 +1,117 @@
#!/bin/bash
parse() {
sudo_user="root"
sudo_command=""
sudo_login_shell=""
local args=("$@")
local i=0
local arg_count=${#args[@]}
while [[ $i -lt $arg_count ]]; do
case "${args[$i]}" in
-u|--user)
((i++))
if [[ $i -lt $arg_count ]]; then
sudo_user="${args[$i]}"
fi
((i++))
;;
-i|--login)
sudo_login_shell=true
((i++))
;;
-s|--shell)
((i++))
;;
--)
((i++))
sudo_command="${args[*]:$i}"
break
;;
-*)
((i++))
;;
su)
((i++))
local su_user=""
while [[ $i -lt $arg_count ]]; do
case "${args[$i]}" in
-|-l|--login)
sudo_login_shell=true
((i++))
;;
-c|--command)
((i++))
if [[ $i -lt $arg_count ]]; then
sudo_command="${args[$i]}"
((i++))
fi
;;
--session-command=*)
sudo_command="${args[$i]#*=}"
((i++))
;;
-m|-p|--preserve-environment)
((i++))
;;
-s|--shell)
((i++))
if [[ $i -lt $arg_count && "${args[$i]}" != -* ]]; then
((i++))
fi
;;
-*)
((i++))
;;
*)
if [[ -z "$su_user" ]]; then
su_user="${args[$i]}"
((i++))
else
((i++))
fi
;;
esac
done
if [[ -n "$su_user" ]]; then
sudo_user="$su_user"
fi
break
;;
*)
sudo_command="${args[*]:$i}"
break
;;
esac
done
}
parse "$@"
[ -z "$WSCOMPAT_MASTER" ] && WSCOMPAT_MASTER="$(whoami)"
read -r -d '' init_cmd << WSCOMPAT_EOF_9oqn7IVF || true
export WS_IS_COMPAT=1
export WSCOMPAT_MASTER="$WSCOMPAT_MASTER"
export WSCOMPAT_DIR="/tmp/wscompat_${WSCOMPAT_MASTER}_\$(whoami)"
rm -rf "\$WSCOMPAT_DIR" && mkdir -p "\$WSCOMPAT_DIR" && chmod 700 "\$WSCOMPAT_DIR"
cat << 'WSCOMPAT_EOF_84EbM3la' > "\$WSCOMPAT_DIR/profile"
$(
sed 's/WSCOMPAT_EOF_/WSCOMPAT_EOF__/g' "$WSCOMPAT_DIR/profile"
for file in "$WSCOMPAT_DIR.profile"*.sh; do
if [ -f "$file" ]; then
sed 's/WSCOMPAT_EOF_/WSCOMPAT_EOF__/g' "$file"
fi
done
)
WSCOMPAT_EOF_84EbM3la
. \$WSCOMPAT_DIR/profile
WSCOMPAT_EOF_9oqn7IVF
if [ -z "$sudo_command" ]; then
sudo_command="exec /bin/bash --rcfile \"\$WSCOMPAT_DIR/bashrc\""
fi
if [ "$sudo_login_shell" ]; then
bash_flags="--login --noprofile --norc";
else
bash_flags="--noprofile --norc";
fi
exec /bin/sudo -u "$sudo_user" /bin/bash $bash_flags -c "$init_cmd; $sudo_command"

View File

@ -1,3 +1,3 @@
--- ---
model: openrouter:anthropic/claude-sonnet-4 model: openrouter:anthropic/claude-sonnet-4.5
--- ---

View File

@ -4,10 +4,12 @@
stty intr ^K stty intr ^K
alias ssh='wssh'
alias sudo='wsudo'
alias ls='ls --color=auto' alias ls='ls --color=auto'
alias grep='grep --color=auto' alias grep='grep --color=auto'
alias node='NODE_NO_READLINE=1 rlwrap node' alias node='NODE_NO_READLINE=1 rlwrap node'
alias ssh='wssh'
export EDITOR=vim export EDITOR=vim

View File

@ -16,25 +16,30 @@ cat << 'WSCOMPAT_EOF_04tcIQE7' > "$WSCOMPAT_DIR/bashrc"
[ -f ~/.bashrc ] && . ~/.bashrc [ -f ~/.bashrc ] && . ~/.bashrc
stty intr ^K stty intr ^K
alias ssh='wssh' alias ssh='wssh'
alias sudo='wsudo'
WSCOMPAT_EOF_04tcIQE7 WSCOMPAT_EOF_04tcIQE7
export VIMINIT="source $WSCOMPAT_DIR/vimrc" export VIMINIT="source $WSCOMPAT_DIR/vimrc"
cat << 'WSCOMPAT_EOF_04tcIQE7' > "$WSCOMPAT_DIR/vimrc" cat << 'WSCOMPAT_EOF_04tcIQE7' > "$WSCOMPAT_DIR/vimrc"
{{ template "vimrc" . }} {{ tmpl.Inline (file.Read "config/vim/vimrc.tmpl") . }}
WSCOMPAT_EOF_04tcIQE7 WSCOMPAT_EOF_04tcIQE7
export INPUTRC="$WSCOMPAT_DIR/inputrc" export INPUTRC="$WSCOMPAT_DIR/inputrc"
cat << 'WSCOMPAT_EOF_04tcIQE7' > "$WSCOMPAT_DIR/inputrc" cat << 'WSCOMPAT_EOF_04tcIQE7' > "$WSCOMPAT_DIR/inputrc"
{{ template "inputrc" . }} {{ tmpl.Inline (file.Read "config/readline/inputrc") . }}
WSCOMPAT_EOF_04tcIQE7 WSCOMPAT_EOF_04tcIQE7
export LESSKEYIN="$WSCOMPAT_DIR/lesskey" export LESSKEYIN="$WSCOMPAT_DIR/lesskey"
cat << 'WSCOMPAT_EOF_04tcIQE7' > "$WSCOMPAT_DIR/lesskey" cat << 'WSCOMPAT_EOF_04tcIQE7' > "$WSCOMPAT_DIR/lesskey"
{{ template "lesskey" . }} {{ tmpl.Inline (file.Read "config/less/lesskey") . }}
WSCOMPAT_EOF_04tcIQE7 WSCOMPAT_EOF_04tcIQE7
cat << 'WSCOMPAT_EOF_04tcIQE7' > "$WSCOMPAT_DIR/wssh" cat << 'WSCOMPAT_EOF_04tcIQE7' > "$WSCOMPAT_DIR/wssh"
{{ template "wssh" . }} {{ tmpl.Inline (file.Read "bin/wssh") . }}
WSCOMPAT_EOF_04tcIQE7 WSCOMPAT_EOF_04tcIQE7
chmod +x "$WSCOMPAT_DIR/wssh" chmod +x "$WSCOMPAT_DIR/wssh"
cat << 'WSCOMPAT_EOF_04tcIQE7' > "$WSCOMPAT_DIR/wsudo"
{{ tmpl.Inline (file.Read "bin/wsudo") . }}
WSCOMPAT_EOF_04tcIQE7
chmod +x "$WSCOMPAT_DIR/wsudo"

View File

@ -85,12 +85,7 @@ cp -rf data/* ~/.local/share
########### compat ############ ########### compat ############
export IS_COMPAT=1 export IS_COMPAT=1
gomplate --file config/workspace-compat/profile.tmpl \ gomplate --file config/workspace-compat/profile.tmpl --out ~/.config/workspace-compat/profile
-t vimrc=config/vim/vimrc \
-t inputrc=config/readline/inputrc \
-t lesskey=config/less/lesskey \
-t wssh=bin/wssh \
--out ~/.config/workspace-compat/profile
export IS_COMPAT=0 export IS_COMPAT=0
############################### ###############################