https://www.chovits.jp
/
chroot_mk.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
0542e9e
)
/etc/profile.d/{which2.sh,which2.sh} 削除 /proc配下を見ている為
master
author
dev
<dev>
Tue, 18 Oct 2022 10:59:16 +0000
(10:59 +0000)
committer
dev
<dev>
Tue, 18 Oct 2022 10:59:16 +0000
(10:59 +0000)
chroot.sh
patch
|
blob
|
history
diff --git
a/chroot.sh
b/chroot.sh
index e86a4f9e41fe1db0c9054e2bf62985d731bd1545..e78674f099b1c4d531848a2016d7d4585f38c71f 100755
(executable)
--- a/
chroot.sh
+++ b/
chroot.sh
@@
-14,7
+14,7
@@
# - このスクリプトでchroot環境を構築後に、スクリプト再実行すると上書きされる
# ので、chroot環境のファイルを修正した場合は、注意する事
#
# - このスクリプトでchroot環境を構築後に、スクリプト再実行すると上書きされる
# ので、chroot環境のファイルを修正した場合は、注意する事
#
-# $Id: chroot.sh,v 1.
2 2022/10/18 08:43:47
dev Exp $
+# $Id: chroot.sh,v 1.
3 2022/10/18 10:59:16
dev Exp $
#
#####################################################################################
#
#####################################################################################
@@
-48,6
+48,7
@@
LINKED_DIRS=(
/etc/profile.d
/usr/share/terminfo
)
/etc/profile.d
/usr/share/terminfo
)
+
LINKED_FILES=(
/etc/profile
/etc/bashrc
LINKED_FILES=(
/etc/profile
/etc/bashrc
@@
-59,8
+60,14
@@
LINKED_FILES=(
/usr/libexec/grepconf.sh
)
/usr/libexec/grepconf.sh
)
+DELETE_FILES=(
+ /etc/profile.d/which2.csh
+ /etc/profile.d/which2.sh
+)
+
# Init
# Init
-FLG=0
+ALL_CMDLIST=("${CMD_LIST[@]} ${REQUIRED_CMD[@]}")
+
EXEC_CMD=(
/usr/bin/which
/usr/bin/install
EXEC_CMD=(
/usr/bin/which
/usr/bin/install
@@
-70,17
+77,18
@@
EXEC_CMD=(
/usr/bin/chmod
)
/usr/bin/chmod
)
+FLG=0
for valf in ${EXEC_CMD[@]}
do
for valf in ${EXEC_CMD[@]}
do
- if [ ! -x $valf ]; then
- echo "File ($valf) not found"
- FLG=1
- fi
+
if [ ! -x $valf ]; then
+
echo "File ($valf) not found"
+
FLG=1
+
fi
done
if [ $FLG -eq 1 ]; then
done
if [ $FLG -eq 1 ]; then
- echo "--- Error ---"
- exit 1
+
echo "--- Error ---"
+
exit 1
fi
# Main
fi
# Main
@@
-110,7
+118,7
@@
do
done
# 利用コマンドとライブラリーのコピー
done
# 利用コマンドとライブラリーのコピー
-for valp in `which $
CMD_
LIST`;
+for valp in `which $
ALL_CMD
LIST`;
do
# command
test -e ./$valp && continue
do
# command
test -e ./$valp && continue
@@
-119,11
+127,11
@@
do
# library
LIBS=`ldd $valp | awk '{ print $3 }'`
if [ ${#LIBS[*]} -gt 0 ]; then
# library
LIBS=`ldd $valp | awk '{ print $3 }'`
if [ ${#LIBS[*]} -gt 0 ]; then
- for valf in $LIBS;
- do
- test ! -d `dirname ${CHG_ROOT}$valf` && install -m 0755 -o root -g root -d `dirname ${CHG_ROOT}$valf`
- test ! -f ${CHG_ROOT}$valf && cp -p $valf ./$valf
- done
+
for valf in $LIBS;
+
do
+
test ! -d `dirname ${CHG_ROOT}$valf` && install -m 0755 -o root -g root -d `dirname ${CHG_ROOT}$valf`
+
test ! -f ${CHG_ROOT}$valf && cp -p $valf ./$valf
+
done
fi
done
fi
done
@@
-140,6
+148,12
@@
test ! -c ${CHG_ROOT}/dev/random && mknod ${CHG_ROOT}/dev/random c 1 8
test ! -c ${CHG_ROOT}/dev/urandom && mknod ${CHG_ROOT}/dev/urandom c 1 9
chmod 0666 ${CHG_ROOT}/dev/{null,zero,random,urandom}
test ! -c ${CHG_ROOT}/dev/urandom && mknod ${CHG_ROOT}/dev/urandom c 1 9
chmod 0666 ${CHG_ROOT}/dev/{null,zero,random,urandom}
+# ディレクトリコピー後の指定ファイルの削除
+for valf in ${DELETE_FILES[@]}
+do
+ test -f ${CHG_ROOT}$valf && rm -f ${CHG_ROOT}$valf
+done
+
# rootユーザー情報の追加
grep /etc/passwd -e "^root" > ${CHG_ROOT}/etc/passwd
grep /etc/group -e "^root" > ${CHG_ROOT}/etc/group
# rootユーザー情報の追加
grep /etc/passwd -e "^root" > ${CHG_ROOT}/etc/passwd
grep /etc/group -e "^root" > ${CHG_ROOT}/etc/group