moved bind-mount vscode and chromium to modules. Made .inst files for them with sensible defaults that can be overridden by env vars.
parent
3262da4ded
commit
35a6904cf4
|
@ -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
|
|
@ -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
|
|
@ -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
|
|
@ -1,24 +1,42 @@
|
|||
#!/bin/bash
|
||||
# must have fuser and bindfs installed
|
||||
function bmount () {
|
||||
if [ "$1" == "-mp" ]; then
|
||||
MOUNTED=$(mountpoint "$2" | grep not)
|
||||
if [ -z "$MOUNTED" ]; then
|
||||
echo $2 is a mount point so bind mounting $2/$3 to $4
|
||||
notify-send "bind mounting ${2}/${3} to ${4}" --icon=dialog-information -t 2000
|
||||
bindfs "$2/$3" "$4"
|
||||
else
|
||||
notify-send "${2} not a mount point - Unable to bind mount ${2}/${3} to ${4}" --icon=dialog-error -t 2000
|
||||
fi
|
||||
else
|
||||
echo bind mounting $1 to $2
|
||||
notify-send "bind mounting ${1} to ${2}" --icon=dialog-information -t 2000
|
||||
bindfs "$1" "$2"
|
||||
fi
|
||||
}
|
||||
# for use by sudoers
|
||||
# ln -s $BASH_SHELL_HOST/all/modules/bind-mount/bind-mount.sh /opt/bin/bmount
|
||||
# function xxbmount () {
|
||||
# if [ "$1" == "-mp" ]; then
|
||||
# MOUNTED=$(mountpoint "$2" | grep not)
|
||||
# if [ -z "$MOUNTED" ]; then
|
||||
# echo $2 is a mount point so bind mounting $2/$3 to $4
|
||||
# notify-send "bind mounting ${2}/${3} to ${4}" --icon=dialog-information -t 2000
|
||||
# bindfs "$2/$3" "$4"
|
||||
# else
|
||||
# notify-send "${2} not a mount point - Unable to bind mount ${2}/${3} to ${4}" --icon=dialog-error -t 2000
|
||||
# fi
|
||||
# else
|
||||
# echo bind mounting $1 to $2
|
||||
# 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"
|
||||
notify-send "removing bind mount at ${1}" --icon=dialog-information -t 2000
|
||||
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 $@
|
|
@ -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
|
|
@ -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_ $@
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -2,23 +2,20 @@
|
|||
|
||||
command -v code >/dev/null 2>&1 || exit
|
||||
|
||||
# set default home here
|
||||
# can pass
|
||||
vscode () {
|
||||
|
||||
home=${VSCODE_HOME:-$1}
|
||||
home=${home:-$HOME}
|
||||
echo $home
|
||||
#local home=$HOME
|
||||
local home=/opt/vscode
|
||||
home=${VSCODE_HOME:-$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
|
||||
user=${home}/user
|
||||
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
|
||||
(return 0 2>/dev/null) || vscode $@
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -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"
|
Reference in New Issue