Skip to content

Instantly share code, notes, and snippets.

@lattera
Created June 26, 2015 08:31
Show Gist options
  • Save lattera/0e99814bbdfd65df2e36 to your computer and use it in GitHub Desktop.
Save lattera/0e99814bbdfd65df2e36 to your computer and use it in GitHub Desktop.
Package mount
#!/usr/local/bin/zsh
repo=""
thing=""
usage() {
cat<<EOF
USAGE: ${0} -r <repo> -t <syncdir>
-r <repo>: repository (eg, /pkg/hardenedbsd-11-current-amd64)
-t <syncdir>: sync directory (eg, sync1)
This script creates a symbolic link at \${repo} pointing to \${repo}-\${syncdir}
EOF
exit 1
}
while getopts 'r:t:' o; do
case "${o}" in
r)
repo="${OPTARG}"
;;
t)
thing="${OPTARG}"
;;
esac
done
if [ -z "${repo}" ]; then
usage
fi
if [ -z "${thing}" ]; then
usage
fi
if [ ! -d ${repo}-${thing} ]; then
echo "ERROR: ${repo}-${thing} not found"
exit 1
fi
if [ -e ${repo} ]; then
rm ${repo}
if [ ! ${?} -eq 0 ]; then
exit ${?}
fi
fi
ln -s ${repo}-${thing} ${repo}
exit ${?}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment