Merge branch '1-update-script-for-os-6-8' into 'master'

Resolve "Update script for OS 6.8"

Closes #1

See merge request !1
This commit is contained in:
Cody Cook 2017-08-22 17:28:25 -07:00
commit e4e6079a0b
2 changed files with 110 additions and 21 deletions

View file

@ -1,6 +1,51 @@
#!/bin/bash
(
volume="data"
for i in `find /$volume -maxdepth 2 -type d -name ".iscsi" | sed "s/\/.iscsi//g;s/\/$volume\///g;"`; do mkdir -p /$volume/._share/${i} cd /$volume/._share/${i}; echo "comment " > iscsi.conf; echo "0 0 0 * 0 0 0" > snapshot.conf;done
)
# 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

View file

@ -1,23 +1,58 @@
#!/bin/bash
(
volume="data"
#volume=$(rn_nml -g volumes | grep resource-id | awk '{print $2}' | sed 's/resource-id="//;s/"$//')
# share fix
# use this script to rebuild default configs for shares if the ._share becomes
# broken for whatever reason.
for i in `find /$volume/ -mindepth 2 -maxdepth 2 -type d | egrep -v "\/$volume\/home|\/$volume\/.apps|\/$volume\/.vault|\/$volume\/.purge|\/$volume\/._share|\/$volume\/.timemachine|\/$volume\/.TemporaryItems|.iscsi" | sed "s/\/$volume\///g;s/\/.*//g" | sort | uniq`; do mkdir -p /$volume/._share/${i}; cd /$volume/._share/${i}; echo "share" > datasettype.conf; echo "0,25000" > recycle.conf; echo "#dashboard:available=0 \"/$volume/$i\" 127.0.0.1(ro,insecure,insecure_locks,root_squash,anongid=99,anonuid=99,no_subtree_check,sync)" > nfs.conf; echo "" > snapdir.conf; echo "0 0 0 * * * 0" > snapshot.conf; cat > afp.conf << EOF
echo "Activating 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/ -mindepth 1 -maxdepth 2 -type d | egrep -v "\/$volume\/home|\/$volume\/.apps|\/$volume\/.vault|\/$volume\/.purge|\/$volume\/._share|\/$volume\/.timemachine|\/$volume\/.TemporaryItems|.iscsi" | sed "s/\/$volume\///g;s/\/.*//g" | sort | uniq`
do
found=1
path="/$volume/._share/${i}"
echo "Found /$volume/${i}... recreating configs...".
mkdir -p "$path"
echo "share" > $path/datasettype.conf
echo "0,0" > $path/recycle.conf
echo "#dashboard:available=0 \"/$volume/$i\" 127.0.0.1(ro,insecure,insecure_locks,no_subtree_check,crossmnt,anongid=99,anonuid=99,root_squash,async)" > $path/nfs.conf
echo "" > $path/snapdir.conf
echo "0 0 0 * * * 0" > $path/snapshot.conf
cat > $path/afp.conf << EOF
[$i]
available = 1
path = /$volume/$i
invalid users = "guest","nobody","@guest","@nogroup"
admin group = admin
EOF
cat > fs.conf << 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/fs.conf << EOF
compression = 0
bitrotprotection = 0
refquota = 0
EOF
cat > ftp.conf << EOF
cat > $path/ftp.conf << EOF
available 0
default_access writeable
default_access disabled
mask
fmask
dmask
@ -28,18 +63,27 @@ user_ro
group_ro
host_ro
EOF
cat > samba.conf << EOF
cat > $path/samba.conf << EOF
[$i]
path = /$volume/$i
comment = "$i folder"
force create mode = 0666
create mask = 0666
force directory mode = 1777
directory mask = 1777
admin users = "+admin","Administrator"
spotlight = 0
guest ok = 1
admin users = +admin
writeable = 1
follow symlinks = 1
EOF
chown root.root datasettype.conf recycle.conf snapdir.conf snapshot.conf; chown admin.admin afp.conf fs.conf ftp.conf nfs.conf samba.conf
echo -n "Fixing permissions on files..."
cd $path
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
echo " done!"
echo " Done with /$volume/${i}."
done
echo " Done with /$volume"
done
)
if [[ $found ]]
then
echo "Restarting readynasd to finish changes..."
systemctl restart readynasd
fi