Here is a script that installs missing LaTeX packages.
#!/bin/bash
EMPHASISCOLOR="\e[7m"
RESETEMPHASIS="\e[27m"
DEFAULTCOLOR="\e[39m"
GREENCOLOR="\e[32m"
LIGHGRAYCOLOR="\e[37m"
BLUECOLOR="\e[34m"
YELLOWCOLOR="\e[93m"
echo -e "************************************************************************"
echo -e "* LaTeX Package Installer"
echo -e "************************************************************************"
printf "* Checking dependencies....... "
# check if required programs are installed
hash apt-file 2>/dev/null || { echo >&2 "false\nI require apt-file but it's not installed. Aborting."; exit 1; }
echo -e "${GREENCOLOR}ok${DEFAULTCOLOR}"
printf "* Packet name................. "
if [ -z "$1" ]; then
echo -e "${YELLOWCOLOR}Please provide a packet name as argument$DEFAULTCOLOR";
exit 1
else
PACKETNAME=$1;
echo -e "${GREENCOLOR}$PACKETNAME$DEFAULTCOLOR";
fi
RESULT=`apt-file -x search "/${PACKETNAME}$"`
# if package is found, result is
# texlive-latex-extra: /usr/share/texlive/texmf-dist/tex/latex/preprint/balance.sty
# otherwise, result is empty
# exit code from apt-file is 0 in either case
IFS=':' read -a myarray <<< "$RESULT"
APTPACKAGE=${myarray[0]}
printf "* Result...................... "
if [[ $RESULT ]]; then
echo -e "${GREENCOLOR}$APTPACKAGE$DEFAULTCOLOR";
else
echo -e "${YELLOWCOLOR}no apt package found$DEFAULTCOLOR";
exit 0
fi
echo "* Installing APT package...... "
sudo apt-get install $APTPACKAGE
echo -e "************************************************************************"
exit 0
#!/bin/bash
EMPHASISCOLOR="\e[7m"
RESETEMPHASIS="\e[27m"
DEFAULTCOLOR="\e[39m"
GREENCOLOR="\e[32m"
LIGHGRAYCOLOR="\e[37m"
BLUECOLOR="\e[34m"
YELLOWCOLOR="\e[93m"
echo -e "************************************************************************"
echo -e "* LaTeX Package Installer"
echo -e "************************************************************************"
printf "* Checking dependencies....... "
# check if required programs are installed
hash apt-file 2>/dev/null || { echo >&2 "false\nI require apt-file but it's not installed. Aborting."; exit 1; }
echo -e "${GREENCOLOR}ok${DEFAULTCOLOR}"
printf "* Packet name................. "
if [ -z "$1" ]; then
echo -e "${YELLOWCOLOR}Please provide a packet name as argument$DEFAULTCOLOR";
exit 1
else
PACKETNAME=$1;
echo -e "${GREENCOLOR}$PACKETNAME$DEFAULTCOLOR";
fi
RESULT=`apt-file -x search "/${PACKETNAME}$"`
# if package is found, result is
# texlive-latex-extra: /usr/share/texlive/texmf-dist/tex/latex/preprint/balance.sty
# otherwise, result is empty
# exit code from apt-file is 0 in either case
IFS=':' read -a myarray <<< "$RESULT"
APTPACKAGE=${myarray[0]}
printf "* Result...................... "
if [[ $RESULT ]]; then
echo -e "${GREENCOLOR}$APTPACKAGE$DEFAULTCOLOR";
else
echo -e "${YELLOWCOLOR}no apt package found$DEFAULTCOLOR";
exit 0
fi
echo "* Installing APT package...... "
sudo apt-get install $APTPACKAGE
echo -e "************************************************************************"
exit 0
No comments:
Post a Comment