[IMP] point_of_sale: Change raspbian to raspios
We change the OS from Raspbian to Raspberry Pi OS So we change all occurence of raspbian to raspios m X-original-commit: f54f02e208f7f96e89a0b2a68c57570edb0c75d5
This commit is contained in:
@@ -330,11 +330,11 @@ class IoTboxHomepage(web.Home):
|
||||
_logger.error('A error encountered : %s ' % e)
|
||||
return Response(str(e), status=500)
|
||||
|
||||
@http.route('/hw_proxy/perform_flashing_download_raspbian', type='http', auth='none')
|
||||
def perform_flashing_download_raspbian(self):
|
||||
@http.route('/hw_proxy/perform_flashing_download_raspios', type='http', auth='none')
|
||||
def perform_flashing_download_raspios(self):
|
||||
try:
|
||||
response = subprocess.check_output(['sudo', 'bash', '-c', '. /home/pi/odoo/addons/point_of_sale/tools/posbox/configuration/upgrade.sh; download_raspbian']).decode().split('\n')[-2]
|
||||
if response == 'Error_Raspbian_Download':
|
||||
response = subprocess.check_output(['sudo', 'bash', '-c', '. /home/pi/odoo/addons/point_of_sale/tools/posbox/configuration/upgrade.sh; download_raspios']).decode().split('\n')[-2]
|
||||
if response == 'Error_Raspios_Download':
|
||||
raise Exception(response)
|
||||
return Response('success', status=200)
|
||||
except subprocess.CalledProcessError as e:
|
||||
@@ -344,10 +344,10 @@ class IoTboxHomepage(web.Home):
|
||||
_logger.error('A error encountered : %s ' % e)
|
||||
return Response(str(e), status=500)
|
||||
|
||||
@http.route('/hw_proxy/perform_flashing_copy_raspbian', type='http', auth='none')
|
||||
def perform_flashing_copy_raspbian(self):
|
||||
@http.route('/hw_proxy/perform_flashing_copy_raspios', type='http', auth='none')
|
||||
def perform_flashing_copy_raspios(self):
|
||||
try:
|
||||
response = subprocess.check_output(['sudo', 'bash', '-c', '. /home/pi/odoo/addons/point_of_sale/tools/posbox/configuration/upgrade.sh; copy_raspbian']).decode().split('\n')[-2]
|
||||
response = subprocess.check_output(['sudo', 'bash', '-c', '. /home/pi/odoo/addons/point_of_sale/tools/posbox/configuration/upgrade.sh; copy_raspios']).decode().split('\n')[-2]
|
||||
if response == 'Error_Iotbox_Download':
|
||||
raise Exception(response)
|
||||
return Response('success', status=200)
|
||||
|
||||
@@ -32,9 +32,9 @@
|
||||
try {
|
||||
await $.ajax({url: '/hw_proxy/perform_flashing_create_partition/'}).promise();
|
||||
$('.message-status').text('Prepare new boot partition.');
|
||||
await $.ajax({url: '/hw_proxy/perform_flashing_download_raspbian/'}).promise();
|
||||
await $.ajax({url: '/hw_proxy/perform_flashing_download_raspios/'}).promise();
|
||||
$('.message-status').text('Download file for new boot partition.');
|
||||
await $.ajax({url: '/hw_proxy/perform_flashing_copy_raspbian/'}).promise();
|
||||
await $.ajax({url: '/hw_proxy/perform_flashing_copy_raspios/'}).promise();
|
||||
$('.message-status').text('Prepare to restart and installation of the new version of the IoT Box.');
|
||||
setTimeout(function() {
|
||||
$('.message-status').text('The auto flash is almost finished - the page will be automatically reloaded');
|
||||
|
||||
@@ -48,84 +48,84 @@ create_partition () {
|
||||
echo 'p'; # print
|
||||
echo 'w') |fdisk "${PARTITION}" # write and quit
|
||||
|
||||
PART_RASPBIAN_ROOT=$(sudo fdisk -l | tail -n 1 | awk '{print $1}')
|
||||
PART_RASPIOS_ROOT=$(sudo fdisk -l | tail -n 1 | awk '{print $1}')
|
||||
sleep 5
|
||||
|
||||
# Clean partition
|
||||
mount -o remount,rw /
|
||||
partprobe # apply changes to partitions
|
||||
resize2fs "${PART_ODOO_ROOT}"
|
||||
mkfs.ext4 -Fv "${PART_RASPBIAN_ROOT}" # change file sytstem
|
||||
mkfs.ext4 -Fv "${PART_RASPIOS_ROOT}" # change file sytstem
|
||||
|
||||
echo "end fdisking"
|
||||
}
|
||||
|
||||
download_raspbian () {
|
||||
if [ ! -f *raspbian*.img ] ; then
|
||||
# download latest Raspbian image and check integrity
|
||||
LATEST_RASPBIAN=$(curl -LIsw %{url_effective} http://downloads.raspberrypi.org/raspbian_lite_latest | tail -n 1)
|
||||
wget -c "${LATEST_RASPBIAN}"
|
||||
RASPBIAN=$(echo *raspbian*.zip)
|
||||
wget -c "${LATEST_RASPBIAN}".sha256
|
||||
CHECK=$(sha256sum -c "${RASPBIAN}".sha256)
|
||||
if [ "${CHECK}" != "${RASPBIAN}: OK" ]
|
||||
download_raspios () {
|
||||
if [ ! -f *raspios*.img ] ; then
|
||||
# download latest Raspios image and check integrity
|
||||
LATEST_RASPIOS=$(curl -LIsw %{url_effective} http://downloads.raspberrypi.org/raspios_lite_armhf_latest | tail -n 1)
|
||||
wget -c "${LATEST_RASPIOS}"
|
||||
RASPIOS=$(echo *raspios*.zip)
|
||||
wget -c "${LATEST_RASPIOS}".sha256
|
||||
CHECK=$(sha256sum -c "${RASPIOS}".sha256)
|
||||
if [ "${CHECK}" != "${RASPIOS}: OK" ]
|
||||
then
|
||||
# Checksum is not correct so clean and reset self-flashing
|
||||
mount -o remount,rw /
|
||||
# Clean raspbian img
|
||||
rm "${RASPBIAN}" "${RASPBIAN}".sha256
|
||||
# Clean raspios img
|
||||
rm "${RASPIOS}" "${RASPIOS}".sha256
|
||||
|
||||
rm start_upgrade
|
||||
echo "Error_Raspbian_Download"
|
||||
echo "Error_Raspios_Download"
|
||||
exit 0
|
||||
fi
|
||||
unzip "${RASPBIAN}"
|
||||
unzip "${RASPIOS}"
|
||||
fi
|
||||
|
||||
echo "end dowloading raspbian"
|
||||
echo "end dowloading raspios"
|
||||
}
|
||||
|
||||
copy_raspbian () {
|
||||
copy_raspios () {
|
||||
umount -v /boot
|
||||
|
||||
# mapper raspbian
|
||||
PART_RASPBIAN_ROOT=$(fdisk -l | tail -n 1 | awk '{print $1}')
|
||||
# mapper raspios
|
||||
PART_RASPIOS_ROOT=$(fdisk -l | tail -n 1 | awk '{print $1}')
|
||||
PART_ODOO_ROOT=$(fdisk -l | tail -n 2 | awk 'NR==1 {print $1}')
|
||||
PART_BOOT=$(fdisk -l | tail -n 3 | awk 'NR==1 {print $1}')
|
||||
RASPBIAN=$(echo *raspbian*.img)
|
||||
LOOP_RASPBIAN=$(kpartx -avs "${RASPBIAN}")
|
||||
LOOP_RASPBIAN_ROOT=$(echo "${LOOP_RASPBIAN}" | tail -n 1 | awk '{print $3}')
|
||||
LOOP_RASPBIAN_ROOT="/dev/mapper/${LOOP_RASPBIAN_ROOT}"
|
||||
LOOP_BOOT=$(echo "${LOOP_RASPBIAN}" | tail -n 2 | awk 'NR==1 {print $3}')
|
||||
RASPIOS=$(echo *raspios*.img)
|
||||
LOOP_RASPIOS=$(kpartx -avs "${RASPIOS}")
|
||||
LOOP_RASPIOS_ROOT=$(echo "${LOOP_RASPIOS}" | tail -n 1 | awk '{print $3}')
|
||||
LOOP_RASPIOS_ROOT="/dev/mapper/${LOOP_RASPIOS_ROOT}"
|
||||
LOOP_BOOT=$(echo "${LOOP_RASPIOS}" | tail -n 2 | awk 'NR==1 {print $3}')
|
||||
LOOP_BOOT="/dev/mapper/${LOOP_BOOT}"
|
||||
|
||||
mount -o remount,rw /
|
||||
# copy raspbian
|
||||
dd if="${LOOP_RASPBIAN_ROOT}" of="${PART_RASPBIAN_ROOT}" bs=4M status=progress
|
||||
e2fsck -fv "${PART_RASPBIAN_ROOT}" # resize2fs requires clean fs
|
||||
# copy raspios
|
||||
dd if="${LOOP_RASPIOS_ROOT}" of="${PART_RASPIOS_ROOT}" bs=4M status=progress
|
||||
e2fsck -fv "${PART_RASPIOS_ROOT}" # resize2fs requires clean fs
|
||||
|
||||
# Modify startup
|
||||
mkdir -v raspbian
|
||||
mount -v "${PART_RASPBIAN_ROOT}" raspbian
|
||||
resize2fs "${PART_RASPBIAN_ROOT}"
|
||||
chroot raspbian/ /bin/bash -c "sudo apt-get -y install kpartx"
|
||||
mkdir -v raspios
|
||||
mount -v "${PART_RASPIOS_ROOT}" raspios
|
||||
resize2fs "${PART_RASPIOS_ROOT}"
|
||||
chroot raspios/ /bin/bash -c "sudo apt-get -y install kpartx"
|
||||
PATH_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
cp -v "${PATH_DIR}"/upgrade.sh raspbian/home/pi/
|
||||
NBR_LIGNE=$(sed -n -e '$=' raspbian/etc/rc.local)
|
||||
sed -ie "${NBR_LIGNE}"'i\. /home/pi/upgrade.sh; copy_iot' raspbian/etc/rc.local
|
||||
cp -v /etc/fstab raspbian/etc/fstab
|
||||
sed -ie "s/$(echo ${PART_ODOO_ROOT} | sed -e 's/\//\\\//g')/$(echo ${PART_RASPBIAN_ROOT} | sed -e 's/\//\\\//g')/g" raspbian/etc/fstab
|
||||
mkdir raspbian/home/pi/config
|
||||
find /home/pi -maxdepth 1 -type f ! -name ".*" -exec cp {} raspbian/home/pi/config/ \;
|
||||
cp -v "${PATH_DIR}"/upgrade.sh raspios/home/pi/
|
||||
NBR_LIGNE=$(sed -n -e '$=' raspios/etc/rc.local)
|
||||
sed -ie "${NBR_LIGNE}"'i\. /home/pi/upgrade.sh; copy_iot' raspios/etc/rc.local
|
||||
cp -v /etc/fstab raspios/etc/fstab
|
||||
sed -ie "s/$(echo ${PART_ODOO_ROOT} | sed -e 's/\//\\\//g')/$(echo ${PART_RASPIOS_ROOT} | sed -e 's/\//\\\//g')/g" raspios/etc/fstab
|
||||
mkdir raspios/home/pi/config
|
||||
find /home/pi -maxdepth 1 -type f ! -name ".*" -exec cp {} raspios/home/pi/config/ \;
|
||||
|
||||
# download latest IoT Box image and check integrity
|
||||
wget -c 'https://nightly.odoo.com/master/iotbox/iotbox-latest.zip' -O raspbian/iotbox-latest.zip
|
||||
wget -c 'https://nightly.odoo.com/master/iotbox/SHA1SUMS.txt' -O raspbian/SHA1SUMS.txt
|
||||
cd raspbian/
|
||||
wget -c 'https://nightly.odoo.com/master/iotbox/iotbox-latest.zip' -O raspios/iotbox-latest.zip
|
||||
wget -c 'https://nightly.odoo.com/master/iotbox/SHA1SUMS.txt' -O raspios/SHA1SUMS.txt
|
||||
cd raspios/
|
||||
CHECK=$(sha1sum -c --ignore-missing SHA1SUMS.txt)
|
||||
cd ..
|
||||
|
||||
umount -v raspbian
|
||||
umount -v raspios
|
||||
if [ "${CHECK}" != "iotbox-latest.zip: OK" ]
|
||||
then
|
||||
# Checksum is not correct so clean and reset self-flashing
|
||||
@@ -143,11 +143,11 @@ copy_raspbian () {
|
||||
mkdir -v boot
|
||||
mount -v "${PART_BOOT}" boot
|
||||
PART_IOT_BOOT_ID=$(grep -oP '(?<=root=).*(?=rootfstype)' boot/cmdline.txt)
|
||||
sed -ie "s/$(echo ${PART_IOT_BOOT_ID} | sed -e 's/\//\\\//g')/$(echo ${PART_RASPBIAN_ROOT} | sed -e 's/\//\\\//g')/g" boot/cmdline.txt
|
||||
sed -ie "s/$(echo ${PART_IOT_BOOT_ID} | sed -e 's/\//\\\//g')/$(echo ${PART_RASPIOS_ROOT} | sed -e 's/\//\\\//g')/g" boot/cmdline.txt
|
||||
umount -v boot
|
||||
|
||||
kpartx -dv "${RASPBIAN}"
|
||||
rm -v "${RASPBIAN}"
|
||||
kpartx -dv "${RASPIOS}"
|
||||
rm -v "${RASPIOS}"
|
||||
|
||||
reboot
|
||||
}
|
||||
@@ -201,11 +201,11 @@ copy_iot () {
|
||||
|
||||
cleanup () {
|
||||
# clean partitions
|
||||
PART_RASPBIAN_ROOT=$(fdisk -l | tail -n 1 | awk '{print $1}')
|
||||
mkfs.ext4 -Fv "${PART_RASPBIAN_ROOT}" # format file sytstem
|
||||
wipefs -a "${PART_RASPBIAN_ROOT}"
|
||||
PART_RASPIOS_ROOT=$(fdisk -l | tail -n 1 | awk '{print $1}')
|
||||
mkfs.ext4 -Fv "${PART_RASPIOS_ROOT}" # format file sytstem
|
||||
wipefs -a "${PART_RASPIOS_ROOT}"
|
||||
|
||||
PARTITION=$(echo "${PART_RASPBIAN_ROOT}" | sed 's/..$//')
|
||||
PARTITION=$(echo "${PART_RASPIOS_ROOT}" | sed 's/..$//')
|
||||
|
||||
(echo 'p'; # print
|
||||
echo 'd'; # delete partition
|
||||
|
||||
@@ -96,7 +96,7 @@ rm -rfv /usr/share/doc
|
||||
|
||||
# python-usb in wheezy is too old
|
||||
# the latest pyusb from pip does not work either, usb.core.find() never returns
|
||||
# this may be fixed with libusb>2:1.0.11-1, but that's the most recent one in raspbian
|
||||
# this may be fixed with libusb>2:1.0.11-1, but that's the most recent one in raspios
|
||||
# so we install the latest pyusb that works with this libusb.
|
||||
# Even in stretch, we had an error with langid (but worked otherwise)
|
||||
# We fixe the version of evdev to 1.2.0 because in 1.3.0 we have a RuntimeError in 'get_event_loop()'
|
||||
|
||||
@@ -37,8 +37,8 @@ if ! file_exists *raspios*.img ; then
|
||||
unzip raspios.img.zip
|
||||
fi
|
||||
|
||||
RASPBIAN=$(echo *raspios*.img)
|
||||
rsync -avh --progress "${RASPBIAN}" iotbox.img
|
||||
RASPIOS=$(echo *raspios*.img)
|
||||
rsync -avh --progress "${RASPIOS}" iotbox.img
|
||||
|
||||
CLONE_DIR="${OVERWRITE_FILES_BEFORE_INIT_DIR}/home/pi/odoo"
|
||||
|
||||
@@ -99,10 +99,10 @@ START_OF_ROOT_PARTITION=$(fdisk -l iotbox.img | tail -n 1 | awk '{print $2}')
|
||||
echo 'p'; # print
|
||||
echo 'w') | fdisk iotbox.img # write and quit
|
||||
|
||||
LOOP_RASPBIAN=$(kpartx -avs "${RASPBIAN}")
|
||||
LOOP_RASPBIAN_ROOT=$(echo "${LOOP_RASPBIAN}" | tail -n 1 | awk '{print $3}')
|
||||
LOOP_RASPBIAN_PATH="/dev/${LOOP_RASPBIAN_ROOT::-2}"
|
||||
LOOP_RASPBIAN_ROOT="/dev/mapper/${LOOP_RASPBIAN_ROOT}"
|
||||
LOOP_RASPIOS=$(kpartx -avs "${RASPIOS}")
|
||||
LOOP_RASPIOS_ROOT=$(echo "${LOOP_RASPIOS}" | tail -n 1 | awk '{print $3}')
|
||||
LOOP_RASPIOS_PATH="/dev/${LOOP_RASPIOS_ROOT::-2}"
|
||||
LOOP_RASPIOS_ROOT="/dev/mapper/${LOOP_RASPIOS_ROOT}"
|
||||
|
||||
LOOP_IOT=$(kpartx -avs iotbox.img)
|
||||
LOOP_IOT_ROOT=$(echo "${LOOP_IOT}" | tail -n 1 | awk '{print $3}')
|
||||
@@ -113,7 +113,7 @@ LOOP_IOT_BOOT="/dev/mapper/${LOOP_IOT_BOOT}"
|
||||
|
||||
mkfs.ext4 -v "${LOOP_IOT_ROOT}"
|
||||
|
||||
dd if="${LOOP_RASPBIAN_ROOT}" of="${LOOP_IOT_ROOT}" bs=4M status=progress
|
||||
dd if="${LOOP_RASPIOS_ROOT}" of="${LOOP_IOT_ROOT}" bs=4M status=progress
|
||||
|
||||
# resize filesystem
|
||||
e2fsck -fv "${LOOP_IOT_ROOT}" # resize2fs requires clean fs
|
||||
@@ -159,4 +159,4 @@ zerofree -v "${LOOP_IOT_ROOT}" || true
|
||||
sleep 10
|
||||
|
||||
kpartx -dv "${LOOP_IOT_PATH}"
|
||||
kpartx -dv "${LOOP_RASPBIAN_PATH}"
|
||||
kpartx -dv "${LOOP_RASPIOS_PATH}"
|
||||
|
||||
Reference in New Issue
Block a user