|
|
08abde |
#!/bin/bash
|
|
|
08abde |
#
|
|
|
08abde |
# verify_doLinkInstall.sh -- This function receives a list of missing
|
|
|
08abde |
# links and installs them using `ln'.
|
|
|
08abde |
#
|
|
|
72c8a5 |
# Copyright (C) 2009-2011 Alain Reguera Delgado
|
|
|
08abde |
#
|
|
|
7cd8e9 |
# This program is free software; you can redistribute it and/or
|
|
|
7cd8e9 |
# modify it under the terms of the GNU General Public License as
|
|
|
7cd8e9 |
# published by the Free Software Foundation; either version 2 of the
|
|
|
7cd8e9 |
# License, or (at your option) any later version.
|
|
|
08abde |
#
|
|
|
08abde |
# This program is distributed in the hope that it will be useful, but
|
|
|
08abde |
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
08abde |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
08abde |
# General Public License for more details.
|
|
|
08abde |
#
|
|
|
08abde |
# You should have received a copy of the GNU General Public License
|
|
|
08abde |
# along with this program; if not, write to the Free Software
|
|
|
08abde |
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
|
|
08abde |
# USA.
|
|
|
08abde |
#
|
|
|
08abde |
# ----------------------------------------------------------------------
|
|
|
08abde |
# $Id$
|
|
|
08abde |
# ----------------------------------------------------------------------
|
|
|
08abde |
|
|
|
08abde |
function verify_doLinkInstall {
|
|
|
08abde |
|
|
|
08abde |
local ID=0
|
|
|
08abde |
local LINKS_PARENT=''
|
|
|
08abde |
local WARNING=''
|
|
|
08abde |
|
|
|
08abde |
for ID in $LINKS_MISSING_ID;do
|
|
|
08abde |
|
|
|
08abde |
# Verify parent directory of missing link names that have a
|
|
|
08abde |
# file as target. If the parent directory doesn't exist,
|
|
|
08abde |
# create it first before creating links inside it. Because
|
|
|
b76c02 |
# links are not created yet, we use their related targets as
|
|
|
b76c02 |
# reference to determine what type of link we are creating.
|
|
|
08abde |
if [[ -f ${TARGETS[$ID]} ]];then
|
|
|
08abde |
LINKS_PARENT=$(dirname ${LINKS[$ID]})
|
|
|
b76c02 |
cli_checkFiles $LINKS_PARENT 'd'
|
|
|
08abde |
fi
|
|
|
08abde |
|
|
|
08abde |
# Verify missing link that already exists as regular file. If
|
|
|
08abde |
# a regular file exists with the same name of a required link,
|
|
|
08abde |
# warn the user about it and continue with the next file in
|
|
|
08abde |
# the list of missing links that need to be installed.
|
|
|
b76c02 |
if [[ -f ${LINKS[$ID]} ]];then
|
|
|
08abde |
WARNING=" (`gettext "Already exists as regular file."`)"
|
|
|
08abde |
cli_printMessage "${LINKS[$ID]}${WARNING}" 'AsResponseLine'
|
|
|
08abde |
continue
|
|
|
08abde |
fi
|
|
|
08abde |
|
|
|
08abde |
# Create symbolic link.
|
|
|
08abde |
ln -s ${TARGETS[$ID]} ${LINKS[$ID]}
|
|
|
08abde |
|
|
|
08abde |
done
|
|
|
08abde |
|
|
|
08abde |
}
|