#!/usr/bin/env bash

sudo mount -o remount,rw /

cd /home/pi/odoo
localbranch=$(git symbolic-ref -q --short HEAD)
localremote=$(git config branch.$localbranch.remote)
git fetch "${localremote}" "${localbranch}" --depth=1
git reset "${localremote}"/"${localbranch}" --hard
sudo mount -o remount,ro /
(sleep 5 && sudo service odoo restart) &

#!/usr/bin/env bash

sudo mount -o remount,rw /

cd /home/pi/odoo
localbranch=$(git symbolic-ref -q --short HEAD)
localremote=$(git config branch.$localbranch.remote)

echo "addons/point_of_sale/tools/posbox/overwrite_after_init/home/pi/odoo" >> .git/info/sparse-checkout

git fetch "${localremote}" "${localbranch}" --depth=1
git reset "${localremote}"/"${localbranch}" --hard

git clean -df
cp -a /home/pi/odoo/addons/point_of_sale/tools/posbox/overwrite_after_init/home/pi/odoo/* /home/pi/odoo/
rm -r /home/pi/odoo/addons/point_of_sale/tools/posbox/overwrite_after_init

sudo find / -type f -name "*.iotpatch" 2> /dev/null | while read iotpatch; do
    DIR=$(dirname "${iotpatch}")
    BASE=$(basename "${iotpatch%.iotpatch}")
    sudo find "${DIR}" -type f -name "${BASE}" ! -name "*.iotpatch" | while read file; do
        sudo patch -f "${file}" < "${iotpatch}"
    done
done

sudo mount -o remount,ro /
sudo mount -o remount,rw /root_bypass_ramdisks/etc/cups
(sleep 5 && sudo service odoo restart) &

Apply iotpatch after IoT Box upgrade
[FIX] iot: Apply iotpatch after IoT Box upgrade

We didn't apply the iotpatch files after upgrading the IoT Box,
resulting in the crash of the Box and the user needed to re-flash his
Box.

closes odoo/odoo#41885

X-original-commit: 8dceea9383ed94b9fed7e76bbbe33794526af417
Signed-off-by: Quentin Lejeune (qle) <5d1c09880ce30fdcf63039932dac0c183ef0bdc7@odoo.com>
