You are not logged in.
These two sites by Dylan Araps can be quite useful:
Offline
Ok, so I've outsmarted myself. This works conditionally:
#!/bin/bash
for u in $HOME/Remote/SSHFS/*
do
if [ -d $u ]; then
basename "$u" >/dev/null
acct="$(basename -- $u)"
IFS=- read -r left right <<< "$acct"
if mountpoint "${HOME}/Remote/SSHFS/${acct}" >/dev/null; then
printf '%b\n' "unmount ${right},fusermount -u /home/schwim/Remote/${right}"
else
printf '%b\n' "mount ${right},sshfs -o workaround=rename $left@$right:/home/$left /home/schwim/Remote/SSHFS/${acct}"
fi
fi
done
The condition being, as long as the remote mount point is /home/$acctname for:
sshfs -o workaround=rename $left@$right:/home/$left /home/schwim/Remote/SSHFS
The issue is that not all of my mount points follow that logical account path. Some are /var/www/acct, etc.
So I'm back to hardcoding the entries so I can pass the remote path to the mount command.
I could do this with a config file in the Remote directory that would contain all the necessary information needed for the mount command. Is there a smoother way of handling this that I'm missing? If not, what would be the best way of passing this info to the bash script?
Schw.im! A social site with an identity crisis.
Offline
If you’re okay, I’ll step away from this now. It’s starting to get a bit complex
You’ll have to strike a balance between how many cases you want to handle vs how much time you spend on it.
Copy+paste the for loop to deal with each case would be dirty, but simple.
Might be able to wrap current for loop in an another for loop which covers the different paths/accounts.
Or write all paths/accounts to a cache file and the read it line by line.
Try to really thing it through and aim for a simple solution. Clean and simple code where you can.
Offline
Or write all paths/accounts to a cache file and the read it line by line.
example reader
#!/bin/bash
while read -r p; do
echo "$p"
done <data.txt
example data.txt
some/info/here
some other info here
and here
Last edited by brontosaurusrex (2020-11-22 19:27:21)
Offline
malm wrote:Or write all paths/accounts to a cache file and the read it line by line.
example reader
#!/bin/bash while read -r p; do echo "$p" done <data.txt
example data.txt
some/info/here some other info here and here
I apologize for my density but could you explain how this would pertain to my needs? I don't quite understand how I would make this example work for me.
{EDIT}
It seems it would make some sense to have the bash script read a file with the important information for each file system, then apply those variables during the menu entry and mount command building.
Should I be creating a single file with each domain's information in it as variables inside an array of some sort?
Last edited by schwim (2020-11-22 21:34:30)
Schw.im! A social site with an identity crisis.
Offline
What exactly is a data needed for single connection? An example?
Offline
What exactly is a data needed for single connection? An example?
So far as I can tell, these are the only variables that I need to use.
host: schwim.net
user: schwim
local dir: /home/schwim/schwim.net
remote dir: /var/www/client1
Last edited by schwim (2020-11-23 15:08:31)
Schw.im! A social site with an identity crisis.
Offline
I'd probably try with an associative array, where key would be your label (server1) and value would be the entire command needed (sshfs + all the data needed) - unlike variables one should be able to expand an array value directly (without any evals).
In this direction
#!/bin/bash
# an array here
declare -A exe
exe=(
["serverOne"]="echo woot"
["job"]="sleep 3"
["myserv"]="neofetch"
)
# this is the exe
${exe[serverOne]}
${exe[job]}
${exe[myserv]}
p.s. Arrays in bash are a world of pain (only my experience), so be prepared to suffer.
Last edited by brontosaurusrex (2020-11-23 17:54:42)
Offline
"menuItem" is a variable used by BL and sourced from /usr/lib/bunsen/common/bl-includes.
You should have seen this in the existing BL pipemenus.
There are also some functions for jgmenu in the same file:
jgmenuItem
jgmenuSeparator
jgmenuSubmenu
jgmenuEnd
If you're creating a jgmenu pipe menu from scratch they can save you some work (but you seem to be there already).
You can see some examples of usage in /usr/bin/bl-scrot-pipemenu
...elevator in the Brain Hotel, broken down but just as well...
( a boring Japan blog (currently paused), now on Bluesky, there's also some GitStuff )
Offline
Would something like this make sense?
# an array here
declare -A loop
loop=(
["serverOne"][domain]="domain.com"
["serverOne"][user]="bobthebuilder"
["serverOne"]["local"]="/home/schwim/Remote/SSHFS/domain.com"
["serverOne"]["remote"]="/var/www/client1"
["serverTwo"][domain]="anotherdomain.com"
["serverTwo"][user]="dougthedestroyer"
["serverTwo"]["local"]="/home/schwim/Remote/SSHFS/anotherdomain.com"
["serverTwo"]["remote"]="/home/doug/www"
)
? Does bash work this way? If this is feasible, how might I go about looping through that array in the script to get to the important bits?
Schw.im! A social site with an identity crisis.
Offline
^Not a valid bash array of any sort. https://www.shellcheck.net/
I'am out as well.
Last edited by brontosaurusrex (2020-11-24 10:52:09)
Offline