Last active
June 25, 2022 11:18
-
-
Save adlerweb/031472145bcba78d2e7b1e1b3a41298d to your computer and use it in GitHub Desktop.
Unattended deployment of yay on a system. Useful when generating VMs on the fly.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
version=$(git -c 'versionsort.suffix=-' ls-remote --exit-code --refs --sort='version:refname' --tags https://github.com/Jguer/yay.git '*.*.*' | tail --lines=1 | cut --delimiter='/' --fields=3 | tr -d 'v') | |
url="https://github.com/Jguer/yay/releases/download/v${version}/yay_${version}_x86_64.tar.gz" | |
tmp=$(mktemp -d) | |
if [ -d "$tmp" ] | |
then | |
if [ "$(ls -A $tmp)" ]; then | |
echo "Oops. Temporary directory $tmp is not empty" | |
exit 1 | |
fi | |
else | |
echo "Oops. Temporary directory $tmp not found" | |
exit 1 | |
fi | |
pushd "$tmp" | |
wget $url && \ | |
tar xvaf yay_*.tar.* && \ | |
rm yay_*.tar.* && \ | |
cd yay_* && \ | |
./yay -Y --gendb && \ | |
./yay -Syu --devel --noconfirm && \ | |
./yay -Y --devel --save && \ | |
./yay -S yay --noconfirm | |
popd | |
if compgen -G "$tmp/yay_*" > /dev/null ; then | |
rm -Rv "$tmp"/yay_* | |
fi | |
rmdir "$tmp" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- name: Deploy yay | |
ansible.builtin.shell: | | |
if ! command -v yay &> /dev/null ;then | |
version=$(git -c 'versionsort.suffix=-' ls-remote --exit-code --refs --sort='version:refname' --tags https://github.com/Jguer/yay.git '*.*.*' | tail --lines=1 | cut --delimiter='/' --fields=3 | tr -d 'v') | |
url="https://github.com/Jguer/yay/releases/download/v${version}/yay_${version}_x86_64.tar.gz" | |
tmp=$(mktemp -d) | |
if [ -d "$tmp" ] | |
then | |
if [ "$(ls -A $tmp)" ]; then | |
echo "Oops. Temporary directory $tmp is not empty" | |
exit 1 | |
fi | |
else | |
echo "Oops. Temporary directory $tmp not found" | |
exit 1 | |
fi | |
pushd "$tmp" | |
wget $url && \ | |
tar xvaf yay_*.tar.* && \ | |
rm yay_*.tar.* && \ | |
cd yay_* && \ | |
./yay -Y --gendb && \ | |
./yay -Syu --devel --noconfirm && \ | |
./yay -Y --devel --save && \ | |
./yay -S yay --noconfirm | |
popd | |
if compgen -G "$tmp/yay_*" > /dev/null ; then | |
rm -Rv "$tmp"/yay_* | |
fi | |
rmdir "$tmp" | |
fi | |
args: | |
executable: /bin/bash |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment