Major updates
This commit is contained in:
parent
22ec501225
commit
c768b82b81
1 changed files with 44 additions and 30 deletions
|
@ -8,9 +8,9 @@ shares=0
|
||||||
iscsi=0
|
iscsi=0
|
||||||
share_create() {
|
share_create() {
|
||||||
found=$((found+1))
|
found=$((found+1))
|
||||||
share=$((share+1))
|
shares=$((shares+1))
|
||||||
path="/$volume/._share/$item"
|
path="/$volume/._share/$item"
|
||||||
echo -e "=== Found share at /$volume/$item... recreating share configs...".
|
echo -n "=== Found share at /$volume/$item... recreating share configs...".
|
||||||
mkdir -p "$path"
|
mkdir -p "$path"
|
||||||
echo "share" > "$path"/datasettype.conf
|
echo "share" > "$path"/datasettype.conf
|
||||||
echo "0,0" > "$path"/recycle.conf
|
echo "0,0" > "$path"/recycle.conf
|
||||||
|
@ -71,14 +71,14 @@ EOF
|
||||||
cd "$path"
|
cd "$path"
|
||||||
chown root.root datasettype.conf recycle.conf snapdir.conf snapshot.conf
|
chown root.root datasettype.conf recycle.conf snapdir.conf snapshot.conf
|
||||||
chown admin.admin afp.conf fs.conf ftp.conf nfs.conf samba.conf custom_snapshot_management.conf custom_snapshot_schedule.conf
|
chown admin.admin afp.conf fs.conf ftp.conf nfs.conf samba.conf custom_snapshot_management.conf custom_snapshot_schedule.conf
|
||||||
echo " Done with /$volume/$item."
|
echo " done with /$volume/$item."
|
||||||
}
|
}
|
||||||
|
|
||||||
iscsi_create() {
|
iscsi_create() {
|
||||||
iscsi=$((iscsi+1))
|
iscsi=$((iscsi+1))
|
||||||
found=$((found+1))
|
found=$((found+1))
|
||||||
path="/$volume/._share/$item"
|
path="/$volume/._share/$item"
|
||||||
echo -e "=== Found LUN at /$volume/$item... recreating iSCSI configs...".
|
echo -ne "=== Found LUN at /$volume/$item... recreating iSCSI configs...".
|
||||||
mkdir -p "$path"
|
mkdir -p "$path"
|
||||||
cat > "$path"/iscsi.conf << EOF
|
cat > "$path"/iscsi.conf << EOF
|
||||||
comment
|
comment
|
||||||
|
@ -104,11 +104,13 @@ EOF
|
||||||
cat > "$path"/snapshot.conf << EOF
|
cat > "$path"/snapshot.conf << EOF
|
||||||
0 0 0 * 0 0 0
|
0 0 0 * 0 0 0
|
||||||
EOF
|
EOF
|
||||||
echo " Done with /$volume/$item."
|
echo " done with /$volume/$item."
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
backup_configs() {
|
||||||
|
cd "/$volume/._share/"
|
||||||
|
tar -cf "/var/backups/$volume_sharelunconfig.$(date +%s).tar" ./*
|
||||||
|
}
|
||||||
|
|
||||||
echo "==============================="
|
echo "==============================="
|
||||||
echo "Share and iSCSI Rebuild v6.8.0"
|
echo "Share and iSCSI Rebuild v6.8.0"
|
||||||
|
@ -126,29 +128,41 @@ elif [[ $? -eq 1 ]] ; then # but if it wasn't
|
||||||
fi
|
fi
|
||||||
|
|
||||||
number=$(echo "$x" | wc -w)
|
number=$(echo "$x" | wc -w)
|
||||||
echo "$number volume(s) found."
|
|
||||||
echo -n "Beginning in 3..."; sleep 1; echo -n " 2..."; sleep 1; echo -n " 1..."; sleep 1
|
|
||||||
echo "==============================="
|
|
||||||
echo "=== All right! Time to go! ==="
|
|
||||||
echo "==============================="
|
|
||||||
for volume in $x; do
|
|
||||||
echo "= Investigating volume /$volume..."
|
|
||||||
objects=$(ls -A /$volume | egrep -v "^.apps$|^home$|^.purge$|^._share$|^.timemachine$|^.vault$|^.TemporaryItems$")
|
|
||||||
echo "= Objects found:" $objects
|
|
||||||
for item in $objects; do
|
|
||||||
echo "== Reviewing $item"
|
|
||||||
if ls -QdA /$volume/$item/.iscsi >/dev/null 2>&1; then
|
|
||||||
iscsi_create
|
|
||||||
else
|
|
||||||
share_create
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
echo "= done with /$volume="
|
|
||||||
done
|
|
||||||
|
|
||||||
if [[ $found -gt 0 ]] && [[ $readynasd ]] ; then
|
if [[ ! $number ]]; then
|
||||||
echo "Restarting readynasd to finish changes..."
|
echo "No volumes found!"
|
||||||
systemctl restart readynasd
|
exit 1
|
||||||
else
|
else
|
||||||
echo "Not starting readynasd because it returned a bad message earlier; restart manually."
|
echo "$number volume(s) found."
|
||||||
|
echo -n "Beginning in 3..."; sleep 1; echo -n " 2..."; sleep 1; echo " 1..."; sleep 1
|
||||||
|
echo "==============================="
|
||||||
|
echo "=== All right! Time to go! ==="
|
||||||
|
echo "==============================="
|
||||||
|
for volume in $x; do
|
||||||
|
echo "= Investigating volume /$volume..."
|
||||||
|
objects=$(ls -A /"$volume" | egrep -v "^.apps$|^home$|^.purge$|^._share$|^.timemachine$|^.vault$|^.TemporaryItems$")
|
||||||
|
echo "= Objects found:" $objects
|
||||||
|
backup_configs
|
||||||
|
for item in $objects; do
|
||||||
|
echo "== Reviewing $item"
|
||||||
|
if ls -QdA /"$volume"/"$item"/.iscsi >/dev/null 2>&1; then
|
||||||
|
iscsi_create
|
||||||
|
else
|
||||||
|
share_create
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
echo "= done with /$volume"
|
||||||
|
done
|
||||||
|
|
||||||
|
if [[ $found -gt 0 ]] && [[ $readynasd ]] ; then
|
||||||
|
echo "*** Restarting readynasd to finish changes... ***"
|
||||||
|
systemctl restart readynasd
|
||||||
|
else
|
||||||
|
echo "Not starting readynasd because it returned a bad message earlier; restart manually."
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "================================================="
|
||||||
|
echo "| Completed share creation! We were able to |"
|
||||||
|
echo "| rebuild $shares shares and $iscsi LUNs. |"
|
||||||
|
echo "================================================="
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue