aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristos.K <freedomrfox@gmail.com>2017-08-29 18:01:24 +0300
committerChristos.K <freedomrfox@gmail.com>2017-08-29 18:01:24 +0300
commit421fda85243f6892e18bd1744f34c2248baa138f (patch)
tree5df3e151239c272feebb0407f2db25ebdb26d382
parentIncluded cp as well (diff)
downloadGSE-421fda85243f6892e18bd1744f34c2248baa138f.tar.gz
GSE-421fda85243f6892e18bd1744f34c2248baa138f.tar.bz2
GSE-421fda85243f6892e18bd1744f34c2248baa138f.zip
Dracut's modules rdep check
-rwxr-xr-xscripts/functions/sinit_functions100
1 files changed, 81 insertions, 19 deletions
diff --git a/scripts/functions/sinit_functions b/scripts/functions/sinit_functions
index eb89685..eb93abb 100755
--- a/scripts/functions/sinit_functions
+++ b/scripts/functions/sinit_functions
@@ -644,7 +644,7 @@ _lcreq() {
if _am_i_root_sub "$UID"; then
echo -e "[\e[32m*\e[0m] Root privileges found"
emerge -aq eix && echo -e "[\e[33m*\e[0m] \e[35mUpdating database\e[0m"
- eval eix-sync -a "${_flag_silence}"
+ eval eix-sync -a >/dev/null
else
echo -e "[\e[31m*\e[0m] Could not get root privileges"
die "Please resolve this issue and start again"
@@ -655,7 +655,7 @@ _lcreq() {
for i in "${lreq[@]}"; do
sleep 0.1
- if eval eix --installed "$i" "${_flag_silence}"; then
+ if eval eix --installed "$i" >/dev/null; then
echo -e "[\e[32m*\e[0m] Searching for \e[32m$i\e[0m"
else
echo -e "[\e[31m*\e[0m] Searching for $i"
@@ -869,9 +869,7 @@ controller_f() {
_make_cimage() {
_KVER_="$(uname -r)"
- mkdir -p "/usr/lib64/dracut/modules.d/01controller"
- cp -r "${CCONFDIR}/controller/modules"/* "/usr/lib64/dracut/modules.d/01controller"
-
+
_dracut_f() {
echo "$@"
dracut "$@" --show-modules \
@@ -889,6 +887,44 @@ _make_cimage() {
die
fi
+ _check_dr_mods() {
+ if ! [[ $(command -v eix) ]]; then
+ echo -e "[\e[33m*\e[0m] \e[35mPlease install eix to proceed!\e[0m"
+ if _am_i_root_sub "$UID"; then
+ echo -e "[\e[32m*\e[0m] Root privileges found"
+ emerge -aq eix && echo -e "[\e[33m*\e[0m] \e[35mUpdating database\e[0m"
+ eval eix-sync -a >/dev/null
+ else
+ echo -e "[\e[31m*\e[0m] Could not get root privileges"
+ die "Please resolve this issue and start again"
+ fi
+ fi
+
+ _ct_dr_req=("sys-apps/pciutils" "sys-fs/btrfs-progs" "sys-fs/cryptsetup" "app-crypt/gnupg" \
+ "sys-block/open-iscsi" "sys-block/nbd" "net-fs/nfs-utils" "net-nds/rpcbind" "sys-kernel/dracut" \
+ "dev-libs/openssl" "app-admin/syslog-ng" "sys-fs/device-mapper" "net-misc/dhcp" "sys-apps/iproute2")
+
+ for i in "${_ct_dr_req[@]}"; do
+ sleep 0.1
+ if eval eix --installed "$i" >/dev/null; then
+ echo -e "[\e[32m*\e[0m] Searching for \e[32m$i\e[0m"
+ else
+ echo -e "[\e[31m*\e[0m] Searching for $i"
+ echo -e "[\e[33m*\e[0m] Attempting to resolve the missing dependency"
+ if _am_i_root $UID && echo -e "[\e[32m*\e[0m] Root privileges found"; then
+ emerge -aq "$i"
+ else
+ echo -e "[\e[31m*\e[0m] Could not get root privileges"
+ die "Please resolve this issue and start again"
+ fi
+ fi
+ done
+ }
+
+ _e_report_back "Checking for controller dependencies"
+
+ _check_dr_mods
+
if [[ ! -e "/usr/lib64/dracut/modules.d/01controller" ]]; then
mkdir -p "/usr/lib64/dracut/modules.d/01controller"
else
@@ -2313,13 +2349,32 @@ _prepare_chroot() {
echo -e "[\e[32m*\e[0m] Copying requested files"
if [[ -n $(cat ${CCONFDIR}/system/inject_files | sed '/^#/ d' | sed '/^\s*$/d') ]]; then
+ INJFLERR=()
while read -r INJFL; do
- f1="$(echo $INJFL | awk -F ' ' '{ print $1 }')"
- f2="${BWORKDIR}/(echo $INJFL | awk -F ' ' '{ print $2 }')"
- echo "Copying $f1 to $f2"
- eval rsync -aAXPhrv "$f1" "$f2" "${_flag_silence}" \
- && pass || { mapfile -t INJFLERR < <($INJFL | awk -F ' ' '{ print $1 }'); }
+ _case_var="$(echo ${INJFL} | awk -F ' ' '{print $1}')"
+ f1="$(echo "${INJFL}" | awk -F ' ' '{ print $2 }')"
+ f2="${BWORKDIR}/$(echo "${INJFL}" | awk -F ' ' '{ print $3 }')"
+
+ case "${_case_var}" in
+ rsync)
+ echo "Syncing ${f1} to ${f2}"
+ if eval rsync -aAPhrv "${f1}" "${f2}" "${_flag_silence}"; then
+ pass
+ else
+ INJFLERR+=("${f1}")
+ fi;;
+ cp)
+ if eval cp -r "${f1}" "${f2}" "${_flag_silence}"; then
+ pass
+ else
+ INJFLERR+=("${f1}")
+ fi
+ ;;
+ *)
+ echo "Unknown ${_case_var} entry"
+ esac
+
done < <(cat "${CCONFDIR}/system/inject_files" | sed '/^#/ d' | sed '/^\s*$/d')
unset INJFL
@@ -2330,26 +2385,30 @@ _prepare_chroot() {
echo "You can list the failed files again, continue, request terminal or exit"
echo "Please choose: LIST/CONTINUE/TERMINAL/EXIT"
read -rp "Input :: <= " INJFLANS
- case "$INJFLANS" in
+ case "${INJFLANS}" in
LIST)
- clear; echo "${INJFLERR[@]}";;
+ clear; echo "${INJFLERR[@]}"
+ ;;
CONTINUE)
while true; do
echo "Are you sure? Y/N "
- read -p "Input :: <= " YN
+ read -rp "Input :: <= " YN
case "${YN}" in
[yY])
echo "Proceeding"
INJFLESC=0
- break;;
+ break
+ ;;
[nN])
INJFLESC=1
;;
esac
- done;;
+ done
+ ;;
TERMINAL)
_subshell
- INJFLESC=0;;
+ INJFLESC=0
+ ;;
EXIT)
while true; do
echo "Are you sure? Y/N "
@@ -2357,12 +2416,15 @@ _prepare_chroot() {
case $YN in
[yY])
echo "Aborting..."
- exit 0;;
+ exit 0
+ ;;
[nN])
INJFLESC=1
- break;;
+ break
+ ;;
esac
- done;;
+ done
+ ;;
esac
[[ "$INJFLESC" == 0 ]] && break
done