Path: blob/main/usr.sbin/bsdconfig/examples/browse_packages_http.sh
105216 views
#!/bin/sh1#2# This sample downloads the package digests.txz and packagesite.txz files from3# HTTP to /tmp (if they don't already exist) and then displays the package4# configuration/management screen using the local files (resulting in faster5# browsing of packages from-start since digests.txz/packagesite.txz can be6# loaded from local media).7#8# NOTE: Packages cannot be installed unless staged to9# /tmp/packages/$PKG_ABI/All10#11[ "$_SCRIPT_SUBR" ] || . /usr/share/bsdconfig/script.subr || exit 112nonInteractive=113f_musthavepkg_init # Make sure we have a usable pkg(8) with $PKG_ABI14TMPDIR=/tmp15PKGDIR=$TMPDIR/packages/$PKG_ABI16[ -d "$PKGDIR" ] || mkdir -p "$PKGDIR" || exit 117for file in digests.txz packagesite.txz; do18[ -s "$PKGDIR/$file" ] && continue19if [ ! "$HTTP_INITIALIZED" ]; then20_httpPath=http://pkg.freebsd.org21mediaSetHTTP22mediaOpen23fi24f_show_info "Downloading %s from\n %s" "$file" "$_httpPath"25f_device_get device_media "/$PKG_ABI/latest/$file" > $PKGDIR/$file ||26exit 127done28_directoryPath=$TMPDIR29mediaSetDirectory30configPackages313233