|
@@ -3,62 +3,74 @@
|
|
|
RDX_DEVICE="/dev/sdb"
|
|
|
RDX_PART="/dev/sdb1"
|
|
|
BPC_DATAS_DIR="/var/lib/BackupPC"
|
|
|
-BPC_FILES="/root/rdx_init.tar.gz"
|
|
|
+BPC_FILES="/root/RDX_BackupPC/rdx_init.tar.gz"
|
|
|
|
|
|
init_rdx()
|
|
|
{
|
|
|
-
|
|
|
+ /etc/init.d/crond stop
|
|
|
echo -e "[*] Unmounting RDX "
|
|
|
- umount $RDX_PART 2>&1 || echo -e "[x] Error unmounting RDX partition"
|
|
|
+ /bin/umount $RDX_PART 2>&1 || echo -e "[x] Error unmounting RDX partition"
|
|
|
|
|
|
echo -e "[*] Creating /dev/sdb1..."
|
|
|
(echo o; echo n; echo p; echo 1; echo ; echo; echo w) | fdisk $RDX_DEVICE 2>&1 || echo -e "[x] Error during parted"
|
|
|
|
|
|
echo -e "[*] Creating ext4 filesystem... (this can take severals minutes)"
|
|
|
- mkfs.ext4 $RDX_PART 2>&1 || echo -e "[x] Error during mkfs.ext4"
|
|
|
+ /sbin/mkfs.ext4 $RDX_PART 2>&1 || echo -e "[x] Error during mkfs.ext4"
|
|
|
|
|
|
- echo -e "[*] Mounting and extracting base files..."
|
|
|
- mount $RDX_PART $BPC_DATAS_DIR 2>&1 || echo -e "[x] Error during mounting"
|
|
|
- tar xvf $BPC_FILES -C $BPC_DATAS_DIR 2>&1 || echo -e "[x] Error during extract, check if $BPC_FILES exists"
|
|
|
+ /etc/init.d/crond start
|
|
|
+ /sbin/partprobe $RDX_DEVICE
|
|
|
check_rdx
|
|
|
|
|
|
}
|
|
|
|
|
|
check_rdx()
|
|
|
{
|
|
|
-
|
|
|
+
|
|
|
rdx_present=$(smartctl -A $RDX_DEVICE | grep "Current Drive Temperature" | cut -d ":" -f2 | sed -e "s/\ //g")
|
|
|
-
|
|
|
if [ "$rdx_present" = "<notavailable>" ]; then
|
|
|
echo -e "[x] RDX SMART <notavailable>, maybe the disk is ejected?"
|
|
|
echo -e "[x] force unmount of $BPC_DATAS_DIR"
|
|
|
/bin/umount -f $BPC_DATAS_DIR
|
|
|
+
|
|
|
|
|
|
else
|
|
|
+ /sbin/partprobe $RDX_DEVICE
|
|
|
echo "[*] RDX SMART OK, mouting BackupPC filesystem"
|
|
|
+
|
|
|
+ fs_detect=$(file -s $RDX_PART | grep "ext4" 2>&1 || echo "non")
|
|
|
+ if [ "$fs_detect" = "non" ]; then
|
|
|
+ echo -e "[x] Device $RDX_PART not found, maybe no parted?"
|
|
|
+ echo -e "[*] RDX Initialisation..."
|
|
|
+ init_rdx
|
|
|
+ else
|
|
|
+ echo -e "Good filesystem..."
|
|
|
+ fi
|
|
|
+
|
|
|
if [ -e $RDX_PART ]; then
|
|
|
echo -e "[*] fsck $RDX_PART"
|
|
|
- /sbin/fsck -f $RDX_PART 2>&1 || echo -e "[x] Error during fsck"
|
|
|
+# /sbin/fsck.ext4 -f -y $RDX_PART 2>&1 || echo -e "[x] Error during fsck"
|
|
|
echo -e "[*] Mount $RDX_PART in $BPC_DATAS_DIR"
|
|
|
/bin/mount $RDX_PART $BPC_DATAS_DIR 2>&1 || echo -e "[x] Error during mount"
|
|
|
|
|
|
- if [ -d "/var/lib/BackupPC/pool" ]; then
|
|
|
+ if [ -d "$BPC_DATAS_DIR/pool" ]; then
|
|
|
echo -e "[*] RDX is already initilised, all is done :)"
|
|
|
/etc/init.d/backuppc restart
|
|
|
+ exit 1
|
|
|
else
|
|
|
echo -e "[x] RDX is steal empty"
|
|
|
- init_rdx
|
|
|
+ /bin/tar xvf $BPC_FILES -C $BPC_DATAS_DIR 2>&1 || echo -e "[x] Error during extract, check if $BPC_FILES exists"
|
|
|
fi
|
|
|
-
|
|
|
- else
|
|
|
- echo -e "[x] Device $RDX_PART not found, maybe no parted?"
|
|
|
- echo -e "[*] RDX Initialisation..."
|
|
|
- init_rdx
|
|
|
-
|
|
|
fi
|
|
|
|
|
|
fi
|
|
|
}
|
|
|
|
|
|
|
|
|
-check_rdx
|
|
|
+if [ -e $BPC_DATAS_DIR/pool ]; then
|
|
|
+ exit 1
|
|
|
+
|
|
|
+else
|
|
|
+ check_rdx
|
|
|
+fi
|
|
|
+
|
|
|
+
|