progress
This commit is contained in:
parent
3d62ae51e9
commit
d48eaaa173
2
etc/base
2
etc/base
|
@ -66,7 +66,7 @@ if [ "$ENC" == "1" ]; then
|
||||||
echo "echo \"Disk pw is '${PASS}'\"" > /etc/runit/core-services/99-changepwdisk.sh
|
echo "echo \"Disk pw is '${PASS}'\"" > /etc/runit/core-services/99-changepwdisk.sh
|
||||||
echo "read -p \"Change PW for disk? y/n \" answer" >> /etc/runit/core-services/99-changepwdisk.sh
|
echo "read -p \"Change PW for disk? y/n \" answer" >> /etc/runit/core-services/99-changepwdisk.sh
|
||||||
echo "if [ \"\${answer}\" = \"y\" ]; then" >> /etc/runit/core-services/99-changepwdisk.sh
|
echo "if [ \"\${answer}\" = \"y\" ]; then" >> /etc/runit/core-services/99-changepwdisk.sh
|
||||||
echo " while ! cryptsetup luksChangeKey /dev/disk/by-uuid/${cfg[partuuid]}; do" >> /etc/runit/core-services/99-changepwdisk.sh
|
echo " while ! cryptsetup luksChangeKey /dev/disk/by-id/${TARGET_PHY_ID}-part${TARGET_PART}; do" >> /etc/runit/core-services/99-changepwdisk.sh
|
||||||
echo " echo \"Again, please\"" >> /etc/runit/core-services/99-changepwdisk.sh
|
echo " echo \"Again, please\"" >> /etc/runit/core-services/99-changepwdisk.sh
|
||||||
echo " done" >> /etc/runit/core-services/99-changepwdisk.sh
|
echo " done" >> /etc/runit/core-services/99-changepwdisk.sh
|
||||||
echo " rm -rf /etc/runit/core-services/99-changepwdisk.sh" >> /etc/runit/core-services/99-changepwdisk.sh
|
echo " rm -rf /etc/runit/core-services/99-changepwdisk.sh" >> /etc/runit/core-services/99-changepwdisk.sh
|
||||||
|
|
|
@ -6,72 +6,62 @@ if [ $UID -ne 0 ]; then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#test -f "${backupcfg}" && echo "${backupcfg} existiert" && exit 1
|
input() {
|
||||||
|
output=""
|
||||||
|
echo "${1}"
|
||||||
|
read -r -p "[${2}]: " output
|
||||||
|
test -z "${output}" && output="${2}"
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
# find all disks
|
multiplechoice() {
|
||||||
declare -A disk_tmp=()
|
output=""
|
||||||
declare -A disk=()
|
local done=""
|
||||||
index=0
|
local input=("${@}")
|
||||||
for i in $(find /dev/disk/by-id/ -type l -printf "%P\n" | grep usb | grep -v part | tac ); do
|
#for i in $(seq 1 "$(( ${#input[@]} - 1 ))"); do
|
||||||
name="$(readlink -f /dev/disk/by-id/"${i}")"
|
for i in $(seq 0 "$(( ${#input[@]} - 1 ))"); do
|
||||||
if [[ "${name}" =~ *"^[0-9]+$"* ]]; then
|
if [[ "${i}" == "0" ]]; then
|
||||||
continue
|
choices="${input[$i]}"
|
||||||
fi
|
use="${input[$i]}"
|
||||||
if [[ "${name}" == *"dm"* ]]; then
|
|
||||||
continue
|
|
||||||
fi
|
|
||||||
if [[ "${name}" == *"/dev/sr"* ]]; then
|
|
||||||
continue
|
|
||||||
fi
|
|
||||||
if blkid "${name}"|grep -q UUID; then
|
|
||||||
size="$(fdisk -l "${name}" | head -n1 | awk '{print $3}')"
|
|
||||||
else
|
else
|
||||||
continue
|
choices="${choices}|${input[$i]}"
|
||||||
|
use+=" ${input[$i]}"
|
||||||
fi
|
fi
|
||||||
size=$(awk "BEGIN { printf(\"%.0f\n\", ${size}); }")
|
|
||||||
uuid=$(blkid -o value -s UUID ${name})
|
|
||||||
index=$(( index + 1 ))
|
|
||||||
disk_tmp+=( [${index}.id]="${i}" [${index}.name]="${name}" [${index}.uuid]="${uuid}" [${index}.size]="${size}" )
|
|
||||||
done
|
done
|
||||||
disk_tmp+=( [count]="${index}" )
|
while input "[${choices}]: " "${input[0]}"; do
|
||||||
|
for i in $(seq 0 "${#input[@]}"); do
|
||||||
if [[ "${disk_tmp[count]}" -eq 0 ]]; then
|
if [[ "${output}" == "${input[$i]}" ]] || [[ "${output}" == "${input[$i]:0:2}" ]]; then
|
||||||
echo "No Disk attached."
|
output="${input[$i]}"
|
||||||
exit 1
|
done=1
|
||||||
fi
|
fi
|
||||||
# show devices
|
|
||||||
echo "Devices:"
|
|
||||||
for i in $(seq 1 "${disk_tmp[count]}"); do
|
|
||||||
echo "${disk_tmp[${i}.id]}"
|
|
||||||
echo " - uuid: ${disk_tmp[${i}.uuid]}"
|
|
||||||
echo " - name: ${disk_tmp[${i}.name]}"
|
|
||||||
echo " - size: ${disk_tmp[${i}.size]}"
|
|
||||||
done
|
done
|
||||||
|
if [[ -z "${done}" ]]; then
|
||||||
# choose device
|
echo wronginput "${output}"
|
||||||
found=
|
echo use these: "${use}"
|
||||||
while read -p "Which Device? [${disk_tmp[1.uuid]}]: " output; do
|
else
|
||||||
test -z "${output}" && output="${disk_tmp[1.uuid]}"
|
|
||||||
for i in $(seq 1 "${disk_tmp[count]}"); do
|
|
||||||
if [[ "${disk_tmp[${i}.id]}" == "${output}" ]] || [[ "${disk_tmp[${i}.name]}" == "${output}" ]] || [[ "${disk_tmp[${i}.uuid]}" == "${output}" ]]; then
|
|
||||||
found=1
|
|
||||||
id="${disk_tmp[${i}.id]}"
|
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
|
|
||||||
done
|
done
|
||||||
[[ "${found}" ]] && break
|
}
|
||||||
echo "${output} not found"
|
|
||||||
done
|
|
||||||
|
|
||||||
echo "g
|
echo "Bitte Backupgerät noch nicht anschliessen!"
|
||||||
n
|
read
|
||||||
1
|
DISKS_DETAILS=$(lsblk -l -o KNAME,TYPE,SIZE,MODEL|grep disk)
|
||||||
|
echo "${DISKS_DETAILS}"
|
||||||
|
echo ""
|
||||||
|
echo "Nun das Gerät anschliessen und das neue in der Liste auswaehlen"
|
||||||
|
read
|
||||||
|
DISKS_DETAILS=$(lsblk -l -o KNAME,TYPE,SIZE,MODEL|grep disk)
|
||||||
|
echo "${DISKS_DETAILS}"
|
||||||
|
multiplechoice $(echo "${DISKS_DETAILS}"|awk '{print $1}')
|
||||||
|
TARGET_PHY_DISK="${output}"
|
||||||
|
|
||||||
|
|
||||||
w
|
parted "${TARGET_PHY_ID}" -s -- mklabel gpt
|
||||||
q" | fdisk "/dev/disk/by-id/${id}"
|
parted "${TARGET_PHY_ID}" unit mib -s -- mkpart root btrfs 1 100%
|
||||||
|
|
||||||
UUID=$(blkid -o value -s UUID "/dev/disk/by-id/${id}-part1")
|
UUID=$(blkid -o value -s UUID "/dev/${TARGET_PHY_ID}1")
|
||||||
|
|
||||||
if ! cryptsetup luksFormat UUID="${UUID}"; then
|
if ! cryptsetup luksFormat UUID="${UUID}"; then
|
||||||
echo "Konnte /dev/disk/by-uuid/${UUID} nicht verschluesseln."
|
echo "Konnte /dev/disk/by-uuid/${UUID} nicht verschluesseln."
|
||||||
|
|
Loading…
Reference in New Issue
Block a user