gfontinstallermac/GFontInstaller.sh

64 lines
1.6 KiB
Bash
Raw Normal View History

2021-01-09 07:32:16 -05:00
#!/bin/bash
2023-08-09 14:32:30 -04:00
SCRIPTLOC="https://gitlab.tfmm.co/tfmm/GFontInstallerMac/-/raw/master/fontupdater.sh"
2021-01-09 07:32:16 -05:00
#Check for root
if [[ $EUID -ne "0" ]]
then
echo "You must be root - try: sudo $0 or sudo bash $0"
exit 1
fi
#Ask for user
echo "Please enter the username for which you would like Google Fonts installed: "
read username
#Ask for update frequency
PS3="Please enter the frequency at which you would like the fonts updated (daily/weekly/monthly):"
options=("Daily (Not Recommended)" "Weekly" "Monthly" "Quit")
select opt in "${options[@]}"
do
case $opt in
"Daily (Not Recommended)")
updatefreq=daily
2021-01-11 15:59:14 -05:00
break
2021-01-09 07:32:16 -05:00
;;
"Weekly")
updatefreq=weekly
2021-01-11 15:59:14 -05:00
break
2021-01-09 07:32:16 -05:00
;;
"Monthly")
updatefreq=monthly
2021-01-11 15:59:14 -05:00
break
2021-01-09 07:32:16 -05:00
;;
"Quit")
break
;;
*) echo "invalid option $REPLY";;
esac
done
#Setup directory in /opt and fetch script
mkdir -p /opt/gfontinstallermac
2023-08-09 14:32:30 -04:00
wget -O /opt/gfontinstallermac/fontupdater.sh $SCRIPTLOC
2021-01-09 07:32:16 -05:00
chmod +x /opt/gfontinstallermac/fontupdater.sh
#Setup config file
touch /opt/gfontinstallermac/config
echo "USER=$username" >> /opt/gfontinstallermac/config
#Run initial git clone
pushd /Users/$username/Library/Fonts/
git clone https://github.com/google/fonts.git google-fonts
chown -R $username:staff google-fonts
popd
#Setup auto-update
mkdir -p /usr/local/etc/periodic/$updatefreq
2021-01-11 15:59:14 -05:00
ln -sf /opt/gfontinstallermac/fontupdater.sh /usr/local/etc/periodic/$updatefreq/fontupdater
2021-01-09 07:32:16 -05:00
#Finished
2021-01-11 15:59:14 -05:00
echo "Google Fonts installed in /Users/$username/Library/Fonts and set to update $updatefreq."