|
|
08abde |
#!/bin/bash
|
|
|
08abde |
#
|
|
|
08abde |
# verify_doLinkInstall.sh -- This function receives a list of missing
|
|
|
08abde |
# links and installs them using `ln'.
|
|
|
08abde |
#
|
|
|
08abde |
# Copyright (C) 2009-2010 Alain Reguera Delgado
|
|
|
08abde |
#
|
|
|
08abde |
# This program is free software; you can redistribute it and/or modify
|
|
|
08abde |
# it under the terms of the GNU General Public License as published by
|
|
|
08abde |
# the Free Software Foundation; either version 2 of the License, or
|
|
|
08abde |
# (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
|
|
|
08abde |
# links are not created yet, we use their targets as reference
|
|
|
08abde |
# to determine what type of link we are creating.
|
|
|
08abde |
if [[ -f ${TARGETS[$ID]} ]];then
|
|
|
08abde |
LINKS_PARENT=$(dirname ${LINKS[$ID]})
|
|
|
08abde |
cli_checkFiles $LINKS_PARENT 'd' '' '--quiet'
|
|
|
08abde |
if [[ $? -ne 0 ]];then
|
|
|
08abde |
mkdir -p $LINKS_PARENT
|
|
|
08abde |
fi
|
|
|
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.
|
|
|
08abde |
cli_checkFiles ${LINKS[$ID]} 'f' '' '--quiet'
|
|
|
08abde |
if [[ $? -eq 0 ]];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 |
}
|