需要一些幫助來了解錯誤。 簡而言之:我編寫了一個bourne shell腳本,它創建指向目標目錄中源目錄內容的鏈接。 它在主機系統上工作正常,但是當針對掛載的fs上的目錄(來自chroot和本機系統)時,它不起作用,並且根本不提供任何輸出。sh腳本:在安裝的文件系統中運行時無輸出
詳細說明: 安裝FS:EXT3,RW
主機系統:3.2.0-48泛型#74-Ubuntu的SMP的GNU/Linux
要縮小的問題, 「/ USR」 取舉個例子。
權限在宿主系統 「的/ usr」 的。drwxr-XR-X上掛載的分區
權限 「的/ usr」 的。drwxr-XR-X
嘗試同時使用bash和破折號來自主機系統。相同的結果 - 適用於本機文件系統,不適用於掛載。
腳本(cord.sh;從根在我的情況下運行):
# !/bin/sh
SRCFOLDER=$2 # folder with package installation
DESTFOLDER=$3 # destination folder to install symlinks to ('/' - for base sys; '/usr' - userland)
TARGETS=$(ls $SRCFOLDER) # targets to handle
SRCFOLDER=${SRCFOLDER%/} # stripping slashes from the end, if they are present
DESTFOLDER=${DESTFOLDER%/} #
##
## LINKING
##
if [ "$1" = "-c" ];
then printf %s "$TARGETS" | while IFS= read -r line
do
current_target=$(file $SRCFOLDER/$line) # had an issue with different output in different systems
if [ "${current_target% }" = "$SRCFOLDER/$line: directory" ]; # stripping space helped
then
mkdir -v $DESTFOLDER/$line # if other package created it - it'll fail
/usr/local/bin/cord.sh -c $SRCFOLDER/$line $DESTFOLDER/$line # RECURSION
else
ln -sv $SRCFOLDER/$line $DESTFOLDER/$line # will fail, if exists
fi;
done
##
## REMOVING LINKS
##
elif [ "$1" = "-d" ];
then printf %s "$TARGETS" | while IFS= read -r line
do
current_target=$(file $SRCFOLDER/$line)
if [ "${current_target% }" = "$SRCFOLDER/$line: directory" ];
then
/usr/local/bin/cord.sh -d $SRCFOLDER/$line $DESTFOLDER/$line # RECURSION
else
rm -v $DESTFOLDER/$line
fi;
done
elif [ "$1" = "-h" ];
then
echo "Usage:"
echo "cord -c /path/to/pkgdir /path/to/linkdir - create simlinks for package contents"
echo "cord -d /path/to/pkgdir /path/to/linkdir - delete links for package"
echo "cord -h - displays this help note"
else
echo "Usage:"
echo "cord -c /path/to/pkgdir /path/to/linkdir - create simlinks for package contents"
echo "cord -d /path/to/pkgdir /path/to/linkdir - delete links for package"
echo "cord -h - displays this help note"
fi;
最明顯的一點暗示,是一些問題的權限。然而一切看起來都很健康。也許我錯過了什麼?
呃......現在我感到羞愧。不是要發明另一輛自行車。我在基本系統中沒有'lndir',並且不知道它。謝謝。 –
哦!是否有東西可以刪除創建的鏈接?例如,鏈接到'/ usr'的'/ usr/packages/foo'內容。需要某些東西來刪除鏈接只包'foo'。 –