Adding port customisation

This commit is contained in:
Adsooi 2023-03-22 13:24:58 +01:00
parent 0b3a551ed3
commit a9454db32f
Signed by: Ad5001
GPG key ID: EF45F9C6AFE20160
3 changed files with 9 additions and 5 deletions

View file

@ -17,8 +17,9 @@ This script has several dependencies:
First of all, you will need create the scripts that will be executed on the remote servers. First of all, you will need create the scripts that will be executed on the remote servers.
1. Head to the `remotes` directory 1. Head to the `remotes` directory
2. Create a new directory named using the `user`@`host` pattern for the remote host and the user on it you want to execute the script on. (e.g: `root@example.org`) if it does not exist. 2. Create a new directory named using the `user`@`host` pattern for the remote host and the user on it you want to execute the script on. (e.g: `root@example.org`) if it does not exist.
3. Create a new script (the file name will be used as script name when it's executed at runtime). 3. Create a file `port` with the SSH port number.
4. (optional) You can import common libraries by adding a comment on line two following this pattern : `# Requires: libraries/<path/to/library>.sh`. You can import several libraries by separating them by a space. You can see the various default included libraries in the `libraries` directory. 4. Create a new script (the file name will be used as script name when it's executed at runtime).
5. (optional) You can import common libraries by adding a comment on line two following this pattern : `# Requires: libraries/<path/to/library>.sh`. You can import several libraries by separating them by a space. You can see the various default included libraries in the `libraries` directory.
**Note**: The libraries/common.sh library will always be imported into the server so you don't need to reference it there. **Note**: The libraries/common.sh library will always be imported into the server so you don't need to reference it there.

View file

@ -0,0 +1 @@
22

View file

@ -48,6 +48,7 @@ for folder in "$REMOTES"/*; do
echo -e "\n" echo -e "\n"
dependencies="libraries/common.sh" dependencies="libraries/common.sh"
full_script="" full_script=""
port="$(cat $folder/port)"
# Executing all necessary scripts # Executing all necessary scripts
if [[ $pswd != "skip" ]]; then if [[ $pswd != "skip" ]]; then
for script in $folder/*.sh; do for script in $folder/*.sh; do
@ -72,11 +73,12 @@ $full_script"
export SSH_ASKPASS="$(pwd)/tmp.sh" export SSH_ASKPASS="$(pwd)/tmp.sh"
export SSH_ASKPASS_REQUIRE="force" export SSH_ASKPASS_REQUIRE="force"
# Transmit the script # Transmit the script
echo "$full_script" | ssh -q $host "tee run.sh" 1>/dev/null echo "$full_script" | ssh -q $host -p $port "tee run.sh" 1>/dev/null
info "Transmitted script" info "Transmitted script"
# Run and remove it. # Run and remove it.
#ssh $host PASSWORD="$pswd" "bash run.sh && rm run.sh" ssh $host -p $port PASSWORD="$pswd" "bash run.sh && rm run.sh"
ssh -t $host PASSWORD="$pswd" "bash -i run.sh && rm run.sh" ## Interactive shell does not work.
#ssh -t $host PASSWORD="$pswd" "bash -i run.sh && rm run.sh"
rm tmp.sh rm tmp.sh
else else
box "Skipping ${host}..." box "Skipping ${host}..."