51 lines
1.4 KiB
Bash
51 lines
1.4 KiB
Bash
#!/bin/bash
|
|
# iscsi share fix
|
|
# use this script to rebuild default configs for shares if the ._share becomes
|
|
# broken for whatever reason.
|
|
echo "Activating iSCSI share rebuilder"
|
|
echo "Querying readynasd for list of volumes..."
|
|
x=$(rn_nml -g volumes | grep "resource-id" | sed 's/^.*id="//;s/".*//;')
|
|
number=$(echo "$x" | wc -w)
|
|
echo "$number volume(s) found."
|
|
for volume in ${x}
|
|
do
|
|
echo -n "Investigating volume /$volume..."
|
|
for i in $(find /"$volume" -maxdepth 2 -type d -name ".iscsi" | sed "s/\/.iscsi//g;s/\/$volume\///g;")
|
|
do
|
|
found=1
|
|
path="/$volume/._share/${i}"
|
|
echo "Found /$volume/${i}... recreating configs...".
|
|
mkdir -p "$path"
|
|
cat > "$path"/iscsi.conf << EOF
|
|
comment
|
|
alert_threshold 80
|
|
EOF
|
|
cat > "$path"/custom_snapshot_management.conf << EOF
|
|
enabled = no
|
|
retention_rule = lifetime
|
|
lifetime = 2592000
|
|
number = 30
|
|
nonempty_snapshots = yes
|
|
prev_versions = no
|
|
EOF
|
|
cat > "$path"/custom_snapshot_schedule.conf << EOF
|
|
........................
|
|
........................
|
|
........................
|
|
........................
|
|
........................
|
|
........................
|
|
........................
|
|
EOF
|
|
cat > "$path"/snapshot.conf << EOF
|
|
0 0 0 * 0 0 0
|
|
EOF
|
|
echo " Done with /$volume/${i}."
|
|
done
|
|
echo " Done with /$volume"
|
|
done
|
|
if [[ $found ]]
|
|
then
|
|
echo "Restarting readynasd to finish changes..."
|
|
systemctl restart readynasd
|
|
fi
|