/usr/share/drbl/samples/custom-ocs-2 is in clonezilla 3.10.11-1.
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 | #!/bin/bash
# Author: Steven Shiau <steven _at_ nchc org tw>, Thomas Tsai <thomas _at_ nchc org tw>
# License: GPL
# In this example, the image repository is on /dev/sda7, it will allow your user to use clonezilla live to choose
# (1) backup the WinXP image of /dev/sda1 to /dev/sda7
# (2) backup the EZGO8 image of /dev/sda2 to /dev/sda7
# (3) restore WinXP image in /dev/sda7 to /dev/sda1
# (4) restore EZGO8 image in /dev/sda7 to /dev/sda2
# (5) restore default WinXP image in /dev/sda7 to /dev/sda1
# (6) restore default EZGO8 image in /dev/sda7 to /dev/sda2
# Here we assume the filesystems are ntfs.
# The interface is traditional Chinese (zh_TW.UTF-8).
# When this script is ready, you can run
# ocs-iso -g zh_TW.UTF-8 -k NONE -s -m ./custom-ocs-2
# to create the iso file for CD/DVD. or
# ocs-live-dev -g zh_TW.UTF-8 -k NONE -s -c -m ./custom-ocs-2
# to create the zip file for USB flash drive.
# Begin of the scripts:
#
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 setting for clonezilla live.
. /etc/ocs/ocs-live.conf
# Load language files. For English, use "en_US.UTF-8". For Chinese, use "zh_TW.UTF-8"
ask_and_load_lang_set zh_TW.UTF-8
export LANG=zh_TW.UTF-8
# The above is almost necessary, it is recommended to include them in your own custom-ocs.
# From here, you can write your own scripts.
# functions
decide_sda_or_hda() {
if [ -n "$(grep -Ew sda1 /proc/partitions)" -a -n "$(grep -Ew sda7 /proc/partitions)" ]; then
disk=sda
elif [ -n "$(grep -Ew hda1 /proc/partitions)" -a -n "$(grep -Ew hda7 /proc/partitions)" ]; then
disk=hda
else
[ "$BOOTUP" = "color" ] && $SETCOLOR_FAILURE
echo "/dev/hda1 and /dev/hda7 do not exist or /dev/sda1 and /dev/sda7 do not exist!"
echo "Program terminated!"
[ "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL
fi
# src_part: hda1(2) or sda1(2), tgt_part: hda7 or sda7
src_part1=${disk}1
src_part2=${disk}2
tgt_part7=${disk}7
def_tgt_part7=${disk}7
}
action_backup_xp() {
mkdir -p /home/partimag/
if ! mountpoint /home/partimag/ &>/dev/null; then
ntfs-3g /dev/$tgt_part7 /home/partimag/
fi
if mountpoint /home/partimag/ &>/dev/null; then
rm -rf /home/partimag/xp-backup
# If you want to run it in batch mode, add option "-b" in the ocs-sr command
# For more options about ocs-sr, run "ocs-sr -h"
ocs-sr -b -q2 -b -j2 -z1p -i 2000 -p true saveparts xp-backup $src_part1
else
[ "$BOOTUP" = "color" ] && $SETCOLOR_FAILURE
echo "Fail to mount /dev/$tgt_part7 as /home/partimag!"
echo "Program terminated!"
[ "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL
fi
umount /home/partimag/
}
action_backup_go() {
mkdir -p /home/partimag/
if ! mountpoint /home/partimag/ &>/dev/null; then
ntfs-3g /dev/$tgt_part7 /home/partimag/
fi
if mountpoint /home/partimag/ &>/dev/null; then
rm -rf /home/partimag/go-backup
# If you want to run it in batch mode, add option "-b" in the ocs-sr command
# For more options about ocs-sr, run "ocs-sr -h"
ocs-sr -b -q2 -b -j2 -z1p -i 2000 -p true saveparts go-backup $src_part2
else
[ "$BOOTUP" = "color" ] && $SETCOLOR_FAILURE
echo "Fail to mount /dev/$tgt_part7 as /home/partimag!"
echo "Program terminated!"
[ "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL
fi
umount /home/partimag/
}
action_restore_xp() {
mkdir -p /home/partimag/
if ! mountpoint /home/partimag/ &>/dev/null; then
ntfs-3g /dev/$tgt_part7 /home/partimag/
fi
if mountpoint /home/partimag/ &>/dev/null; then
# If you want to run it in batch mode, add option "-b" in the ocs-sr command
# For more options about ocs-sr, run "ocs-sr -h"
ocs-sr -g auto -e1 auto -e2 -r -j2 -k -p true restoreparts xp-backup "$src_part1"
else
[ "$BOOTUP" = "color" ] && $SETCOLOR_FAILURE
echo "Fail to mount /dev/$tgt_part7 as /home/partimag!"
echo "Program terminated!"
[ "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL
fi
umount /home/partimag/
}
action_restore_go() {
mkdir -p /home/partimag/
if ! mountpoint /home/partimag/ &>/dev/null; then
ntfs-3g /dev/$tgt_part7 /home/partimag/
fi
if mountpoint /home/partimag/ &>/dev/null; then
# If you want to run it in batch mode, add option "-b" in the ocs-sr command
# For more options about ocs-sr, run "ocs-sr -h"
ocs-sr -g auto -e1 auto -e2 -r -j2 -k -p true restoreparts go-backup "$src_part2"
else
[ "$BOOTUP" = "color" ] && $SETCOLOR_FAILURE
echo "Fail to mount /dev/$tgt_part7 as /home/partimag!"
echo "Program terminated!"
[ "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL
fi
umount /home/partimag/
}
action_default_xp() {
mkdir -p /home/partimag/
if ! mountpoint /home/partimag/ &>/dev/null; then
ntfs-3g /dev/$tgt_part7 /home/partimag/
fi
if mountpoint /home/partimag/ &>/dev/null; then
# If you want to run it in batch mode, add option "-b" in the ocs-sr command
# For more options about ocs-sr, run "ocs-sr -h"
ocs-sr -g auto -e1 auto -e2 -r -j2 -k -p true restoreparts WINXP "$src_part1"
else
[ "$BOOTUP" = "color" ] && $SETCOLOR_FAILURE
echo "Fail to mount /dev/$tgt_part7 as /home/partimag!"
echo "Program terminated!"
[ "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL
fi
umount /home/partimag/
}
action_default_go() {
mkdir -p /home/partimag/
if ! mountpoint /home/partimag/ &>/dev/null; then
ntfs-3g /dev/$tgt_part7 /home/partimag/
fi
if mountpoint /home/partimag/ &>/dev/null; then
# If you want to run it in batch mode, add option "-b" in the ocs-sr command
# For more options about ocs-sr, run "ocs-sr -h"
ocs-sr -g auto -e1 auto -e2 -r -j2 -k -p true restoreparts EZGO8 "$src_part2"
else
[ "$BOOTUP" = "color" ] && $SETCOLOR_FAILURE
echo "Fail to mount /dev/$tgt_part7 as /home/partimag!"
echo "Program terminated!"
[ "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL
fi
umount /home/partimag/
}
##################
###### MAIN ######
##################
TMP=$(mktemp /tmp/menu.XXXXXX)
trap "[ -f "$TMP" ] && rm -f $TMP" HUP INT QUIT TERM EXIT
$DIA --backtitle "$msg_nchc_free_software_labs" --title \
"$msg_nchc_clonezilla" --menu "$msg_choose_mode:" \
0 0 0 \
"Backup_xp" "備份XP" \
"Backup_go" "備份Ezgo" \
"Restore_xp" "還原XP" \
"Restore_go" "還原Ezgo" \
"Restore_default_xp" "還原預設XP" \
"Restore_default_go" "還原預設Ezgo" \
2> $TMP
mode="$(cat $TMP)"
[ -f "$TMP" ] && rm -f $TMP
# find the device and partition
decide_sda_or_hda
#
case "$mode" in
Backup_xp) action_backup_xp;;
Backup_go) action_backup_go;;
Restore_xp) action_restore_xp;;
Restore_go) action_restore_go;;
Restore_default_xp) action_default_xp;;
Restore_default_go) action_default_go;;
*)
[ "$BOOTUP" = "color" ] && $SETCOLOR_FAILURE
echo "Unknown mode \"$mode\"!"
echo "Program terminated!"
[ "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL
exit 1
esac
|