Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 51b7c0f

Browse files
committedSep 26, 2023
fix unkn0w#190 chce_ssh_config.sh - uzupełnienie danych
1 parent 82d895a commit 51b7c0f

File tree

2 files changed

+22
-39
lines changed

2 files changed

+22
-39
lines changed
 

‎.github/workflows/update-serwery-txt.yml

-33
This file was deleted.

‎actions/chce_ssh_config.sh

+22-6
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,6 @@
88
# --host HOSTNAME (to configure connection for non mikr.us host)
99
# username@test.com (without param in front)
1010

11-
# Read hosts from serwery.txt
12-
declare -A hosts
13-
while IFS='=' read -r key value; do
14-
hosts["$key"]="$value"
15-
done < "../serwery.txt"
16-
1711
# some bash magic: https://brianchildress.co/named-parameters-in-bash/
1812
while [ $# -gt 0 ]; do
1913
if [[ $1 == *"--"* ]]; then
@@ -50,6 +44,28 @@ if [ -n "$mikrus" ]; then
5044
port="$(( 10000 + $(echo $mikrus | grep -o '[0-9]\+') ))"
5145

5246
key="$(echo $mikrus | grep -o '[^0-9]\+' )"
47+
48+
url="https://mikr.us/serwery.txt"
49+
servers=""
50+
if command -v curl &> /dev/null; then
51+
servers=$(curl -s "$url")
52+
elif command -v wget &> /dev/null; then
53+
servers=$(wget -q -O - "$url")
54+
else
55+
echo "ERROR: Neither 'curl' nor 'wget' were found."
56+
exit 1
57+
fi
58+
59+
if [ -z "$servers" ]; then
60+
echo "ERROR: Unable to download the list of servers."
61+
exit 1
62+
fi
63+
64+
declare -A hosts
65+
while IFS='=' read -r server value; do
66+
hosts["$server"]="$value"
67+
done <<< "$servers"
68+
5369
host="${hosts[$key]}"
5470
if [ -z "$host" ]; then
5571
echo "ERROR: Server hostname not known for key '$key'."

0 commit comments

Comments
 (0)
Please sign in to comment.