diff --git a/rootdir/bin/move_wifi_data.sh b/rootdir/bin/move_wifi_data.sh index f8deaf0f6d76aacaf650749b46494802e7d70dfc..24083e1b0f84658534435e170f522a55bcd3dbf0 100755 --- a/rootdir/bin/move_wifi_data.sh +++ b/rootdir/bin/move_wifi_data.sh @@ -33,22 +33,40 @@ DEST_PATH="/data/vendor/wifi" FILES_MOVED="/data/vendor/wifi/moved" SRC_PATH="/data/misc/wifi" +function copy_file() { + echo "=== Copying $1 to $2 ..." + if [ ! -f "$1" ] + then + echo " return as $1 not exist"; + return; + fi + + if [ ! -d "$2" ] + then + echo " dest path is not exist, making dir $2"; + mkdir -p $2 -m 700 + fi + + if [ ! -d "$2" ] + then + echo " mkdir failed" + return; + fi + + echo " copied $1 success" + cp $1 $2 +} + if [ ! -f "$FILES_MOVED" ]; then - for i in "$SRC_PATH/"*; do - dest_path=$DEST_PATH/"${i#$SRC_PATH/}" - echo $dest_path - if [ -d "$i" ]; then - mkdir -p $dest_path -m 700 - mv $i "$DEST_PATH" - else - mv $i "$DEST_PATH" - fi - find $DEST_PATH -print0 | while IFS= read -r -d '' file - do - chgrp wifi "$file" - done - echo $i - done + copy_file "$SRC_PATH/p2p_supplicant.conf" "$DEST_PATH/wpa/" + copy_file "$SRC_PATH/hostapd.accept" "$DEST_PATH/hostapd/" + copy_file "$SRC_PATH/hostapd.deny" "$DEST_PATH/hostapd/" + + find $DEST_PATH -print0 | while IFS= read -r -d '' file + do + chgrp wifi "$file" + echo " chgrp wifi $file" + done restorecon -R "$DEST_PATH" echo 1 > "$FILES_MOVED" fi