/usr/sbin/ocs-live-run-menu is in clonezilla 3.10.11-3.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 | #!/bin/bash
# Author: Steven Shiau <steven _at_ nchc org tw>
# License: GPL
# We need to know ocsroot.
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 options from config file
[ -e /etc/ocs/ocs-live.conf ] && . /etc/ocs/ocs-live.conf
# Set initial value if not set
[ -z "$ocs_live_run" ] && ocs_live_run="ocs-live-general"
[ -z "$ocs_live_keymap" ] && ocs_live_keymap="NONE"
[ -z "$ocs_live_batch" ] && ocs_live_batch="no"
[ -z "$ocs_lang" ] && ocs_lang="en_US.UTF-8"
#
if [ -z "$ocs_live_run" ]; then
echo "No \$ocs_live_run was assigned (Either from /etc/ocs/ocs-live.conf or command kernel parameters). Skip Clonezilla-related action."
exit 3
fi
# Get the live media mount point.
get_live_media_mnt_point
if [ -z "$LIVE_MEDIA" -o ! -d "/$LIVE_MEDIA" ]; then
echo "$0 is run in Clonezilla Live!"
echo "Program terminated!"
exit 1
fi
#
get_fb_term
[ "$fb_term" = "bterm" -a ! -e "$uni_font" ] && exit 1
use_bterm=""
# Ex. zh_TW.UTF-8 -> zh_TW
locale_region="$(echo "$ocs_lang" | sed -e "s|\..*||g")"
if `locale_required_bterm_or_not "$locale_region"` && \
[ -n "$fb_term" ] && \
([ -e /dev/fb/0 ] || [ -e /dev/fb0 ]); then
use_bterm="yes"
else
use_bterm="no"
fi
#
gen_locale_if_not_found $locale_region $ocs_lang
# export these variables so that they can be passed to $ocs_live_run in bterm
export LANG="$ocs_lang"
export CURRENT_TTY="$(tty)" # e.g. /dev/tty1
# By default we will run $ocs_live_run in /dev/tty1 if ocs_live_run_tty is not specified.
if [ -n "$ocs_live_run_tty" ]; then
# tty is specified. Check if it the current tty
[ "$CURRENT_TTY" != "$ocs_live_run_tty" ] && exit 3
else
# No tty is specified to run $ocs_live_run_tty. Default to run only on /dev/tty1 (no more ttyS0). If you want to use ttyS0, add live-getty and console=ttyS0,38400n81 in the boot parameter
# If it's not in /dev/tty1, just exit.
[ "$CURRENT_TTY" != "/dev/tty1" ] && exit 3
fi
# Waiting for the jobs in /etc/ocs/ocs-live.d are finished.
to_wait=""
while [ -z "$to_wait" ]; do
if [ -e /var/lib/live/clonezilla/ocs-live.d ]; then
echo "The jobs in /etc/ocs/ocs-live.d/ are finished. Start \"$ocs_live_run\" now."
to_wait="no"
else
sleep 0.2
fi
done
# Pre run
ocs-live-pre-run
#
if [ "$use_bterm" = "yes" ];then
case "$fb_term" in
"bterm")
# Since bterm can only use one parameter (i.e. not working if we run 'bterm -l zh_TW.UTF-8 -f $uni_font ls -alF /etc/', i.e. only ls will be respected. There is no such issue for jfbterm). Here we use a workaround to make it work for bterm, i.e. use a tmp file to run it.
ocs_live_run_tmp="$(mktemp /tmp/ocs_live_run_tmp.XXXXXX)"
echo "$ocs_live_run" > $ocs_live_run_tmp
chmod 755 $ocs_live_run_tmp
export TERM=bterm
set +e
# bterm need full path command even it's in the PATH already.
bterm -l $LANG -f $uni_font $ocs_live_run_tmp
EXIT=$?
[ -e "$ocs_live_run_tmp" ] && rm -f $ocs_live_run_tmp
;;
"jfbterm")
export TERM=jfbterm
set +e
jfbterm -q -e $ocs_live_run
EXIT=$?
;;
esac
else
$ocs_live_run
fi
echo "\"$ocs_live_run\" is finished."
# Post run
ocs-live-post-run
# Post actions
# Case 1: Clonezilla SE's client: comment the execution to avoid it's run twice (since all the commands are from /proc/cmdline, and if user inputs "exit" in the shell, the job will be started again in batch mode without stop. While in Clonezilla live interactive mode, it won't be run in batch mode.)
# Case 2: Clonezilla live interactive mode: ask if want to reboot, shutdown or in command line...
if [ -n "$(LC_ALL=C grep -iE "ocs_server" /proc/cmdline)" ]; then
# Case 1: Clonezilla SE's client
# Once the job is done, and if it's started by Clonezilla Server (ocs_server found in /proc/cmdline), we have to comment the autologin account's ~/.bash_profile
# The job is started by Clonezilla SE, comment the line "sudo -i ocs-live-run-menu"
get_live_autologin_account
if [ -z "$live_autologin_account" ]; then
echo "No account with NOPASSWD sudo privilege was found!"
echo "Program terminated!"
exit 1
fi
get_live_auto_login_id_home
LANG=C perl -pi -e 's|(^[^#][[:space:]]*)(sudo -i ocs-live-run-menu)|$1 true # $2 # commented after clonezilla job is done.|g' $live_auto_login_id_home/.bash_profile
else
# The result got from ocs-live-final-action will be saved in file $ocs_live_run_rlt.
ocs_live_run_rlt="$(mktemp /tmp/ocs_live_run_rlt.XXXXXX)"
# Case 2: Clonezilla live interactive mode
if [ "$use_bterm" = "yes" ];then
case "$fb_term" in
"bterm")
# Since bterm can only use one parameter (i.e. not working if we run 'bterm -l zh_TW.UTF-8 -f $uni_font ls -alF /etc/', i.e. only ls will be respected. There is no such issue for jfbterm). Here we use a workaround to make it work for bterm, i.e. use a tmp file to run it.
ocs_live_run_tmp="$(mktemp /tmp/ocs_live_run_tmp.XXXXXX)"
echo "ocs-live-final-action $ocs_live_run_rlt" > $ocs_live_run_tmp
chmod 755 $ocs_live_run_tmp
export TERM=bterm
set +e
# bterm need full path command even it's in the PATH already.
bterm -l $LANG -f $uni_font $ocs_live_run_tmp
EXIT=$?
[ -e "$ocs_live_run_tmp" ] && rm -f $ocs_live_run_tmp
;;
"jfbterm")
export TERM=jfbterm
set +e
jfbterm -q -e ocs-live-final-action $ocs_live_run_rlt
EXIT=$?
;;
esac
else
# At this point, it's not in bterm/jfbterm, only text console. Use English.
ask_and_load_lang_set en_US.UTF-8
ocs-live-final-action $ocs_live_run_rlt
fi
# //NOTE// Do not put poweroff/reboot in this program since it's run in jfbterm/bterm. We separate the final action from ocs-live-final-action. Otherwise if the poweroff command run in jfbterm/bterm, the Debian live "Press Enter to continue" message after poweroff/shutdown command is issued might be coverd by jfbterm/bterm and user will not have any idea what's happening after choose poweroff/reboot.
final_action="$(cat $ocs_live_run_rlt)"
[ -e "$ocs_live_run_rlt" ] && rm -f $ocs_live_run_rlt
[ -n "$final_action" ] && echo "The next step: $final_action"
case "$final_action" in
poweroff) unmount_mounted_fs_before_ocs_live_reboot
echo -n 'Will poweroff... '
countdown 5
poweroff $HALT_REBOOT_OPT ;;
reboot) unmount_mounted_fs_before_ocs_live_reboot
echo -n 'Will reboot... '
countdown 5
reboot $HALT_REBOOT_OPT ;;
rerun*) # umount the clonezilla home dir
if [ "$final_action" = "rerun1" ]; then
echo "Completely start over, so umounting $ocsroot..."
unmount_mounted_fs_before_ocs_live_reboot
else
echo "Keep the mounted image repository $ocsroot..."
fi
echo -n 'Run Clonezilla live again... '
# since we are not in login shell, it's useless to use "exit" or "logout" to force logout bash. Use kill to terminate the login shell in tty1. The clonezilla live main menu will be run again.
if [ -n "$ocs_live_run_tty" ]; then
# ocs_live_run_tty is like: /dev/tty2, /dev/pts/2 (very unlikely)
ttys="$(LC_ALL=C echo $ocs_live_run_tty | sed -e "s|/dev/||g")"
else
ttys="tty1"
fi
for i in $ttys; do
tty_bash_id="$(LC_ALL=C ps -t $i | grep bash | awk -F" " '{print $1}')"
kill -9 $tty_bash_id
done
;;
*) echo ;;
esac
fi
|