Parcourir la source

use ramfs to speed up writing

tags/1.5
Nico Rey il y a 4 ans
Parent
révision
83e5d1ca32
1 fichiers modifiés avec 22 ajouts et 8 suppressions
  1. +22
    -8
      migrate_data.sh

+ 22
- 8
migrate_data.sh Voir le fichier

@@ -1,13 +1,25 @@
#!/bin/bash #!/bin/bash


## import common lib
. "$HOME/.noaa.conf"
. "$HOME/.tweepy.conf"
. "$NOAA_HOME/common.sh"

# TODO: Warn the user # TODO: Warn the user
BASEPATH="/var/www/wx/image" BASEPATH="/var/www/wx/image"
FINALPATH="/var/www/wx/images" FINALPATH="/var/www/wx/images"
SAT_NAMES="NOAA15 NOAA18 NOAA19 METEOR-M2" SAT_NAMES="NOAA15 NOAA18 NOAA19 METEOR-M2"
DB_PATH="/var/ramfs/panel.db"
DB_PATH="${NOAA_HOME}/panel.db"


(
cd "${RAMFS_AUDIO}" || exit 1
sqlite3 < "${NOAA_HOME}/panel.sql"
)



cd "$BASEPATH" || exit 1 cd "$BASEPATH" || exit 1
mkdir -p "$FINALPATH"
mkdir -p "$FINALPATH/thumb"


for filename in $(find . -name *.jpg); do for filename in $(find . -name *.jpg); do
basename="$(echo "$filename" | sed 's~.*/~~')" basename="$(echo "$filename" | sed 's~.*/~~')"
@@ -23,18 +35,20 @@ for filename in $(find . -name *.jpg); do
passname=$(echo "$basename" | cut -f1,2 -d'-') passname=$(echo "$basename" | cut -f1,2 -d'-')
echo "Migration in progress: $basename" echo "Migration in progress: $basename"
cp "$BASEPATH/$filename" "$FINALPATH" cp "$BASEPATH/$filename" "$FINALPATH"
convert -thumbnail 300 "$BASEPATH/$filename" "$FINALPATH/thumb/$filename"
if [[ $basename == *"METEOR"* ]]; then if [[ $basename == *"METEOR"* ]]; then
sqlite3 "$DB_PATH" "insert into decoded_passes (pass_start, file_path, daylight_pass, is_noaa) values ($epoch_date,\"$passname\",1,0);"
sqlite3 "$DB_PATH" "insert into decoded_passes (pass_start, file_path, daylight_pass, is_noaa) values ($epoch_date,\"$passname\",1,0);"
sqlite3 "$DB_PATH" "insert or replace into predict_passes (sat_name,pass_start,pass_end,max_elev) values (\"$sat_name\",$epoch_date,$epoch_date,0);"
sqlite3 "${RAMFS_AUDIO}/panel.db" "insert into decoded_passes (pass_start, file_path, daylight_pass, is_noaa) values ($epoch_date,\"$passname\",1,0);"
sqlite3 "${RAMFS_AUDIO}/panel.db" "insert into decoded_passes (pass_start, file_path, daylight_pass, is_noaa) values ($epoch_date,\"$passname\",1,0);"
sqlite3 "${RAMFS_AUDIO}/panel.db" "insert or replace into predict_passes (sat_name,pass_start,pass_end,max_elev) values (\"$sat_name\",$epoch_date,$epoch_date,0);"
elif [[ $basename == *"ZA"* ]]; then elif [[ $basename == *"ZA"* ]]; then
sqlite3 "$DB_PATH" "insert or replace into predict_passes (sat_name,pass_start,pass_end,max_elev) values (\"$sat_name\",$epoch_date,$epoch_date,0);"
sqlite3 "${RAMFS_AUDIO}/panel.db" "insert or replace into predict_passes (sat_name,pass_start,pass_end,max_elev) values (\"$sat_name\",$epoch_date,$epoch_date,0);"
if [[ -f "$FINALPATH/$passname-MSA.jpg" ]]; then if [[ -f "$FINALPATH/$passname-MSA.jpg" ]]; then
sqlite3 "$DB_PATH" "insert into decoded_passes (pass_start, file_path, daylight_pass, is_noaa) values ($epoch_date,\"$passname\",1,1);"
sqlite3 "${RAMFS_AUDIO}/panel.db" "insert into decoded_passes (pass_start, file_path, daylight_pass, is_noaa) values ($epoch_date,\"$passname\",1,1);"
else else
sqlite3 "$DB_PATH" "insert into decoded_passes (pass_start, file_path, daylight_pass, is_noaa) values ($epoch_date,\"$passname\",0,1);"
sqlite3 "${RAMFS_AUDIO}/panel.db" "insert into decoded_passes (pass_start, file_path, daylight_pass, is_noaa) values ($epoch_date,\"$passname\",0,1);"
fi fi
fi fi
mv "${RAMFS_AUDIO}/panel.db" "$DB_PATH"
echo "Done." echo "Done."
echo "" echo ""
done done


Chargement…
Annuler
Enregistrer