#!/bin/bash
#
# Author: Honza Horak <hhorak@redhat.com>
#
# Description:
# This script checks if there are some maps generated and generates
# a warning that maps should be re-generated after upgrade.


#Preupgrade Assistant performs system upgradability assessment
#and gathers information required for successful operating system upgrade.
#Copyright (C) 2013 Red Hat Inc.
#Honza Horak <hhorak@redhat.com>
#
#This program 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
#(at your option) any later version.
#
#This program 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 this program.  If not, see <http://www.gnu.org/licenses/>.
. /usr/share/preupgrade/common.sh
check_applies_to "ypserv"
#END GENERATED SECTION

check_root

. ../common.sh

ypserv_maps_exist || exit $RESULT_NOT_APPLICABLE

read -r -d '' PROBLEM_MESSAGE <<'EOF'
The ypserv package in Red Hat Enterprise Linux 7 uses TokyoCabinet as a back-end library to store
generated NIS maps, while in Red Hat Enterprise Linux 6 it was GDBM. As a consequence, the
map files generated on Red Hat Enterprise Linux 6 will not be readable on Red Hat Enterprise Linux 7.

It is advised to re-generate maps after the upgrade.
EOF

log_high_risk "$PROBLEM_MESSAGE"

read -r -d '' PROBLEM_SOLUTION <<EOF
${PROBLEM_MESSAGE}

In order to re-generate the maps, run manually (as root):
# systemctl start ypserv.service
# make NOPUSH=true -C /var/yp all
EOF

solution_file "$PROBLEM_SOLUTION"

exit $RESULT_FAILED
