[Issue#] N/A
[Feature/Bug] N/A
[Problem] After calling wrt_reset_all.sh wrt database labels are reset to "_"
[Cause] Db files are removed and created with default label
[Solution] Old label is stored and applied to newly created files
[Verification]
1.Check /opt/dbspace/.wrt.db* labels with chsmack [filename]. It should be
"wrt-commons::db_wrt"
2.Run wrt_reset_all.sh. Check labels again. They should be the same.
Change-Id: I885638d482c921fadea0a74d773ce8a548387483
for name in wrt wrt_autosave wrt_custom_handler
do
for name in wrt wrt_autosave wrt_custom_handler
do
+ # extract smack label before removal
+ DB_LABEL=""
+ if [ -f /opt/dbspace/.$name.db ]
+ then
+ DB_LABEL=`chsmack /opt/dbspace/.$name.db | sed -r "s/.*access=\"([^\"]+)\"/\1/"`
+ fi
rm -f /opt/dbspace/.$name.db
rm -f /opt/dbspace/.$name.db
+
+ # extract smack label before removal
+ JOURNAL_LABEL=""
+ if [ -f /opt/dbspace/.$name.db-journal ]
+ then
+ JOURNAL_LABEL=`chsmack /opt/dbspace/.$name.db-journal | sed -r "s/.*access=\"([^\"]+)\"/\1/"`
+ fi
rm -f /opt/dbspace/.$name.db-journal
rm -f /opt/dbspace/.$name.db-journal
SQL="PRAGMA journal_mode = PERSIST;"
sqlite3 /opt/dbspace/.$name.db "$SQL"
SQL=".read /usr/share/wrt-engine/"$name"_db.sql"
SQL="PRAGMA journal_mode = PERSIST;"
sqlite3 /opt/dbspace/.$name.db "$SQL"
SQL=".read /usr/share/wrt-engine/"$name"_db.sql"
chown 0:6026 /opt/dbspace/.$name.db-journal
chmod 660 /opt/dbspace/.$name.db
chmod 660 /opt/dbspace/.$name.db-journal
chown 0:6026 /opt/dbspace/.$name.db-journal
chmod 660 /opt/dbspace/.$name.db
chmod 660 /opt/dbspace/.$name.db-journal
+
+ # restore smack label
+ if [ -n "$DB_LABEL" ]
+ then
+ chsmack -a $DB_LABEL /opt/dbspace/.$name.db
+ fi
+
+ # restore smack label
+ if [ -n "$JOURNAL_LABEL" ]
+ then
+ chsmack -a $JOURNAL_LABEL /opt/dbspace/.$name.db-journal
+ fi