Cleaned up and merge other Linux snippit repo

Meged https://git.bprieshof.nl/brammp/linux into ./Linux
This commit is contained in:
2023-11-17 00:05:49 +01:00
parent 0638efa018
commit 9fb35960f9
53 changed files with 1851 additions and 7 deletions

View File

@@ -0,0 +1,73 @@
# Authchecker functions for curl
## curl keeps asking for password until correct, and downloads file
```
function getcurlsec {
local curlurl="$1"
local curluser="$2"
local curloutput="$3"
while true; do
curl --fail --user "$curluser" "$curlurl" -o "$curloutput"
local EC=$?
if [ $EC -eq 0 ]; then
break
fi
done
}
```
Syntax: `getcurlsec <url to download> <username> <output file>`
## curl downloads file using given credentials
```
function getcurlsecwpassword {
local curlurl="$1"
local curluser="$2"
local curlpassword="$3"
local curloutput="$4"
curl --fail --user "$curluser":"$curlpassword" "$curlurl" -o "$curloutput"
local EC=$?
if [ $EC -eq 0 ]; then
echo "Password correct"
else
echo "Password incorrect"
fi
}
```
Syntax: `getcurlsecwpassword <url to download> <username> <password> <output file>`
## curl keeps asking for password until correct, and stores username and password as var
```
function checkusercurl {
local curlurl="$1"
curluser="$2"
while true; do
read -s -p "Enter password for user $curluser: " curlpassword
echo "";
curl -s --fail --user "$curluser":"$curlpassword" "$curlurl" -o /dev/null
local EC=$?
if [ $EC -eq 0 ]; then
echo "Password correct"
break
fi
echo "Incorrect password"
unset curlpassword
done
}
```
Syntax: `checkusercurl <url to authenticate against> <username>`
username wil become var: curluser
password wil become var: $curlpassword