#!/bin/sh ########################################################################### # # Copyright (c) 2021-2023 Diality Inc. - All Rights Reserved. # # THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN # WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. # # @file decommission_UI.sh # # @author (last) Vy Duong # @date (last) 26-May-2023 # @author (original) Vy Duong # @date (original) 26-May-2023 # ############################################################################ # @details # This file is called by UI Software to remove and reset the device to a decommissioned state if [ $# -eq 0 ]; then currentFile=$(basename "$0") echo "Usage: ./$currentFile " exit 0 fi ERR_PARTITION_NOT_DECRYPTED=256 #TODO determine agreed on error return value LOC_PARTITION="$1" # TODO as something passed in ? LOC_SETTINGS_CONF="/home/root/scripts/settings.conf" #TODO update to reflect real location LOC_DEFAULT_SETTINGS_CONF="/home/root/scripts/default_settings.conf" #TODO update to reflect real location LOC_WIFI_CONF="/etc/wpa_supplicant/wpa_supplicant-wlan0.conf" LOC_BLUETOOTH_CONF="/etc/bluetooth/main.conf" # ------------------------------ Remove Wifi Conf if [ -f $LOC_WIFI_CONF ]; then rm "$LOC_WIFI_CONF" echo "Deleted Wifi Conf" fi # ------------------------------ Remove Bluetooth Conf if [ -f $LOC_BLUETOOTH_CONF ]; then rm "$LOC_BLUETOOTH_CONF" echo "Deleted Bluetooth Conf" fi # ------------------------------ Reset Settings Conf cp $LOC_DEFAULT_SETTINGS_CONF $LOC_SETTINGS_CONF #TODO reset service password # ------------------------------ Remove Logs rm -rf /media/sd-card/log rm -rf /media/sd-card/service rm -rf /media/sd-card/treatment # ------------------------------ Format Former Encrypted Partition # Assuming the partition is decrypted in advance luksDump=$(cryptsetup isLuks $LOC_PARTITION) if [ $luksDump ]; then echo "FAILED : $LOC_PARTITION needs to be decrypted" exit ERR_PARTITION_NOT_DECRYPTED else # proceed to format the partition mkfs.ext4 $LOC_PARTITION fi # ------------------------------ Remove CloudSync Token # TODO remove the cloudsync token ? Need additional info on how exit 0