Skip to content

Instantly share code, notes, and snippets.

@DavidePrincipi
Last active October 14, 2020 07:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DavidePrincipi/ef196d05287c46be716cf9e20bf66fd0 to your computer and use it in GitHub Desktop.
Save DavidePrincipi/ef196d05287c46be716cf9e20bf66fd0 to your computer and use it in GitHub Desktop.
Additional "local" YUM repository for CentOS and NethServer 7 systems
#!/bin/bash
#
# Copyright (C) 2017-2020 Nethesis S.r.l.
# http://www.nethesis.it - nethserver@nethesis.it
#
# This script is part of NethServer.
#
# NethServer is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License,
# or any later version.
#
# NethServer is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with NethServer. If not, see COPYING.
#
#
# Invoke as
# update-local-repo <vmip> <rpm> [rpm]...
#
# Prerequisites:
#
# - ssh pubkey authentication at <vmip>
#
# vmip: target IP address where to create the YUM repository under /srv/local path
#
VMIP=$1
REPODIR=${REPODIR:-/srv/local}
shift
if [[ -z $1 || "$1" != *.rpm ]]; then
echo "Usage: $0 IP_ADDR RPM [RPM] ..." 1>&2
exit 1
fi
set -e
ssh root@${VMIP} "cat - > /etc/yum.repos.d/local.repo" <<EOF
[local]
name=local
gpgcheck=0
enabled=1
baseurl=file://${REPODIR}
EOF
ssh root@${VMIP} "[[ -f /etc/nethserver-release ]] && mkdir -p /etc/e-smith/templates-custom/etc/nethserver/eorepo.conf && echo -n '{ push @repos, \"local\"; \$OUT=\"\"; }' > /etc/e-smith/templates-custom/etc/nethserver/eorepo.conf/40local && expand-template /etc/nethserver/eorepo.conf"
tar -c "$@" | ssh root@${VMIP} "test -x /usr/bin/createrepo || yum -q -y --disablerepo=local install createrepo ; mkdir -p ${REPODIR} ; cd ${REPODIR} ; tar -x -f - ; createrepo . ; yum clean --disablerepo=* --enablerepo=local metadata"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment