try change file mode to 775

pull/23/head
johndah4x0r 2017-07-28 14:02:50 +02:00 committed by GitHub
parent f9a10045dc
commit c9f386984d
1 changed files with 133 additions and 116 deletions

View File

@ -37,7 +37,7 @@ NC=""
# debug related # debug related
debug_start() debug_start()
{ {
if grep -q debug /proc/cmdline; then if grep -q 'debug' /proc/cmdline; then
DEBUG_IS_ENABLED=1 DEBUG_IS_ENABLED=1
else else
DEBUG_IS_ENABLED= DEBUG_IS_ENABLED=
@ -170,15 +170,15 @@ mkbund()
debug_log "mkbund" "$*" debug_log "mkbund" "$*"
if [ -e "$2" ]; then if [ -e "$2" ]; then
echo_warn "mkbund: `basename $2`: File already exists!" echo_warn "mkbund: $(basename $2): File already exists!"
echo_warn "mkbund: `basemane $2`: Deleting file..." echo_warn "mkbund: $(basename $2): Deleting file..."
rm -f "$2" rm -f "$2"
else else
echo_livekit_msg "mkbund: `basename $2`: Making new bundle..." echo_livekit_msg "mkbund: $(basename $2): Making new bundle..."
fi fi
echo_livekit_msg "mkbund: SquashFS compression: 1024k - XZ" >&2 echo_livekit_msg "mkbund: SquashFS compression: 1024k - XZ" >&2
echo_livekit_msg "mkbund: `basename $2`: Compressing bundle..." >&2 echo_livekit_msg "mkbund: $(basename $2): Compressing bundle..." >&2
mksquashfs "$1" "$2" -comp xz -b 1024k $3 $4 $5 $6 $7 $8 $9 >/dev/null || \ mksquashfs "$1" "$2" -comp xz -b 1024k $3 $4 $5 $6 $7 $8 $9 >/dev/null || \
(echo_err "mkbund: Failed to make bundle!" && exit 1) (echo_err "mkbund: Failed to make bundle!" && exit 1)
} }
@ -201,16 +201,16 @@ cmdline_value()
# #
transfer_initramfs() transfer_initramfs()
{ {
if [ ! -r /lib/initramfs_escaped ]; then if [ ! -r /lib/esc_initramfs.sgn ]; then
echo_livekit >&2 echo_livekit >&2
echo "Switching root from initramfs to tmpfs..." >&2 echo "Switching root from initramfs to tmpfs..." >&2
SWITCH=/m # one letter directory SWITCH=/m # one letter directory
mkdir -p $SWITCH mkdir -p $SWITCH
mount -t tmpfs -o size="100%" tmpfs $SWITCH mount -t tmpfs -o size="100%" tmpfs "$SWITCH"
cp -a /??* $SWITCH 2>/dev/null # only copy two-and-more-letter directories cp -a /??* "$SWITCH" 2>/dev/null # only copy two-and-more-letter directories
cd $SWITCH cd $SWITCH
echo "This file indicates that we successfully escaped initramfs" > $SWITCH/lib/initramfs_escaped echo "This file indicates that we successfully escaped initramfs" >"$SWITCH"/lib/esc_initramfs.sgn
exec switch_root -c /dev/console . $0 exec switch_root -c /dev/console . "$0"
fi fi
} }
@ -219,7 +219,7 @@ transfer_initramfs()
init_proc_sysfs() init_proc_sysfs()
{ {
debug_log "init_proc_sysfs" "$*" debug_log "init_proc_sysfs" "$*"
mkdir -p /proc /sys /etc $MEMORY mkdir -p /proc /sys /etc "$MEMORY"
mount -n -t proc proc /proc mount -n -t proc proc /proc
echo "0" >/proc/sys/kernel/printk echo "0" >/proc/sys/kernel/printk
mount -n -t sysfs sysfs /sys mount -n -t sysfs sysfs /sys
@ -281,11 +281,12 @@ init_zram()
init_aufs() init_aufs()
{ {
debug_log "init_aufs" "$*" debug_log "init_aufs" "$*"
# TODO maybe check here if aufs support is working at all
# and produce useful error message if user has no aufs # Prepare for error messages
echo >>/var/log/livkekit-log
modprobe aufs 2>/var/log/livekit-log modprobe aufs 2>/var/log/livekit-log
# TODO ACCOMPLISHED:
# If aufs module failed to load, panic immidiately # If aufs module failed to load, panic immidiately
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
fatal "Failed to load AUFS module!" fatal "Failed to load AUFS module!"
@ -306,7 +307,16 @@ init_union()
echo_livekit_msg "Initialising AUFS union..." echo_livekit_msg "Initialising AUFS union..."
mkdir -p "$1" mkdir -p "$1"
mkdir -p "$2" mkdir -p "$2"
mount -t aufs -o xino="/.xino",trunc_xino,br="$1" aufs "$2"
# Prepare for error messages
echo >>/var/log/livekit-log
mount -t aufs -o xino="/.xino",trunc_xino,br="$1" aufs "$2" >/var/log/livekit-log 2>&1
# If failed to init union, panic
if [ $? -ne 0 ]; then
fatal "Failed to initialise AUFS union!"
fi
} }
# Return device mounted for given directory # Return device mounted for given directory
@ -404,7 +414,7 @@ init_network_dev()
modprobe $MODULE 2>/dev/null modprobe $MODULE 2>/dev/null
ETH="$(cat /proc/net/dev | grep : | grep -v lo: | cut -d : -f 1 | tr -d " " | head -n 1)" ETH="$(cat /proc/net/dev | grep : | grep -v lo: | cut -d : -f 1 | tr -d " " | head -n 1)"
if [ "$ETH" != "" ]; then if [ "$ETH" != "" ]; then
echo $ETH echo "$ETH"
return 0 return 0
fi fi
rmmod $MODULE 2>/dev/null rmmod $MODULE 2>/dev/null
@ -414,7 +424,7 @@ init_network_dev()
# As a last chance, try to modprobe everything. # As a last chance, try to modprobe everything.
echo_warn "No networking kernel module found!" echo_warn "No networking kernel module found!"
modprobe_everything modprobe_everything
cat /proc/net/dev | grep : | grep -v lo: | cut -d : -f 1 | tr -d " " | head -n 1 cat /proc/net/dev | grep ':' | grep -v 'lo:' | cut -d : -f 1 | tr -d " " | head -n 1
} }
@ -429,13 +439,15 @@ download_data_pxe()
mkdir -p "$1/$LIVEKITNAME" mkdir -p "$1/$LIVEKITNAME"
cmdline_value ip | while IFS=":" read CLIENT SERVER GW MASK PORT; do cmdline_value ip | while IFS=":" read CLIENT SERVER GW MASK PORT; do
echo_livekit_msg "Downloading files from $SERVER ..." >&2 echo_livekit_msg "Downloading files from ${SERVER}..." >&2
ETH=$(init_network_dev) ETH=$(init_network_dev)
if [ "$PORT" = "" ]; then PORT="7529"; fi if [ "$PORT" = "" ]; then
PORT="7529"
fi
# set IP address as given by boot paramter # set IP address as given by boot paramter
if [ "$CLIENT" != "" -a "$MASK" != "" ]; then if [ -n "$CLIENT" ] && [ -n "$MASK" ]; then
ifconfig $ETH "$CLIENT" netmask "$MASK" ifconfig $ETH "$CLIENT" netmask "$MASK"
route add default gw "$GW" route add default gw "$GW"
else else
@ -449,16 +461,18 @@ download_data_pxe()
PROTOCOL=http PROTOCOL=http
wget -q -O "$1/PXEFILELIST" "http://$SERVER:$PORT/PXEFILELIST?$(uname -r):$(uname -m)" wget -q -O "$1/PXEFILELIST" "http://$SERVER:$PORT/PXEFILELIST?$(uname -r):$(uname -m)"
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo_warn "Failed to download from http://$SERVER:$PORT, trying TFTP..." echo_warn "Failed to download from http://${SERVER}:${PORT}!" >&2
echo_livekit_msg 'Downloading with TFTP protocol...' >&2
PROTOCOL=tftp PROTOCOL=tftp
tftp -g -r PXEFILELIST -l "$1/PXEFILELIST" $SERVER tftp -g -r PXEFILELIST -l "$1/PXEFILELIST" $SERVER
fi fi
cat "$1/PXEFILELIST" | while read FILE; do cat "$1/PXEFILELIST" | while read FILE; do
if [ "$PROTOCOL" = "http" ]; then if [ "$PROTOCOL" = "http" ]; then
echo_livekit_msg "PXE-HTTP: Downloading ${FILE}..." >&2
wget -O "$1/$LIVEKITNAME/$FILE" "http://$SERVER:$PORT/$FILE" wget -O "$1/$LIVEKITNAME/$FILE" "http://$SERVER:$PORT/$FILE"
else elif [ "$PROTOCOL" = "tftp" ]; then
echo_livekit_msg "PXE: ${FILE}..." >&2 echo_livekit_msg "PXE-TFTP: Downloading ${FILE}..." >&2
tftp -g -r $FILE -l "$1/$LIVEKITNAME/$FILE" $SERVER tftp -g -r $FILE -l "$1/$LIVEKITNAME/$FILE" $SERVER
fi fi
done done
@ -531,7 +545,10 @@ find_data()
echo -n "." >&2 echo -n "." >&2
refresh_devs refresh_devs
DATA="$(find_data_try "$2" "$FROM")" DATA="$(find_data_try "$2" "$FROM")"
# This "was" a bug!
echo "" >&2 echo "" >&2
if [ "$DATA" != "" ]; then if [ "$DATA" != "" ]; then
echo_livekit_msg "$LIVEKITNAME data found on $(mounted_device "$2")" >&2 echo_livekit_msg "$LIVEKITNAME data found on $(mounted_device "$2")" >&2
echo "$DATA" echo "$DATA"