#!/bin/bash
# License: GPL 
# Author: Steven Shiau <steven _at_ clonezilla org>
# Description: Program to show the kernel messages about removable disks
# //NOTE// This program is used to work with screen.

#
DRBL_SCRIPT_PATH="${DRBL_SCRIPT_PATH:-/usr/share/drbl}"
. $DRBL_SCRIPT_PATH/sbin/drbl-conf-functions
. /etc/drbl/drbl-ocs.conf
. $DRBL_SCRIPT_PATH/sbin/ocs-functions

# Load the config in ocs-live.conf. This is specially for Clonezilla live. It will overwrite some settings of /etc/drbl/drbl-ocs.conf, such as $DIA...
[ -e "/etc/ocs/ocs-live.conf" ] && . /etc/ocs/ocs-live.conf

# Settings

#
ask_and_load_lang_set

#
now="$(LC_ALL=C date +%Y/%m/%d" "%T)"
echo "$now"
[ "$BOOTUP" = "color" ] && $SETCOLOR_WARNING
echo -e "$msg_insert_storage_dev_now"
[ "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL
# We have to assign ocs_sr_type as save so that when there is file system on a bare block device (e.g., /dev/sda), it can be listed, i.e., in the functions is_whole_disk and is_partition of ocs-functions.
ocs_sr_type="save"
get_not_busy_disks_or_parts harddisk # Obtain dev_list
echo "Scanning devices... Available disk(s) on this machine:"
echo "==================================="
for idsk in $dev_list; do
  x="$(cat /sys/block/$(to_sysblock_name $(get_diskname ${idsk}))/device/model 2>/dev/null | sed -r -e "s/[[:space:]]+/ /g" | tr ' ' _ 2>/dev/null)"
  x=${x#*\"}
  x=${x%\"*}
  get_disk_serial_no $idsk
  if [ -z "$serialno" ]; then
    serialno="No_disk_serial_no"
  fi
  dsize="$(LC_ALL=C parted -s /dev/${idsk} print 2>/dev/null | grep -E "^[[:space:]]*Disk[[:space:]]+/dev/" | awk -F":" '{print $2}' | sed -e "s/ //g")"
  echo "/dev/${idsk}: $x $serialno $dsize"
done
echo "==================================="
echo -en '\033[1;33m'
echo Update periodically. Press Ctrl-C to exit this window.
echo -en '\033[0;39m'
