parent
5c41a40df3
commit
2d11a5d047
|
@ -0,0 +1,33 @@
|
|||
#!/bin/bash
|
||||
|
||||
module_load sshfs
|
||||
module_load net-utils
|
||||
module_load filesystem
|
||||
|
||||
function ssh-mount-238 () {
|
||||
echo mounting folders locally from 238 network hosts
|
||||
mnt238gate
|
||||
mnt238nas
|
||||
mnt238hass
|
||||
mnttrantor
|
||||
mntwater
|
||||
mnt238lights
|
||||
mnt238relays
|
||||
mnt238switches
|
||||
}
|
||||
|
||||
#!/bin/bash
|
||||
function ssh-unmount-238 () {
|
||||
echo mounting folders locally from 238 network hosts
|
||||
umnt238gate
|
||||
umnt238nas
|
||||
umnt238hass
|
||||
umnttrantor
|
||||
umntwater
|
||||
umnt238lights
|
||||
umnt238relays
|
||||
umnt238switches
|
||||
}
|
||||
|
||||
# list-mounts-238 () {
|
||||
# }
|
|
@ -0,0 +1,75 @@
|
|||
#!/bin/bash
|
||||
|
||||
function mnt238gate(){
|
||||
smount sysadmin@gateway.238.kebler.net:/home/sysadmin /mnt/238/gate/sysadmin -p 22
|
||||
smount sysadmin@gateway.238.kebler.net:/opt /mnt/238/gate/opt -p 22
|
||||
smount root@gateway.238.kebler.net:/ /mnt/238/gate/root -p 22
|
||||
smount root@gateway.238.kebler.net:/etc /mnt/238/gate/etc -p 22
|
||||
}
|
||||
|
||||
|
||||
function wmnt238gate(){
|
||||
smount sysadmin@238.kebler.net:/home/sysadmin /mnt/238/gate/sysadmin -p 22
|
||||
smount sysadmin@238.kebler.net:/opt /mnt/238/gate/opt -p 22
|
||||
smount root@238.kebler.net:/ /mnt/238/gate/root -p 22
|
||||
smount root@238.kebler.net:/etc /mnt/238/gate/etc -p 22
|
||||
}
|
||||
|
||||
function umnt238gate(){
|
||||
usmount /mnt/238/gate/opt
|
||||
usmount /mnt/238/gate/root
|
||||
usmount /mnt/238/gate/etc
|
||||
usmount /mnt/238/gate/sysadmin
|
||||
}
|
||||
|
||||
|
||||
function mnt238nas(){
|
||||
smount sysadmin@nas.238.kebler.net:/opt /mnt/238/nas/opt -p 22
|
||||
smount sysadmin@nas.238.kebler.net:/mnt/data /mnt/238/nas/data -p 22
|
||||
smount sysadmin@nas.238.kebler.net:/mnt/datamirror /mnt/238/nas/datamirror -p 22
|
||||
smount sysadmin@nas.kebler.net:/home/sysadmin /mnt/238/nas/sysadmin -p 22
|
||||
smount root@nas.238.kebler.net:/ /mnt/238/nas/root -p 22
|
||||
}
|
||||
|
||||
|
||||
function umnt238nas(){
|
||||
usmount /mnt/238/nas/opt
|
||||
usmount /mnt/238/nas/data
|
||||
usmount /mnt/238/nas/datamirror
|
||||
usmount /mnt/238/nas/sysadmin
|
||||
usmount /mnt/238/nas/root
|
||||
}
|
||||
|
||||
function mnttrantor(){
|
||||
smount sysadmin@trantor.kebler.net:/home/sysadmin /mnt/238/trantor/sysadmin -p 22
|
||||
smount sysadmin@trantor.kebler.net:/opt /mnt/238/trantor/opt -p 22
|
||||
smount sysadmin@trantor.kebler.net:/mnt/data /mnt/238/trantor/data -p 22
|
||||
smount root@trantor.kebler.net:/ /mnt/238/trantor/root -p 22
|
||||
}
|
||||
|
||||
function umnttrantor(){
|
||||
usmount /mnt/238/trantor/opt
|
||||
usmount /mnt/238/trantor/root
|
||||
usmount /mnt/238/trantor/data
|
||||
usmount /mnt/238/trantor/sysadmin
|
||||
}
|
||||
|
||||
function mntwater(){
|
||||
smount sysadmin@water.kebler.net:/home/sysadmin /mnt/238/water/home -p 22
|
||||
smount sysadmin@water.kebler.net:/opt /mnt/238/water/opt -p 22
|
||||
smount root@water.kebler.net:/ /mnt/238/water/root -p 22
|
||||
}
|
||||
|
||||
function umntwater(){
|
||||
usmount /mnt/238/water/opt
|
||||
usmount /mnt/238/water/root
|
||||
usmount /mnt/238/water/home
|
||||
}
|
||||
|
||||
function mnt238hass(){
|
||||
smount root@hassio.238.kebler.net:/ /mnt/238/hass -p 22
|
||||
}
|
||||
|
||||
function umnt238hass(){
|
||||
usmount /mnt/238/hass
|
||||
}
|
|
@ -0,0 +1,40 @@
|
|||
#!/bin/bash
|
||||
function mnt238lights(){
|
||||
smount sysadmin@lights.238.kebler.net:/home/sysadmin /mnt/238/lights/controller/sysadmin -p 22
|
||||
smount sysadmin@lights.238.kebler.net:/opt /mnt/238/lights/controller/opt -p 22
|
||||
smount root@lights.238.kebler.net:/ /mnt/238/lights/controller/root -p 22
|
||||
}
|
||||
|
||||
function umnt238lights(){
|
||||
usmount /mnt/238/lights/controller/opt
|
||||
usmount /mnt/238/lights/controller/root
|
||||
usmount /mnt/238/lights/controller/sysadmin
|
||||
}
|
||||
|
||||
# via lights firewall at port 222
|
||||
function mnt238relays(){
|
||||
smount sysadmin@lights.238.kebler.net:/home/sysadmin /mnt/238/lights/relays/sysadmin -p 222
|
||||
smount sysadmin@lights.238.kebler.net:/opt /mnt/238/lights/relays/opt -p 222
|
||||
smount root@lights.238.kebler.net:/ /mnt/238/lights/relays/root -p 222
|
||||
}
|
||||
|
||||
|
||||
function umnt238relays(){
|
||||
usmount /mnt/238/lights/relays/opt
|
||||
usmount /mnt/238/lights/relays/root
|
||||
usmount /mnt/238/lights/relays/sysadmin
|
||||
}
|
||||
|
||||
# via lights firewall at port 122
|
||||
function mnt238switches(){
|
||||
smount sysadmin@lights.238.kebler.net:/home/sysadmin /mnt/238/lights/switches/sysadmin -p 122
|
||||
smount sysadmin@lights.238.kebler.net:/opt /mnt/238/lights/switches/opt -p 122
|
||||
smount root@lights.238.kebler.net:/ /mnt/238/lights/switches/root -p 122
|
||||
}
|
||||
|
||||
|
||||
function umntswitches(){
|
||||
usmount /mnt/238/lights/switches/opt
|
||||
usmount /mnt/238/lights/switches/root
|
||||
usmount /mnt/238/lights/switches/sysadmin
|
||||
}
|
|
@ -0,0 +1,42 @@
|
|||
#!/bin/bash
|
||||
function mntpine64(){
|
||||
smount sysadmin@pine64.kebler.net:/home/sysadmin /mnt/pine64/sysadmin -p 22
|
||||
smount sysadmin@pine64.kebler.net:/opt /mnt/pine64/opt -p 22
|
||||
smount root@pine64.kebler.net:/ /mnt/pine64/root -p 22
|
||||
}
|
||||
|
||||
function umntpine64(){
|
||||
usmount /mnt/pine64/opt
|
||||
usmount /mnt/pine64/root
|
||||
usmount /mnt/pine64/sysadmin
|
||||
}
|
||||
function mntrock64(){
|
||||
smount sysadmin@rock64.kebler.net:/home/sysadmin /mnt/rock64/sysadmin -p 22
|
||||
smount sysadmin@rock64.kebler.net:/opt /mnt/rock64/opt -p 22
|
||||
smount root@rock64.kebler.net:/ /mnt/rock64/root -p 22
|
||||
}
|
||||
|
||||
function umntrock64(){
|
||||
usmount /mnt/rock64/opt
|
||||
usmount /mnt/rock64/root
|
||||
usmount /mnt/rock64/sysadmin
|
||||
}
|
||||
|
||||
function mnthass(){
|
||||
smount root@hassio.kebler.net:/ /mnt/hass -p 22
|
||||
}
|
||||
|
||||
function umnthass(){
|
||||
usmount /mnt/hass
|
||||
}
|
||||
function mntrpi4(){
|
||||
smount sysadmin@rpi4focal.kebler.net:/home/sysadmin /mnt/rpi4focal/sysadmin -p 22
|
||||
smount sysadmin@rpi4focal.kebler.net:/opt /mnt/rpi4focal/opt -p 22
|
||||
smount root@rpi4focal.kebler.net:/ /mnt/rpi4focal/root -p 22
|
||||
}
|
||||
|
||||
function umntrpi4(){
|
||||
usmount /mnt/rpi4focal/opt
|
||||
usmount /mnt/rpi4focal/root
|
||||
usmount /mnt/rpi4focal/sysadmin
|
||||
}
|
|
@ -0,0 +1,61 @@
|
|||
#!/bin/bash
|
||||
#hosts lights and lightsi are ssh config entries
|
||||
|
||||
|
||||
function mntlights(){
|
||||
smount sysadmin@lights:/home/sysadmin /mnt/lights/controller/sysadmin -p 22
|
||||
smount sysadmin@lights:/opt /mnt/lights/controller/opt -p 22
|
||||
smount root@lights:/ /mnt/lights/controller/root -p 22
|
||||
}
|
||||
|
||||
function mntlightsi(){
|
||||
smount sysadmin@lightsi:/home/sysadmin /mnt/lights/controller/sysadmin -p 22
|
||||
smount sysadmin@lightsi:/opt /mnt/lights/controller/opt -p 22
|
||||
smount root@lightsi:/ /mnt/lights/controller/root -p 22
|
||||
}
|
||||
|
||||
function umntlights(){
|
||||
usmount /mnt/lights/controller/opt
|
||||
usmount /mnt/lights/controller/root
|
||||
usmount /mnt/lights/controller/sysadmin
|
||||
}
|
||||
|
||||
# via lights firewall at port 222
|
||||
function mntrelays(){
|
||||
smount sysadmin@lights:/home/sysadmin /mnt/lights/relays/sysadmin -p 222
|
||||
smount sysadmin@lights:/opt /mnt/lights/relays/opt -p 222
|
||||
smount root@lights:/ /mnt/lights/relays/root -p 222
|
||||
}
|
||||
|
||||
function mntrelaysi(){
|
||||
smount sysadmin@rlightsi:/home/sysadmin /mnt/lights/relays/sysadmin -p 22
|
||||
smount sysadmin@rlightsi:/opt /mnt/lights/relays/opt -p 22
|
||||
smount root@rlightsi:/ /mnt/lights/relays/root -p 22
|
||||
}
|
||||
|
||||
|
||||
function umntrelays(){
|
||||
usmount /mnt/lights/relays/opt
|
||||
usmount /mnt/lights/relays/root
|
||||
usmount /mnt/lights/relays/sysadmin
|
||||
}
|
||||
|
||||
# via lights firewall at port 122
|
||||
function mntswitches(){
|
||||
smount sysadmin@lights:/home/sysadmin /mnt/lights/switches/sysadmin -p 122
|
||||
smount sysadmin@lights:/opt /mnt/lights/switches/opt -p 122
|
||||
smount root@lights:/ /mnt/lights/switches/root -p 122
|
||||
}
|
||||
|
||||
function mntswitchesi(){
|
||||
smount sysadmin@slightsi:/home/sysadmin /mnt/lights/switches/sysadmin -p 22
|
||||
smount sysadmin@slightsi:/opt /mnt/lights/switches/opt -p 22
|
||||
smount root@slightsi:/ /mnt/lights/switches/root -p 22
|
||||
}
|
||||
|
||||
|
||||
function umntswitches(){
|
||||
usmount /mnt/lights/switches/opt
|
||||
usmount /mnt/lights/switches/root
|
||||
usmount /mnt/lights/switches/sysadmin
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
Fri Nov 13 09:45:13 PST 2020
|
||||
mounting folders locally from 238 network hosts
|
||||
remote sysadmin@gateway.238.kebler.net:/home/sysadmin already mounted at /mnt/238/gate/sysadmin, aborting mount
|
||||
remote sysadmin@gateway.238.kebler.net:/opt already mounted at /mnt/238/gate/opt, aborting mount
|
||||
remote root@gateway.238.kebler.net:/ already mounted at /mnt/238/gate/root, aborting mount
|
||||
remote root@gateway.238.kebler.net:/etc already mounted at /mnt/238/gate/etc, aborting mount
|
||||
remote sysadmin@nas.238.kebler.net:/opt already mounted at /mnt/238/nas/opt, aborting mount
|
||||
remote sysadmin@nas.238.kebler.net:/mnt/data already mounted at /mnt/238/nas/data, aborting mount
|
||||
remote sysadmin@nas.238.kebler.net:/mnt/datamirror already mounted at /mnt/238/nas/datamirror, aborting mount
|
||||
remote sysadmin@nas.kebler.net:/home/sysadmin already mounted at /mnt/238/nas/sysadmin, aborting mount
|
||||
remote root@nas.238.kebler.net:/ already mounted at /mnt/238/nas/root, aborting mount
|
||||
remote root@hassio.238.kebler.net:/ already mounted at /mnt/238/hass, aborting mount
|
||||
remote sysadmin@trantor.kebler.net:/home/sysadmin already mounted at /mnt/238/trantor/sysadmin, aborting mount
|
||||
remote sysadmin@trantor.kebler.net:/opt already mounted at /mnt/238/trantor/opt, aborting mount
|
||||
remote sysadmin@trantor.kebler.net:/mnt/data already mounted at /mnt/238/trantor/data, aborting mount
|
||||
remote root@trantor.kebler.net:/ already mounted at /mnt/238/trantor/root, aborting mount
|
||||
remote sysadmin@water.kebler.net:/home/sysadmin already mounted at /mnt/238/water/home, aborting mount
|
||||
remote sysadmin@water.kebler.net:/opt already mounted at /mnt/238/water/opt, aborting mount
|
||||
remote root@water.kebler.net:/ already mounted at /mnt/238/water/root, aborting mount
|
||||
host lights.238.kebler.net not reachable, aborting mount
|
||||
host lights.238.kebler.net not reachable, aborting mount
|
||||
host lights.238.kebler.net not reachable, aborting mount
|
||||
host lights.238.kebler.net not reachable, aborting mount
|
||||
host lights.238.kebler.net not reachable, aborting mount
|
||||
host lights.238.kebler.net not reachable, aborting mount
|
||||
host lights.238.kebler.net not reachable, aborting mount
|
||||
host lights.238.kebler.net not reachable, aborting mount
|
||||
host lights.238.kebler.net not reachable, aborting mount
|
|
@ -0,0 +1,15 @@
|
|||
#!/bin/bash
|
||||
llog "startup for 238 mounts"
|
||||
dir=$(dirname "$(dirname -- "${BASH_SOURCE[0]}")")
|
||||
for f in $dir/function/ssh-mounts/*; do
|
||||
llog "sourcing: $f"
|
||||
source "$f"
|
||||
done
|
||||
# declare -F | grep 238
|
||||
mkdir -p $dir/logs
|
||||
touch $dir/logs/238-mount.log
|
||||
( sleep 60 ;
|
||||
echo $(date) > $dir/logs/238-mount.log;
|
||||
llog "after delay 238 network mounting"
|
||||
ssh-mount-238 2>&1 | tee -a $dir/logs/238-mount.log
|
||||
) &
|
|
@ -0,0 +1,72 @@
|
|||
#!/bin/bash
|
||||
# vpn tunnel must be operation with dns resolution at 645 dns server
|
||||
|
||||
|
||||
function mnt645nas(){
|
||||
smount sysadmin@nas.645.kebler.net:/opt /mnt/645/nas/opt -p 22
|
||||
smount sysadmin@nas.645.kebler.net:/mnt/data /mnt/645/nas/data -p 22
|
||||
smount sysadmin@nas.645.kebler.net:/mnt/backup /mnt/645/nas/backup -p 22
|
||||
smount sysadmin@nas.645.kebler.net:/home/sysadmin /mnt/645/nas/sysadmin -p 22
|
||||
smount root@nas.645.kebler.net:/ /mnt/645/nas/root -p 22
|
||||
}
|
||||
|
||||
function umnt645nas(){
|
||||
usmount /mnt/645/nas/opt
|
||||
usmount /mnt/645/nas/data
|
||||
usmount /mnt/645/nas/backup
|
||||
usmount /mnt/645/nas/sysadmin
|
||||
usmount /mnt/645/nas/root
|
||||
}
|
||||
|
||||
function mnt645gate(){
|
||||
smount root@grouter.645.kebler.net:/ /mnt/645/gate -p 22
|
||||
}
|
||||
|
||||
function umnt645gate(){
|
||||
usmount /mnt/645/gate
|
||||
}
|
||||
|
||||
|
||||
function mntnadal(){
|
||||
smount sysadmin@nadal.kebler.net:/opt /mnt/645/nadal/opt -p 22
|
||||
smount sysadmin@nadal.kebler.net:/home/sysadmin /mnt/645/nadal/sysadmin -p 22
|
||||
smount sysadmin@nadal.kebler.net:/mnt/data /mnt/645/nadal/data -p 22
|
||||
smount root@nadal.kebler.net:/ /mnt/645/nadal/root -p 22
|
||||
}
|
||||
|
||||
function umntnadal(){
|
||||
usmount /mnt/645/nadal/opt
|
||||
usmount /mnt/645/nadal/sysadmin
|
||||
usmount /mnt/645/nadal/data
|
||||
usmount /mnt/645/nadal/root
|
||||
}
|
||||
|
||||
function mnt645hass(){
|
||||
smount root@hassio.645.kebler.net:/ /mnt/645/hass -p 22
|
||||
}
|
||||
|
||||
function umnt645hass(){
|
||||
usmount /mnt/645/hass
|
||||
}
|
||||
|
||||
# via NAT at WAN interface (mostly to support old gateway)
|
||||
|
||||
function mnt645gatew(){
|
||||
smount sysadmin@645.kebler.net:/opt /mnt/645/wgate/opt -p 22
|
||||
smount sysadmin@645.kebler.net:/home/sysadmin /mnt/645/wgate/sysadmin -p 22
|
||||
smount root@645.kebler.net:/ /mnt/645/wgate/root -p 22
|
||||
}
|
||||
|
||||
function umnt645gatew(){
|
||||
usmount /mnt/645/wgate/opt
|
||||
usmount /mnt/645/wgate/sysadmin
|
||||
usmount /mnt/645/wgate/root
|
||||
}
|
||||
|
||||
function mnt645nasw(){
|
||||
smount sysadmin@645.kebler.net:/opt /mnt/645/nas/opt -p 322
|
||||
smount sysadmin@645.kebler.net:/mnt/data /mnt/645/nas/data -p 322
|
||||
smount sysadmin@645.kebler.net:/mnt/backup /mnt/645/nas/backup -p 322
|
||||
smount sysadmin@645.kebler.net:/home/sysadmin /mnt/645/nas/sysadmin -p 322
|
||||
smount root@645.kebler.net:/ /mnt/645/nas/root -p 322
|
||||
}
|
|
@ -0,0 +1,46 @@
|
|||
#!/bin/bash
|
||||
function mntw645lights(){
|
||||
smount sysadmin@testvpn.kebler.net:/home/sysadmin /mnt/645/lights/controller/sysadmin -p 322
|
||||
smount sysadmin@testvpn.kebler.net:/opt /mnt/645/lights/controller/opt -p 322
|
||||
smount root@testvpn.kebler.net:/ /mnt/645/lights/controller/root -p 322
|
||||
}
|
||||
|
||||
function mnt645lights(){
|
||||
smount sysadmin@controller.lights.645.kebler.net:/home/sysadmin /mnt/645/lights/controller/sysadmin -p 22
|
||||
smount sysadmin@controller.lights.645.kebler.net:/opt /mnt/645/lights/controller/opt -p 22
|
||||
smount root@controller.lights.645.kebler.net:/ /mnt/645/lights/controller/root -p 22
|
||||
}
|
||||
|
||||
function umnt645lights(){
|
||||
usmount /mnt/645/lights/controller/opt
|
||||
usmount /mnt/645/lights/controller/root
|
||||
usmount /mnt/645/lights/controller/sysadmin
|
||||
}
|
||||
|
||||
# via lights firewall at port 222
|
||||
function mnt645relays(){
|
||||
smount sysadmin@controller.lights.645.kebler.net:/home/sysadmin /mnt/645/lights/relays/sysadmin -p 222
|
||||
smount sysadmin@controller.lights.645.kebler.net:/opt /mnt/645/lights/relays/opt -p 222
|
||||
smount root@controller.lights.645.kebler.net:/ /mnt/645/lights/relays/root -p 222
|
||||
}
|
||||
|
||||
|
||||
function umnt645relays(){
|
||||
usmount /mnt/645/lights/relays/opt
|
||||
usmount /mnt/645/lights/relays/root
|
||||
usmount /mnt/645/lights/relays/sysadmin
|
||||
}
|
||||
|
||||
# via lights firewall at port 122
|
||||
function mnt645switches(){
|
||||
smount sysadmin@controller.lights.645.kebler.net:/home/sysadmin /mnt/645/lights/switches/sysadmin -p 122
|
||||
smount sysadmin@controller.lights.645.kebler.net:/opt /mnt/645/lights/switches/opt -p 122
|
||||
smount root@controller.lights.645.kebler.net:/ /mnt/645/lights/switches/root -p 122
|
||||
}
|
||||
|
||||
|
||||
function umntswitches(){
|
||||
usmount /mnt/645/lights/switches/opt
|
||||
usmount /mnt/645/lights/switches/root
|
||||
usmount /mnt/645/lights/switches/sysadmin
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
#!/bin/bash
|
||||
function mnt645lightsbu(){
|
||||
smount sysadmin@backup.lights.645.kebler.net:/home/sysadmin /mnt/645/lights/backup/sysadmin -p 22
|
||||
smount sysadmin@backup.lights.645.kebler.net:/opt /mnt/645/lights/backup/opt -p 22
|
||||
smount root@backup.lights.645.kebler.net:/ /mnt/645/lights/backup/root -p 22
|
||||
}
|
||||
|
||||
function umnt645lightsbu(){
|
||||
usmount /mnt/645/lights/backup/opt
|
||||
usmount /mnt/645/lights/backup/root
|
||||
usmount /mnt/645/lights/backup/sysadmin
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
#!/bin/bash
|
||||
|
||||
# debug logging use -v for verbose i.e. logging
|
||||
if [ "$1" = '-v' ]; then
|
||||
# if not in live terminal session then log to file instead
|
||||
tty -s;
|
||||
if [ "0" != "$?" ]; then
|
||||
SCRIPT_PATH=$(readlink -f "$0")
|
||||
SCRIPT_DIR=$(dirname $SCRIPT_PATH)
|
||||
SCRIPT_NAME=$(basename ${SCRIPT_PATH%.*})
|
||||
mkdir -p $SCRIPT_DIR/logs
|
||||
# log is the /logs subdirectory of original script directory
|
||||
LOG_PATH="$SCRIPT_DIR/logs/$SCRIPT_NAME.log"
|
||||
exec 1> $LOG_PATH 2>&1
|
||||
fi
|
||||
else
|
||||
# silence stdout
|
||||
exec 1> /dev/null
|
||||
fi
|
||||
|
||||
echo $(date)
|
||||
echo setting ssh-agent socket
|
||||
export SSH_AUTH_SOCK="$XDG_RUNTIME_DIR/ssh-agent.socket"
|
||||
echo source mounting functions
|
||||
echo ======== ...mounting 645 devices via vpn ========
|
||||
mnt645gate
|
||||
mnt645nas
|
||||
mnt645hass
|
||||
mntnadal
|
||||
mnt645lights
|
||||
mnt645relays
|
||||
mnt645switches
|
||||
mnt645lightsbu
|
|
@ -0,0 +1,2 @@
|
|||
# set ssh agent socket for each session
|
||||
export SSH_AUTH_SOCK="$XDG_RUNTIME_DIR/ssh-agent.socket"
|
|
@ -0,0 +1,5 @@
|
|||
#!/bin/bash
|
||||
# remote start a program (with x11 forwarding will render locally if gui)
|
||||
function rrem(){
|
||||
ssh -X -t "$1" """$2" "$3"""
|
||||
}
|
|
@ -0,0 +1,2 @@
|
|||
#!/bin/bash
|
||||
module_load sshfs
|
|
@ -0,0 +1,45 @@
|
|||
#!/bin/bash
|
||||
|
||||
# usage:
|
||||
# [[ $(host_reachable host.net) ]] && echo sure || echo nope
|
||||
# or
|
||||
# host_reachable &> /dev/null && echo sure || echo nope
|
||||
# or
|
||||
host_reachable () {
|
||||
if [[ $(command -v nmap) ]] && [[ $2 ]]; then
|
||||
[[ $(nmap $1 -PN -p $2 | grep open) ]] && echo yes && return 0 || return 1
|
||||
fi
|
||||
if [[ $(command -v nc) ]] && [[ $2 ]]; then
|
||||
[[ $(nc -w 2 $1 $2) ]] && echo yes && return 0 || return 1
|
||||
fi
|
||||
if [[ $(command -v ping) ]]; then
|
||||
ping -c1 -W1 $1 &> /dev/null && echo yes && return 0 || return 1
|
||||
fi
|
||||
return 2 # return 2 to indicate no method was available
|
||||
}
|
||||
|
||||
valid_ip()
|
||||
{
|
||||
local ip=$1
|
||||
local stat=1
|
||||
local res
|
||||
|
||||
if [[ $ip =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then
|
||||
OIFS=$IFS
|
||||
IFS='.'
|
||||
ip=($ip)
|
||||
IFS=$OIFS
|
||||
[[ ${ip[0]} -le 255 && ${ip[1]} -le 255 \
|
||||
&& ${ip[2]} -le 255 && ${ip[3]} -le 255 ]]
|
||||
res=$([ $? == 0 ] && echo true || echo false)
|
||||
else
|
||||
res=false
|
||||
fi
|
||||
echo $res
|
||||
}
|
||||
|
||||
get_domain() {
|
||||
local domain
|
||||
domain=$(echo $1 | awk -F\. '{print $(NF-1) FS $NF}')
|
||||
echo "$domain"
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
#!/bin/bash
|
||||
# depends on sshfs fuse for ssh
|
||||
function smount(){
|
||||
local HOST
|
||||
HOST=$(sed 's/.*@\(.*\):.*/\1/' <<< "$1")
|
||||
[[ ! $(host_reachable $HOST 22) ]] && echo host $HOST not reachable, aborting mount && return 1
|
||||
if [[ $(mounted $2) ]]; then
|
||||
echo "remote $1 already mounted at $2, aborting mount"
|
||||
else
|
||||
echo "mounting $1 at $2 via ssh"
|
||||
sshfs $1 $2 $3 $4 -o default_permissions
|
||||
fi
|
||||
}
|
||||
|
||||
function usmount(){
|
||||
if [[ $(mountpoint $1 | grep not) ]]; then
|
||||
echo "unmounting remote file system at $1"
|
||||
fusermount -u $1
|
||||
else
|
||||
echo "nothing mounted at $1, aborting unmount"
|
||||
fi
|
||||
}
|
Reference in New Issue