Merge remote-tracking branch 'git.kebler.net/master' into giskard

giskard
Kebler Network System Administrator 2021-02-05 12:38:48 -08:00
commit 9fb071b840
9 changed files with 129 additions and 29 deletions

26
all/archive/chromium.inst Normal file
View File

@ -0,0 +1,26 @@
#!/bin/bash
module_load notify
_ch=$(command -v _chromium)
if [[ $_ch ]]; then
ch=$(dirname "$_ch")/chromium
## if chromium exits probably an update to so move again
msg="new version availabe, run: sudo mv $ch $_ch"
[[ -f $ch ]] && llog $msg && notify-send $msg
export CHROME_CONFIG_HOME="/opt/chromium"
# chmod +x $BASH_SHELL_HOST/all/modules/chromium.sh
ln -sf $BASH_SHELL_HOST/all/modules/chromium.sh /opt/bin/chromium
llog "chromium sucessfully set up on $HOSTNAME"
login_notify "chromium sucessfully set up on $HOSTNAME"
else
# echo no _chromium
ch=$(command -v chromium)
if [[ $ch ]];then
llog "chromium availabe, need to run this command and log in again"
login_notify "chromium availabe but need to run this command and log in again"
llog "sudo mv $ch $(dirname $ch)/_chromium"
login_notify "sudo mv $ch $(dirname $ch)/_chromium"
else
llog "Warning: ungoogled chromimum not installed on $HOSTNAME"
login_notify "Warning: ungoogled chromimum not installed on $HOSTNAME"
fi
fi

6
all/archive/vscode.inst Normal file
View File

@ -0,0 +1,6 @@
#!/bin/bash
if [[ $(command -v code) ]]; then
export VSCODE_HOME="/opt/vscode"
chmod +x $BASH_SHELL_HOST/all/modules/vscode.sh
ln -sf $BASH_SHELL_HOST/all/modules/vscode.sh /opt/bin/vscode
fi

View File

@ -0,0 +1,7 @@
DIR="$(cd "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"
BIN=${1:-/opt/bin/bmount}
ln -s $DIR/bind-mount.sh $BIN
sudo chown root:sudo $DIR/bind-mount.sh
sudo chmod 771 $DIR/bind-mount.sh
echo "%users $HOSTNAME=(ALL) NOPASSWD:SETENV: /bin/bash $BIN" | sudo tee /etc/sudoers.d/bmount
sudo chmod 440 /etc/sudoers.d/bmount

View File

@ -1,24 +1,42 @@
#!/bin/bash #!/bin/bash
# must have fuser and bindfs installed # must have fuser and bindfs installed
function bmount () { # for use by sudoers
if [ "$1" == "-mp" ]; then # ln -s $BASH_SHELL_HOST/all/modules/bind-mount/bind-mount.sh /opt/bin/bmount
MOUNTED=$(mountpoint "$2" | grep not) # function xxbmount () {
if [ -z "$MOUNTED" ]; then # if [ "$1" == "-mp" ]; then
echo $2 is a mount point so bind mounting $2/$3 to $4 # MOUNTED=$(mountpoint "$2" | grep not)
notify-send "bind mounting ${2}/${3} to ${4}" --icon=dialog-information -t 2000 # if [ -z "$MOUNTED" ]; then
bindfs "$2/$3" "$4" # echo $2 is a mount point so bind mounting $2/$3 to $4
else # notify-send "bind mounting ${2}/${3} to ${4}" --icon=dialog-information -t 2000
notify-send "${2} not a mount point - Unable to bind mount ${2}/${3} to ${4}" --icon=dialog-error -t 2000 # bindfs "$2/$3" "$4"
fi # else
else # notify-send "${2} not a mount point - Unable to bind mount ${2}/${3} to ${4}" --icon=dialog-error -t 2000
echo bind mounting $1 to $2 # fi
notify-send "bind mounting ${1} to ${2}" --icon=dialog-information -t 2000 # else
bindfs "$1" "$2" # echo bind mounting $1 to $2
fi # notify-send "bind mounting ${1} to ${2}" --icon=dialog-information -t 2000
} # bindfs "$1" "$2"
# fi
# }
bumount () { function bumount {
echo "removing bind mount at $1" echo "removing bind mount at $1"
notify-send "removing bind mount at ${1}" --icon=dialog-information -t 2000 notify-send "removing bind mount at ${1}" --icon=dialog-information -t 2000
fusermount -u "$1" fusermount -u "$1"
} }
function bmount {
if [ "$1" == "-d" ]; then
bumount $2
else
# if [[ " ${array[@]} " =~ " ${value} " ]]; then
# # whatever you want to do when array contains value
# fi
# mp="${@: -2}"
echo mounting $@
bindfs $@
fi
}
# if script was executed then call the function
(return 0 2>/dev/null) || bmount $@

View File

@ -0,0 +1,9 @@
#!/bin/bash
source $BASH_SHELL_BASE/module.lib
module_load helpers
NAME=${1:-$(filename $0)}
DIR=$(adirname "$0")
BIN=${1:-/opt/bin/$NAME}
chown :users $DIR/$NAME.sh
chmod 755 $DIR/$NAME.sh
ln -sf $DIR/$NAME.sh $BIN

View File

@ -0,0 +1,35 @@
#!/bin/bash
# user to start MUST be first in arguments
# if not supplied then will use default
chromium_ () {
local DEFAULT=/opt/chromium
# local DEFAULT="$HOME/.local/share/chromium"
local exe="/usr/bin/chromium"
[[ ! $exe ]] && echo chromium not installed set && return 1
user=${CHROMIUM_USER}
[[ $1 && ( ! $1 == -* ) ]] && user=$1 && shift
user=${user:-$USER}
if [[ $user == "$USER" ]]; then
unset CHROME_CONFIG_HOME
echo starting chromium for $USER in default directory within users home
echo $exe "$@"
$exe "$@"
else
[[ $user == "incognito" ]] && set -- "$@" "-incognito"
dir=${CHROMIUM_HOME:-$DEFAULT}
echo "$exe $@ --user-data-dir=$dir/$user"
"$exe" "$@" --user-data-dir="$dir"/"$user"
fi
}
# # if script was executed then call the function
(return 0 2>/dev/null) || chromium_ $@

View File

@ -2,23 +2,20 @@
command -v code >/dev/null 2>&1 || exit command -v code >/dev/null 2>&1 || exit
# set default home here
# can pass
vscode () { vscode () {
#local home=$HOME
home=${VSCODE_HOME:-$1} local home=/opt/vscode
home=${home:-$HOME} home=${VSCODE_HOME:-$home}
echo $home [[ $1 == "-h" ]] && home=$2 && shift 2
mkdir -p $home
[[ $? -ne 0 ]] && echo "unable to set vscode home at $home, aborting" && return 1
exts=${home}/extensions exts=${home}/extensions
user=${home}/user user=${home}/user
exe=$(command -v code) exe=$(command -v code)
$exe --user-data-dir=$user --extensions-dir=$exts $exe --user-data-dir=$user --extensions-dir=$exts "$@"
} }
# # if script was executed then call the function # # if script was executed then call the function
(return 0 2>/dev/null) || vscode $@ (return 0 2>/dev/null) || vscode $@

2
giskard/archive/chromium Executable file
View File

@ -0,0 +1,2 @@
echo setting up bindmounts for chromium
echo sudo -s "/bin/bash /opt/bin/bmount -u $USER -g users /mnt/common/home /mnt/AllData/tempbind"