SKIPMOUNT=false
PROPFILE=true
POSTFSDATA=true
SERVICESH=true

# Waguri-san loves a clean system


set_permissions() {
  set_perm_recursive $MODPATH 0 0 0755 0644
  set_perm $MODPATH/service.sh 0 0 0755
  chmod +x $MODPATH/service.sh
}

ui_print "--------------------------------------"
ui_print "       Waguri-san Project v1.0 Beta       "
ui_print "     Memory Master - Special Edition  "
ui_print "--------------------------------------"
ui_print " "
ui_print "           .     .     .              "
ui_print "        .  :  .  :  .  :  .           "
ui_print "          '  :  :  :  '               "
ui_print "      . . .   🌸🌸🌸   . . .          "
ui_print "          .  :  :  :  .               "
ui_print "        '  :  '  :  '  :  '           "
ui_print "           '     '     '              "
ui_print " "
ui_print "       The Flower is Blooming...      "
ui_print "--------------------------------------"
sleep 2

ui_print "- Waguri-san is checking your device..."
sleep 2

MODEL=$(getprop ro.product.model)
MANUFACTURER=$(getprop ro.product.manufacturer)
CHIPSET=$(getprop ro.board.platform)
ANDROID_VER=$(getprop ro.build.version.release)
RAM_TOTAL=$(free -m | grep Mem | awk '{print $2}')

ui_print "  [Device]   : $MANUFACTURER $MODEL"
sleep 1
ui_print "  [Android]  : $ANDROID_VER"
sleep 1
ui_print "  [Chipset]  : $CHIPSET"
sleep 1
ui_print "  [RAM Size] : ${RAM_TOTAL}MB"
sleep 2

ui_print "--------------------------------------"
ui_print "- Cleaning memory slots for you... ✨"
sleep 2

# Extracting files
unzip -o "$ZIPFILE" 'logo_waguri.png' -d "$MODPATH" >&2
unzip -o "$ZIPFILE" 'service.sh' -d "$MODPATH" >&2

if [ -f "$MODPATH/logo_waguri.png" ]; then
    ui_print "- Preparing Waguri-san's Portrait..."
    cp -af "$MODPATH/logo_waguri.png" "/data/local/tmp/logo_waguri.png"
    chmod 666 "/data/local/tmp/logo_waguri.png"
    chown system:system "/data/local/tmp/logo_waguri.png"
fi

ui_print "- Applying Memory Perfection..."
set_permissions
sleep 2
ui_print "- Done! Reboot to let the flower bloom."
ui_print "--------------------------------------"
