You are not logged in.
I must be missing something, why curl a snapshot then untar it? Is that just to prevent requiring 'git'?
"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" - Richard Stallman
Offline
No, it's just an old script I never updated to use git;-) which still works fine to get 'any' package from AUR
What I meant is he can convert his script to use it with any package instead of a script for every package...
edit: and here's that part rewritten for git;-)
buildir="$HOME"/build
prog=$1
get() {
[ -d "$buildir/$prog" ] && mv "$buildir/$prog" "$buildir/${prog}.bak"
cd "$buildir" || exit
git clone https://aur.archlinux.org/"${prog}"
}
get
build() {
cd "${buildir}"/"${prog}" || exit
makepkg --noconfirm -sic
}
build
edit: add or exit) & build
Last edited by qinohe (2022-03-08 01:43:48)
Offline
Or get 'any' package you want and get on building it the way you like, my get part:
url='https://aur.archlinux.org/cgit/aur.git/snapshot/' buildir="$HOME"/build prog=$2 _get() { [ -d "$buildir/$prog" ] && mv "$buildir/$prog" "$buildir/${prog}.bak" curl -sL "${url}${prog}.tar.gz" -o "$buildir/${prog}.tar.gz" tar zxvf "$buildir/${prog}.tar.gz" -C "$buildir" #&& rm "$buildir/${prog}.tar.gz" } _get "$@"
I mean your two scripts are for one package each, which you could make into 'one rules them all';-) mostly that is!
Nice ... I like that idea. I'll have a go at it when I'm not crazy busy.
Offline
Yeah, then be sure to use the git one from #3677 although the one you quoted works fine too.
Also be sure it exits when not finding the 'buildir', I'll add it to the script...
edit: I added a build part too, do with it what you like!
edit: Ow, and I also forgot to say, you don't need to cd to '/tmp'.. what for?
That's something you set in makepkg.conf, mostly;-)
Last edited by qinohe (2022-03-08 02:04:27)
Offline
wget/linode speedtest for reference
Some superfluous polish..
#!/bin/bash
locations=("Newark, USA" "newark"
"Singapore" "singapore"
"London, UK" "london"
"Frankfurt, Deutschland" "frankfurt"
"Dallas, USA" "dallas"
"Toronta, Canada" "toronto1"
"Sydney, Australia" "syd1"
"Atlanta, USA" "atlanta"
"Tokyo, Japan" "tokyo2"
"Bombay, India" "mumbai1"
"Fremont, USA" "fremont")
sizes=("100MB" "1GB")
for ((i=0; i<${#locations[@]}; i+=2)); do
locs[$i]="${locations[$i]}"
done
echo
PS3=$'\n'"Enter location: "
select t in "${locs[@]}"; do
location="${locations[(($REPLY*2-1))]}"
[[ $REPLY -ge 1 && $REPLY -le ${#locs[@]} ]] && break
done
unset REPLY
echo
PS3=$'\n'"Select size: "
select size in "${sizes[@]}"; do
[[ $REPLY -ge 1 && $REPLY -le ${#sizes[@]} ]] && break
done
echo
[[ -n "${location}" && -n "${size}" ]] && wget -nv --show-progress -O /dev/null "http://speedtest.${location}.linode.com/${size}-${location}.bin"
Last edited by Tarqi (2022-03-09 00:22:44)
Knowing others is wisdom, knowing yourself is enlightenment. ~Lao Tse
Offline
A simple script to check your internal and external IP addresses..
Bash function, useful for own or foreign IPs. The AWK is a bit weird regarding the ordering of the variables, if someone can shed some light on this...
ipi ()
{
curl -s "https://ipapi.co/$*/yaml" | awk '/ip:/{IP=$2} /asn:/{ASN=$2} /city:/{$1="";CITY=$0;} /country_name:/{$1="";COUNTRY=$0} /org:/{$1="";print IP ", " ASN "," $0 "," CITY "," COUNTRY}'
}
Bash function for local IPs:
ips ()
{
ip -c -o a | awk '{print $2,$4}' | column -t
}
Last edited by Tarqi (2022-03-09 00:30:03)
Knowing others is wisdom, knowing yourself is enlightenment. ~Lao Tse
Offline
Why parse yaml with awk? Just get the json and use jq? I gather you've not seen posts 3661-3663 in this very thread ... as an identical goal was discussed with examples.
"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" - Richard Stallman
Offline
I saw the posts, the goal was not to use jq, as it is not installed as default on some systems I administrate, but AWK is. And YAML is (in this case) more friendly for parsing with AWK.
Last edited by Tarqi (2022-03-09 00:26:35)
Knowing others is wisdom, knowing yourself is enlightenment. ~Lao Tse
Offline
In that case, you should probably use awk's -F option as below. I also threw in a sed version if you don't care about the order of the fields (and just used a google ip for demonstration purposes):
#!/bin/sh
curl -s "https://ipapi.co/8.8.8.8/yaml" | awk -F': ' '
/ip:/ { ip=$2 }
/asn:/{ asn=$2 }
/city:/{ city=$2;}
/country_name:/ { country=$2}
/org:/{ printf "%s, %s, %s, %s, %s\n", ip, asn, $2, city, country; }'
curl -s "https://ipapi.co/8.8.8.8/yaml" | sed -n '
/^\(ip\|asn\|city\|country_name\|org\):/{s/[^:]*: //;H;}
${x;s/\n//;s/\n/, /g;p;}'
And once you used the colon as the field separator, it becomes even easier:
curl -s "https://ipapi.co/8.8.8.8/yaml" | awk -F': ' '{ v[$1]=$2; }
END { printf "%s, %s, %s, %s, %s\n", v["ip"], v["asn"], v["org"], v["city"], v["country_name"]; }'
Last edited by Trilby (2022-03-09 00:58:58)
"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" - Richard Stallman
Offline
I missed the field separator somehow... and the solution with the "dynamic dictionary" is great, thanks for that.
Knowing others is wisdom, knowing yourself is enlightenment. ~Lao Tse
Offline
Entering a directory via a symlink, and not quite sure where you really are on the file system?
The really alias that does cd "`pwd -P` has been useful to me.
For easy copy&paste to ie. .zshrc:
alias really="cd \"\`pwd -P\`\""
(yes, the backticks can probably be replaced with $())
Offline
The backticks and backslashes can all be removed:
alias really='cd "$(pwd -P)"'
However, that readlly doesn't do anything at all. The only result I could imagine it having is changing how the current working directory is displayed in a prompt string if you use it there. But if what you really want in the prompt string is the actual path with symlinks resolved, you don't need an alias that you'll run manually, just write your prompt command to show what you actually want in the first place.
Last edited by Trilby (2022-04-07 13:39:17)
"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" - Richard Stallman
Offline
cd -P .
Солідарність з Україною
Offline
My favorite script I've written is a simple and elegant templating engine.
tmpl.sh
#!/bin/sh
EOF=EOF
exec cat <<EOF | sh
cat <<EOF
$(cat $1 | \
sed 's|\\|\\\\|g' | \
sed 's|`|\\`|g' | \
sed 's|\$|\\\$|g' | \
sed "s|${OPEN:-<%}|\`eval echo |g" | \
sed "s|${CLOSE:-%>}| 2>/dev/null \`|g")
$EOF
EOF
You can read more about it at the link below.
https://stackoverflow.com/a/72775596/5179133
Last edited by clayrisser (2022-06-27 16:56:22)
Offline