| #!/bin/sh |
| |
| set -e |
| |
| #files_to_backup=" |
| #/user/bsa |
| #" |
| |
| |
| backup_and_zap() { |
| #for i in $files_to_backup; do |
| # echo cp -pr $i /var/backup/$i |
| #done |
| echo "$i became read-only due to errors. Running zap." |
| /bin/zap --i-really-mean-it |
| # /bin/zap runs reboot |
| } |
| |
| SLEEPTIME=120 |
| |
| # Default |
| debugubifs="/sys/kernel/debug/ubifs" |
| if [ -n "$1" ]; then |
| # override default |
| debugubifs="$1" |
| fi |
| |
| |
| pattern="$debugubifs/ubi*_*/readonly $debugubifs/ubi*_*/ro_error" |
| |
| while :; do |
| for i in $pattern; do |
| if [ ! -e "$i" ]; then |
| continue |
| fi |
| value='' |
| value="$(cat "$i")" |
| if [ "$value" = 1 ]; then |
| backup_and_zap $i |
| exit 0 |
| fi |
| if [ "$value" != 0 ]; then |
| echo "$0: $i contains invalid value" 1>&2 |
| exit 1 |
| fi |
| done |
| sleep $SLEEPTIME |
| done |