This file is indexed.

/usr/sbin/ocs-live-get-img is in clonezilla 3.27.16-2.

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
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
#!/bin/bash
# License: GPL 
# Author: Steven Shiau <steven _at_ clonezilla org>
# Description: Program to restore an image by receiving multicast packets from server
# What will be done in this program:
# 1. Get a tarball about the image which contains all files in the image except file system image files.
# 3. Get a script about the full command to start restoring.
#
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

# Functions
USAGE() {
    echo "$ocs - To start restoring an image from multicast server by Clonezilla"
    echo "Usage:"
    echo "To run $ocs:"
    echo "$ocs [OPTION] [SERVER]"
    echo "This program is specially used in Clonezilla live to start restoring an image with multicast packets in clients."
    echo "Options:"
    echo "-b, --batch-mode   Run in batch mode"
    echo "SERVER is the multicast server IP address or FQDN, e.g. 192.168.25.111..."
    echo "If no SERVER is specified, a dialog menu will be shown."
    echo "Ex:"
    echo "To start restoring an image in client machine from multicaast feeding server 192.168.25.111, run"
    echo "   $ocs 192.168.25.111"
    echo
} # end of USAGE
#
task_run_restoring() {
  network_config_if_necessary
  # No need for this. We have a tarball solution.
  #if ! mountpoint $ocsroot >/dev/null 2>&1; then 
  #  prep-ocsroot
  #fi
  
  if [ "$cast_srv" = "ask_user" ]; then
    # Ask about multicast feeding server
    TMP="$(mktemp /tmp/ocs-cast-srv.XXXXXX)"
    trap "[ -f "$TMP" ] && rm -f $TMP" HUP INT QUIT TERM EXIT
    srv_default="$(LC_ALL=C route -n | grep "^0.0.0.0" | awk -F" " '{print $2}')"
    ask_="true"
    while [ "$ask_" = "true" ]; do
      $DIA --backtitle "$msg_nchc_free_software_labs" --title  \
      "Multicast server" --inputbox "$msg_ip_address_or_FQDN_of_server: Multicast server" \
      0 0 $srv_default $DIA_ESC \
      2> $TMP
      cast_srv="$(cat $TMP)"
      if [ -z "$cast_srv" ]; then
        $DIA --backtitle "$msg_nchc_free_software_labs" --title "$msg_nchc_clonezilla" \
        --yesno "$msg_you_must_input_a_server\n$msg_do_u_want_to_do_it_again" 0 0
        ans_="$?"
        case "$ans_" in
          0) # yes is chosen
             ask_="true";;
          1) # no is chosen
             echo "$msg_program_stop!" | tee -a ${OCS_LOGFILE}
             [ -f "$TMP" ] && rm -f $TMP
             exit 1;;
        esac
      else
        # Got the one we want
        ask_="false"
      fi
    done
    [ -f "$TMP" ] && rm -f $TMP
  fi
  if [ -z "$cast_srv" ]; then
    [ "$BOOTUP" = "color" ] && $SETCOLOR_FAILURE
    echo "No Clonezilla live lite server was assigned or found!" | tee -a ${OCS_LOGFILE}
    [ "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL
    echo "$msg_program_stop!" | tee -a ${OCS_LOGFILE}
    exit 1
  fi
  echo "Multicast server is: $cast_srv" | tee -a ${OCS_LOGFILE}
  # Get info from server then restoring
  # Part 1: get config file
  rm -f /tmp/ocs-client-run.conf
  get_run_conf="wget -P /tmp/ http://$cast_srv/ocs-client-run.conf"
  echo "Running: $get_run_conf"
  eval $get_run_conf | tee -a ${OCS_LOGFILE}
  if [ -e "/tmp/ocs-client-run.conf" ]; then
    echo "The content of /tmp/ocs-client-run.conf:" >> ${OCS_LOGFILE}
    echo $msg_delimiter_star_line >> ${OCS_LOGFILE}
    cat /tmp/ocs-client-run.conf >> ${OCS_LOGFILE}
    echo $msg_delimiter_star_line >> ${OCS_LOGFILE}
  else
    [ "$BOOTUP" = "color" ] && $SETCOLOR_FAILURE
    echo "$msg_failed_to_get_file_from_this_URL: http://$cast_srv/ocs-client-run.conf" | tee -a ${OCS_LOGFILE}
    echo "$msg_program_stop." | tee -a ${OCS_LOGFILE}
    [ "$save_restore_error_log" = "yes" ] && copy_error_log
  fi
  # get pseudo_img and ocs_sr_opt
  pseudo_img=""
  img_prefix=""
  ocs_sr_opt=""
  . /tmp/ocs-client-run.conf
  if [ -z "$pseudo_img" ]; then
    [ "$BOOTUP" = "color" ] && $SETCOLOR_FAILURE
    echo "No pseudo_img was assigned in /tmp/ocs-client-run.conf!" | tee -a ${OCS_LOGFILE}
    [ "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL
    echo "$msg_program_stop" | tee -a ${OCS_LOGFILE}
    exit 1
  fi
  if [ -z "$ocs_sr_opt" ]; then
    [ "$BOOTUP" = "color" ] && $SETCOLOR_FAILURE
    echo "No ocs_sr_opt was assigned in /tmp/ocs-client-run.conf!" | tee -a ${OCS_LOGFILE}
    [ "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL
    echo "$msg_program_stop" | tee -a ${OCS_LOGFILE}
    exit 1
  fi
  [ -z "$img_prefix" ] && img_prefix="ocs-img"

  # Part 2: get pseudo image file
  echo "Preparing the image info..." | tee -a ${OCS_LOGFILE}
  rm -f /tmp/$pseudo_img | tee -a ${OCS_LOGFILE}
  wget -P /tmp/ http://$cast_srv/$pseudo_img | tee -a ${OCS_LOGFILE}
  if [ ! -e /tmp/$pseudo_img ]; then
    [ "$BOOTUP" = "color" ] && $SETCOLOR_FAILURE
    echo "Failed to retreive $pseudo_img from http://$cast_srv/." | tee -a ${OCS_LOGFILE}
    [ "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL
    echo "$msg_program_stop" | tee -a ${OCS_LOGFILE}
    exit 1
  fi
  if [ -d "$/tmp/${img_prefix}" ]; then
    # If image already exists in /tmp, create a random dir.
    image="$(mktemp -d /tmp/${img_prefix}.XXXXXX)"
  else
    image="/tmp/${img_prefix}"
    mkdir -p $image
  fi
  tar -xJf /tmp/$pseudo_img -C $image | tee -a ${OCS_LOGFILE}
  if [ -d "$image/btzone" ]; then
    mkdir -p /tmp/btzone/$(basename $image) | tee -a ${OCS_LOGFILE}
    mv $image/btzone/*.torrent /tmp/btzone/$(basename $image) | tee -a ${OCS_LOGFILE}
  fi
  # Run restoring
  # Before running, replace the new created image name
  ocs_sr_opt="$(echo $ocs_sr_opt | sed -r -e "s/ocs_lite_pseudo_name/$(basename $image)/g")"
  if [ -n "$(ls -A $image 2>/dev/null)" ]; then
    echo "Starting restoring..." | tee -a ${OCS_LOGFILE}
    ocs-sr -os $cast_srv $ocs_sr_opt
  else
    [ "$BOOTUP" = "color" ] && $SETCOLOR_FAILURE
    echo "Failed to find the correct pseudo image dir $image" | tee -a ${OCS_LOGFILE}
    [ "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL
    echo "$msg_program_stop" | tee -a ${OCS_LOGFILE}
    exit 1
  fi
} # end of task_run_restoring

####################
### Main program ###
####################

ocs_file="$0"
ocs=`basename $ocs_file`
OCS_LOGFILE="/var/log/${ocs}.log"
#
while [ $# -gt 0 ]; do
 case "$1" in
   -b|--batch) ocs_batch_mode="on"; shift;;
   -v|--verbose)
           verbose="on"
	   shift;;
   -*)     echo "${0}: ${1}: invalid option" >&2
           USAGE >& 2
           exit 2 ;;
   *)      break ;;
 esac
done

cast_srv="$1"
[ -z "$cast_srv" ] && cast_srv="ask_user"
#
check_if_root
check_if_in_clonezilla_live
ask_and_load_lang_set

# check DIA
check_DIA_set_ESC $DIA

mkdir -p $ocs_log_dir
ocs_log_rotate $OCS_LOGFILE

# Check if run on clonezilla live lite server
if [ -e "/var/www/html/img-wo-fs.tar.xz" -a -e "/var/www/html/ocs-client-run.conf" ]; then
  [ "$BOOTUP" = "color" ] && $SETCOLOR_WARNING
  echo "$msg_client_program_is_run_on_lite_server" | tee -a ${OCS_LOGFILE}
  [ "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL
  echo -n "$msg_are_u_sure_u_want_to_continue (y/N) " | tee -a ${OCS_LOGFILE}
  read continue_confirm_ans
  case "$continue_confirm_ans" in
       y|Y|[yY][eE][sS])
          echo "$msg_let_me_ask_you_again."
          echo -n "$msg_are_u_sure_u_want_to_continue (y/N) " | tee -a ${OCS_LOGFILE}
          read confirm_ans_again
          case "$confirm_ans_again" in
          y|Y|[yY][eE][sS])
             echo "$msg_ok_let_do_it" | tee -a ${OCS_LOGFILE}
	     ;;
          *)
             echo "$msg_program_stop." | tee -a ${OCS_LOGFILE}
             copy_error_log
             exit 1
          esac
             ;;
       *)
          echo "$msg_program_stop." | tee -a ${OCS_LOGFILE}
          # Saving mode, always copy error log to image dir.
          copy_error_log
          exit 1
  esac
fi

#
task_run_restoring