|
|
@@ -65,6 +65,7 @@ _dest_data="/dev/disk/by-label/sddata"
|
|
|
_erase_data="no"
|
|
|
_part6_label="auxpart"
|
|
|
_part6_dlabel="Reserved"
|
|
|
+_instfound="no"
|
|
|
|
|
|
#-----------------------------------------------------
|
|
|
# Check card type
|
|
|
@@ -81,8 +82,6 @@ fi
|
|
|
#-----------------------------------------------------
|
|
|
# Check where the installation files are located
|
|
|
check_source() {
|
|
|
- local _instfound="no"
|
|
|
-
|
|
|
if [ -b ${1} ]; then
|
|
|
/bin/mountx ${1} /mnt > /dev/null 2>&1
|
|
|
[ $? -ne 0 ] && return 1
|
|
|
@@ -150,7 +149,7 @@ check_source() {
|
|
|
_part6_label="oelec"
|
|
|
_part6_dlabel="OpenElec"
|
|
|
else
|
|
|
- if [ -f /mnt/oelec.tar ]; then
|
|
|
+ if [ -f /mnt/oelec.tar ] || [ -f /mnt/oelec.zip ]; then
|
|
|
INST_OELEC="yes"
|
|
|
_part6_label="oelec"
|
|
|
_part6_dlabel="OpenElec"
|
|
|
@@ -218,7 +217,7 @@ sleep 1
|
|
|
#=================================================
|
|
|
printf " Searching for installation drive ... "
|
|
|
|
|
|
-# === Set default dest card to sdcard if exists ===
|
|
|
+# === Set default dest card to NON BOOT if exists ===
|
|
|
DEST_CARD=${CARD1}
|
|
|
DEST_EMMC=${CARD1_EMMC}
|
|
|
if [ "${NUMCARDS}" = "2" ]; then
|
|
|
@@ -226,20 +225,24 @@ if [ "${NUMCARDS}" = "2" ]; then
|
|
|
DEST_EMMC=${CARD2_EMMC}
|
|
|
fi
|
|
|
|
|
|
-check_source "/dev/sda1"
|
|
|
-if [ $? -ne 0 ]; then
|
|
|
- check_source "/dev/sda2"
|
|
|
- if [ $? -ne 0 ]; then
|
|
|
- check_source "/dev/sda3"
|
|
|
- if [ $? -ne 0 ]; then
|
|
|
- check_source "/dev/sda4"
|
|
|
- if [ $? -ne 0 ]; then
|
|
|
- printf " \033[33m\033[1mNOT FOUND, aborted\033[22m\033[37m\n"
|
|
|
- exit_script
|
|
|
- fi
|
|
|
- fi
|
|
|
- fi
|
|
|
+_instfound="no"
|
|
|
+#----------------------------------------------------
|
|
|
+for src_drive in a b c
|
|
|
+do
|
|
|
+ for src_part in 1 2 3 4
|
|
|
+ do
|
|
|
+ check_source "/dev/sd${src_drive}${src_part}"
|
|
|
+ [ "${_instfound}" = "yes" ] && break
|
|
|
+ done
|
|
|
+ [ "${_instfound}" = "yes" ] && break
|
|
|
+done
|
|
|
+if [ "${_instfound}" = "no" ]; then
|
|
|
+ printf " \033[33m\033[1mNOT FOUND, aborted\033[22m\033[37m\n"
|
|
|
+ exit_script
|
|
|
fi
|
|
|
+printf " \033[33m\032[1mFOUND on sd%s%s\033[22m\033[37m\n" "${src_drive}${src_part}"
|
|
|
+sleep 2
|
|
|
+#----------------------------------------------------
|
|
|
|
|
|
if [ ! "${INST_ANDROID}" = "yes" ]; then
|
|
|
SYSTEM_MINSIZE=8
|
|
|
@@ -252,13 +255,16 @@ if [ ! "${INST_ANDROID}" = "yes" ]; then
|
|
|
USERDATA_SIZE=256
|
|
|
fi
|
|
|
if [ ! "${INST_OELEC}" = "yes" ] && [ ! "${INST_LINUX2}" = "yes" ]; then
|
|
|
+ # Partition 6 is reserved partition
|
|
|
OELEC_MINSIZE=8
|
|
|
OELEC_SIZE=256
|
|
|
else
|
|
|
if [ "${INST_OELEC}" = "yes" ]; then
|
|
|
+ # Partition 6 is oelec partition
|
|
|
OELEC_MINSIZE=256
|
|
|
OELEC_SIZE=512
|
|
|
elif [ "${INST_LINUX2}" = "yes" ]; then
|
|
|
+ # Partition 6 is Linux2
|
|
|
OELEC_MINSIZE=1563
|
|
|
OELEC_SIZE=1536
|
|
|
fi
|
|
|
@@ -280,11 +286,7 @@ fi
|
|
|
|
|
|
PARTSIZE_INC=128
|
|
|
export CARD_SIZE=8000
|
|
|
-export ONLY_ANDROID="no"
|
|
|
-export ONLY_LINUX="no"
|
|
|
-export MULTI_BOOT="yes"
|
|
|
export source_mount="/mnt"
|
|
|
-export TWO_CARDS="no"
|
|
|
|
|
|
if [ "${UPGRADE_ANDROID}" = "yes" ]; then
|
|
|
rm /mnt/upgrade.log > /dev/null 2>&1
|
|
|
@@ -296,20 +298,6 @@ else
|
|
|
#log_file="ls/dev/null"
|
|
|
fi
|
|
|
|
|
|
-#--------------------------------------------------------------------------------------------------------------------------------------
|
|
|
-if [ "${INST_LINUX}" = "yes" ] && [ "${INST_ANDROID}" != "yes" ] && [ "${INST_OELEC}" != "yes" ] && [ "${INST_LINUX2}" != "yes" ]; then
|
|
|
- ONLY_LINUX="yes"
|
|
|
- MULTI_BOOT="no"
|
|
|
-fi
|
|
|
-if [ "${INST_ANDROID}" = "yes" ] && [ "${INST_LINUX}" != "yes" ] && [ "${INST_OELEC}" != "yes" ]; then
|
|
|
- ONLY_ANDROID="yes"
|
|
|
- MULTI_BOOT="no"
|
|
|
-fi
|
|
|
-if [ "${CARD1}" != "" ] && [ "${CARD1}" != "" ]; then
|
|
|
- TWO_CARDS="yes"
|
|
|
-fi
|
|
|
-#-----------------------------------------------------------------------------------------------------
|
|
|
-
|
|
|
|
|
|
#---------------------------------------------------------------------------------
|
|
|
# Detect and set installation card size, leave 32M at end unused
|
|
|
@@ -319,7 +307,6 @@ set_cardsize() {
|
|
|
}
|
|
|
#---------------------------------------------------------------------------------
|
|
|
|
|
|
-
|
|
|
#--------------------------------------------------------------------------------------------------------
|
|
|
# Set linux or userdata partition size to fill card size
|
|
|
set_auto_partsize() {
|
|
|
@@ -343,9 +330,7 @@ set_auto_partsize() {
|
|
|
}
|
|
|
#--------------------------------------------------------------------------------------------------------
|
|
|
|
|
|
-
|
|
|
#---------------------------------------------------------------------------------------------------------------------------
|
|
|
-# shellcheck disable=SC2059
|
|
|
print_settings() {
|
|
|
set_auto_partsize
|
|
|
|
|
|
@@ -357,7 +342,7 @@ print_settings() {
|
|
|
else
|
|
|
printf "image"
|
|
|
fi
|
|
|
- if [ "${MULTI_BOOT}" = "yes" ]; then
|
|
|
+ if [ "${INST_LINUX}" = "yes" ] || [ "${INST_OELEC}" = "yes" ]; then
|
|
|
printf "\033[32m &\033[37m"
|
|
|
fi
|
|
|
fi
|
|
|
@@ -368,7 +353,7 @@ print_settings() {
|
|
|
else
|
|
|
printf "image"
|
|
|
fi
|
|
|
- if [ "${MULTI_BOOT}" = "yes" ] && [ "${INST_OELEC}" = "yes" ]; then
|
|
|
+ if [ "${INST_LINUX2}" = "yes" ] || [ "${INST_OELEC}" = "yes" ]; then
|
|
|
printf "\033[32m &\033[37m"
|
|
|
fi
|
|
|
|
|
|
@@ -379,7 +364,7 @@ print_settings() {
|
|
|
else
|
|
|
printf "image"
|
|
|
fi
|
|
|
- if [ "${MULTI_BOOT}" = "yes" ] && [ "${INST_OELEC}" = "yes" ]; then
|
|
|
+ if [ "${INST_OELEC}" = "yes" ]; then
|
|
|
printf "\033[32m &\033[37m"
|
|
|
fi
|
|
|
fi
|
|
|
@@ -393,91 +378,53 @@ print_settings() {
|
|
|
fi
|
|
|
fi
|
|
|
printf "\033[37m\n"
|
|
|
- printf " Install to: \033[36m${DEST_EMMC} Card (${DEST_CARD})\033[37m (${CARD_SIZE}M)\n"
|
|
|
- printf " Installation type: \033[36m"
|
|
|
- if [ "${ONLY_LINUX}" = "yes" ]; then
|
|
|
- printf "Linux"
|
|
|
- elif [ "${ONLY_ANDROID}" = "yes" ]; then
|
|
|
- printf "Android"
|
|
|
- else
|
|
|
- printf "Multi Boot"
|
|
|
- fi
|
|
|
- printf "\033[37m\n\n"
|
|
|
- printf " Card size: \033[36m${CARD_SIZE}M\033[37m\n"
|
|
|
- if [ "${ONLY_LINUX}" = "yes" ]; then
|
|
|
- printf " boot partition size: \033[36m${USERDATA_SIZE}M\033[37m\n"
|
|
|
- else
|
|
|
- printf " userdata partition size: \033[36m${USERDATA_SIZE}M\033[37m\n"
|
|
|
- fi
|
|
|
- [ "${ONLY_LINUX}" != "yes" ] && printf " system partition size: \033[36m${SYSTEM_SIZE}M\033[37m\n"
|
|
|
- [ "${ONLY_LINUX}" != "yes" ] && printf " data partition size: \033[36m${DATA_SIZE}M\033[37m\n"
|
|
|
- [ "${INST_ANDROID}" = "yes" ] && printf " cache partition size: \033[36m${CACHE_SIZE}M\033[37m\n"
|
|
|
- printf " ${_part6_dlabel} partition size: \033[36m${OELEC_SIZE}M\033[37m\n"
|
|
|
- if [ "${INST_LINUX}" = "yes" ]; then
|
|
|
- if [ "${INST_LINUX2}" = "yes" ]; then
|
|
|
- printf " linux 1&2 partition size: \033[36m${LINUX_SIZE}M\033[37m\n"
|
|
|
- else
|
|
|
- printf " linux partition size: \033[36m${LINUX_SIZE}M\033[37m\n"
|
|
|
- fi
|
|
|
- fi
|
|
|
- [ "${INST_LINUX}" = "yes" ] && printf " linux file system type: \033[36m${LINUX_FSTYPE}\033[37m\n"
|
|
|
+ printf " Install to: \033[36m%s Card (%s)\033[37m (%sM)\033[37m\n\n" "${DEST_EMMC}" "${DEST_CARD}" "${CARD_SIZE}"
|
|
|
+
|
|
|
+ printf " Card size: \033[36m%sM\033[37m\n" "${CARD_SIZE}"
|
|
|
+ printf " userdata partition size: \033[36m%sM\033[37m\n" "${USERDATA_SIZE}"
|
|
|
+ printf " system partition size: \033[36m%sM\033[37m\n" "${SYSTEM_SIZE}"
|
|
|
+ printf " data partition size: \033[36m%sM\033[37m\n" "${DATA_SIZE}"
|
|
|
+ printf " cache partition size: \033[36m%sM\033[37m\n" "${CACHE_SIZE}"
|
|
|
+ printf " %s partition size: \033[36m%sM\033[37m\n" "${_part6_dlabel}" "${OELEC_SIZE}"
|
|
|
+ printf " linux partition size: \033[36m%sM\033[37m\n" "${LINUX_SIZE}"
|
|
|
+
|
|
|
+ [ "${INST_LINUX}" = "yes" ] && printf " linux file system type: \033[36m%s\033[37m\n" "${LINUX_FSTYPE}"
|
|
|
printf "\033[36m\n"
|
|
|
|
|
|
- [ "${TWO_CARDS}" = "yes" ] && printf " \033[32m\033[1m1\033[22m Change installation \033[1mcard\033[22m\033[36m\n"
|
|
|
- if [ "${INST_LINUX}" = "yes" ]; then
|
|
|
- printf " \033[32m\033[1m2\033[22m Change \033[1m"
|
|
|
- if [ "${ONLY_LINUX}" = "yes" ]; then
|
|
|
- printf "boot"
|
|
|
- else
|
|
|
- printf "userdata"
|
|
|
- fi
|
|
|
- printf "\033[22m partition size\033[36m\n"
|
|
|
- fi
|
|
|
- [ "${INST_ANDROID}" = "yes" ] && printf " \033[32m\033[1m3\033[22m Change \033[1msystem\033[22m partition size\033[36m\n"
|
|
|
- [ "${INST_ANDROID}" = "yes" ] && printf " \033[32m\033[1m4\033[22m Change \033[1mdata\033[22m partition size\033[36m\n"
|
|
|
- [ "${INST_ANDROID}" = "yes" ] && printf " \033[32m\033[1m5\033[22m Change \033[1mcache\033[22m partition size\033[36m\n"
|
|
|
- if [ "${INST_OELEC}" = "yes" ] && [ "${MULTI_BOOT}" = "yes" ]; then
|
|
|
- printf " \033[32m\033[1m6\033[22m Change \033[1m${_part6_dlabel}\033[22m partition size\033[36m\n"
|
|
|
- fi
|
|
|
- if [ "${INST_LINUX}" = "yes" ]; then
|
|
|
- if [ "${INST_LINUX2}" = "yes" ]; then
|
|
|
- printf " \033[32m\033[1mL\033[22m Change \033[1mLinux 2\033[22m partition size\033[36m\n"
|
|
|
- fi
|
|
|
- printf "\n"
|
|
|
- printf " \033[32m\033[1mt\033[22m Change Linux \033[1mfile system type\033[22m\033[36m\n"
|
|
|
- fi
|
|
|
+ [ "${NUMCARDS}" = "2" ] && printf " \033[32m\033[1m1\033[22m Change installation \033[1mcard\033[22m\033[36m\n"
|
|
|
+ printf " \033[32m\033[1m2\033[22m Change \033[1muserdata\033[22m partition size\033[36m\n"
|
|
|
+ printf " \033[32m\033[1m3\033[22m Change \033[1msystem\033[22m partition size\033[36m\n"
|
|
|
+ printf " \033[32m\033[1m4\033[22m Change \033[1mdata\033[22m partition size\033[36m\n"
|
|
|
+ printf " \033[32m\033[1m5\033[22m Change \033[1mcache\033[22m partition size\033[36m\n"
|
|
|
+ printf " \033[32m\033[1m6\033[22m Change \033[1m%s\033[22m partition size\033[36m\n" "${_part6_dlabel}"
|
|
|
+ [ "${INST_LINUX}" = "yes" ] && printf " \033[32m\033[1mt\033[22m Change Linux \033[1mfile system type\033[22m\033[36m\n"
|
|
|
|
|
|
printf "\n \033[35m\033[1mI\033[22m Start installation\033[36m\n"
|
|
|
printf "\n \033[33m\033[1mE\033[22m EXIT\033[37m\n\n"
|
|
|
if [ "${LINUX_FSTYPE}" = "btrfs" ] && [ "${O_BOARD}" = "C2" ]; then
|
|
|
- printf "\033[32m\033[1m WARNING\033[22m: only install to btrfs if Linux install image is prepared for it\n"
|
|
|
- printf " if not shure, use ext4\033[37m\n"
|
|
|
+ printf "\033[32m\033[1m WARNING\033[22m: only install to btrfs if Linux installation image or backup\n"
|
|
|
+ printf " is prepared for it, if not shure, use ext4\033[37m\n"
|
|
|
fi
|
|
|
}
|
|
|
#---------------------------------------------------------------------------------------------------------------------------
|
|
|
|
|
|
#---- Select destination card -------------------------------------------------------------------------
|
|
|
-# shellcheck disable=SC2059
|
|
|
set_dest() {
|
|
|
printf " Press \033[35m+\033[37m key to change installation card, \033[35m9\033[37m to select\n\n"
|
|
|
|
|
|
_wait_delay=30
|
|
|
while [ $_wait_delay -gt 0 ]; do
|
|
|
- printf " Install to: \033[36m${DEST_EMMC} Card (${DEST_CARD})\033[37m \r"
|
|
|
+ printf " Install to: \033[36m%s Card (%s)\033[37m \r" "${DEST_EMMC}" "${DEST_CARD}"
|
|
|
if read -n 1 -t 1 -s A; then
|
|
|
_wait_delay=30
|
|
|
if [ "${A}" = "+" ]; then
|
|
|
if [ "${NUMCARDS}" = "2" ]; then
|
|
|
if [ "${DEST_CARD}" = "${CARD1}" ]; then
|
|
|
- if [ ! "${CARD2}" = "" ]; then
|
|
|
- DEST_CARD=${CARD2}
|
|
|
- DEST_EMMC=${CARD2_EMMC}
|
|
|
- fi
|
|
|
+ DEST_CARD=${CARD2}
|
|
|
+ DEST_EMMC=${CARD2_EMMC}
|
|
|
elif [ "${DEST_CARD}" = "${CARD2}" ]; then
|
|
|
- if [ ! "${CARD1}" = "" ]; then
|
|
|
- DEST_CARD=${CARD1}
|
|
|
- DEST_EMMC=${CARD1_EMMC}
|
|
|
- fi
|
|
|
+ DEST_CARD=${CARD1}
|
|
|
+ DEST_EMMC=${CARD1_EMMC}
|
|
|
fi
|
|
|
elif [ "${O_BOARD}" = "C2" ]; then
|
|
|
if [ "${DEST_EMMC}" = "SD" ]; then
|
|
|
@@ -498,15 +445,13 @@ set_dest() {
|
|
|
}
|
|
|
#-----------------------------------------------------------------------------
|
|
|
|
|
|
-
|
|
|
#---- Set Linux fs type -------------------------------------------------------------------------
|
|
|
-# shellcheck disable=SC2059
|
|
|
set_linfstype() {
|
|
|
printf " Press \033[35m+\033[37m key to change Linux filesystem type, \033[35m9\033[37m to select\n\n"
|
|
|
|
|
|
_wait_delay=30
|
|
|
while [ $_wait_delay -gt 0 ]; do
|
|
|
- printf " Linux fs type: \033[36m${LINUX_FSTYPE}\033[37m \r"
|
|
|
+ printf " Linux fs type: \033[36m%s\033[37m \r" "${LINUX_FSTYPE}"
|
|
|
if read -n 1 -t 1 -s A; then
|
|
|
_wait_delay=30
|
|
|
if [ "${A}" = "+" ]; then
|
|
|
@@ -526,19 +471,18 @@ set_linfstype() {
|
|
|
}
|
|
|
#-----------------------------------------------------------------------------
|
|
|
|
|
|
-
|
|
|
#----------------------------------------------------------------------------------------------------------------------------
|
|
|
-# shellcheck disable=SC2059
|
|
|
set_systemsize() {
|
|
|
printf " Press \033[35m+\033[37m|\033[35m-\033[37m key to change system partition size, \033[35m9\033[37m to select\n\n"
|
|
|
|
|
|
_wait_delay=30
|
|
|
while [ $_wait_delay -gt 0 ]; do
|
|
|
- printf " system partition size: \033[36m${SYSTEM_SIZE}M\033[37m \r"
|
|
|
+ printf " system partition size: \033[36m%sM\033[37m \r" "${SYSTEM_SIZE}"
|
|
|
if read -n 1 -t 1 -s A; then
|
|
|
_wait_delay=30
|
|
|
if [ "${A}" = "+" ]; then
|
|
|
let SYSTEM_SIZE=SYSTEM_SIZE+PARTSIZE_INC
|
|
|
+ [ ${SYSTEM_SIZE} -eq 136 ] && SYSTEM_SIZE=$PARTSIZE_INC
|
|
|
set_auto_partsize
|
|
|
if [ $? -ne 0 ]; then
|
|
|
let SYSTEM_SIZE=SYSTEM_SIZE-PARTSIZE_INC
|
|
|
@@ -559,19 +503,18 @@ set_systemsize() {
|
|
|
}
|
|
|
#----------------------------------------------------------------------------------------------------------------------------
|
|
|
|
|
|
-
|
|
|
#--------------------------------------------------------------------------------------------------------------------------
|
|
|
-# shellcheck disable=SC2059
|
|
|
set_datasize() {
|
|
|
printf " Press \033[35m+\033[37m|\033[35m-\033[37m key to change data partition size, \033[35m9\033[37m to select\n\n"
|
|
|
|
|
|
_wait_delay=30
|
|
|
while [ $_wait_delay -gt 0 ]; do
|
|
|
- printf " data partition size: \033[36m${DATA_SIZE}M\033[37m \r"
|
|
|
+ printf " data partition size: \033[36m%sM\033[37m \r" "${DATA_SIZE}"
|
|
|
if read -n 1 -t 1 -s A; then
|
|
|
_wait_delay=30
|
|
|
if [ "${A}" = "+" ]; then
|
|
|
let DATA_SIZE=DATA_SIZE+PARTSIZE_INC
|
|
|
+ [ ${DATA_SIZE} -eq 136 ] && DATA_SIZE=$PARTSIZE_INC
|
|
|
set_auto_partsize
|
|
|
if [ $? -ne 0 ]; then
|
|
|
let DATA_SIZE=DATA_SIZE-PARTSIZE_INC
|
|
|
@@ -592,30 +535,18 @@ set_datasize() {
|
|
|
}
|
|
|
#--------------------------------------------------------------------------------------------------------------------------
|
|
|
|
|
|
-
|
|
|
#------------------------------------------------------------------------------------------------------------------------------
|
|
|
-# shellcheck disable=SC2059
|
|
|
set_userdatasize() {
|
|
|
- printf " Press \033[35m+\033[37m|\033[35m-\033[37m key to change "
|
|
|
- if [ "${ONLY_LINUX}" = "yes" ]; then
|
|
|
- printf "boot"
|
|
|
- else
|
|
|
- printf "userdata"
|
|
|
- fi
|
|
|
- printf " partition size, \033[35m9\033[37m to select\n\n"
|
|
|
+ printf " Press \033[35m+\033[37m|\033[35m-\033[37m key to change userdata partition size, \033[35m9\033[37m to select\n\n"
|
|
|
|
|
|
_wait_delay=30
|
|
|
while [ $_wait_delay -gt 0 ]; do
|
|
|
- if [ "${ONLY_LINUX}" = "yes" ]; then
|
|
|
- printf " boot"
|
|
|
- else
|
|
|
- printf " userdata"
|
|
|
- fi
|
|
|
- printf " partition size: \033[36m${USERDATA_SIZE}M\033[37m \r"
|
|
|
+ printf " userdata partition size: \033[36m%sM\033[37m \r" "${USERDATA_SIZE}"
|
|
|
if read -n 1 -t 1 -s A; then
|
|
|
_wait_delay=30
|
|
|
if [ "${A}" = "+" ]; then
|
|
|
let USERDATA_SIZE=USERDATA_SIZE+PARTSIZE_INC
|
|
|
+ [ ${USERDATA_SIZE} -eq 136 ] && USERDATA_SIZE=$PARTSIZE_INC
|
|
|
set_auto_partsize
|
|
|
if [ $? -ne 0 ]; then
|
|
|
let USERDATA_SIZE=USERDATA_SIZE-PARTSIZE_INC
|
|
|
@@ -636,19 +567,18 @@ set_userdatasize() {
|
|
|
}
|
|
|
#------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
|
|
-
|
|
|
#------------------------------------------------------------------------------------------------------------------------------
|
|
|
-# shellcheck disable=SC2059
|
|
|
set_cachesize() {
|
|
|
printf " Press \033[35m+\033[37m|\033[35m-\033[37m key to change cache partition size, \033[35m9\033[37m to select\n\n"
|
|
|
|
|
|
_wait_delay=30
|
|
|
while [ $_wait_delay -gt 0 ]; do
|
|
|
- printf " cache partition size: \033[36m${CACHE_SIZE}M\033[37m \r"
|
|
|
+ printf " cache partition size: \033[36m%sM\033[37m \r" "${CACHE_SIZE}"
|
|
|
if read -n 1 -t 1 -s A; then
|
|
|
_wait_delay=30
|
|
|
if [ "${A}" = "+" ]; then
|
|
|
let CACHE_SIZE=CACHE_SIZE+PARTSIZE_INC
|
|
|
+ [ ${CACHE_SIZE} -eq 136 ] && CACHE_SIZE=$PARTSIZE_INC
|
|
|
set_auto_partsize
|
|
|
if [ $? -ne 0 ]; then
|
|
|
let CACHE_SIZE=CACHE_SIZE-PARTSIZE_INC
|
|
|
@@ -669,15 +599,13 @@ set_cachesize() {
|
|
|
}
|
|
|
#------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
|
|
-
|
|
|
#------------------------------------------------------------------------------------------------------------------------------
|
|
|
-# shellcheck disable=SC2059
|
|
|
set_oelecsize() {
|
|
|
- printf " Press \033[35m+\033[37m|\033[35m-\033[37m key to change ${_part6_dlabel} partition size, \033[35m9\033[37m to select\n\n"
|
|
|
+ printf " Press \033[35m+\033[37m|\033[35m-\033[37m key to change %s partition size, \033[35m9\033[37m to select\n\n" "${_part6_dlabel}"
|
|
|
|
|
|
_wait_delay=30
|
|
|
while [ $_wait_delay -gt 0 ]; do
|
|
|
- printf " ${_part6_dlabel} partition size: \033[36m${OELEC_SIZE}M\033[37m \r"
|
|
|
+ printf " ${_part6_dlabel} partition size: \033[36m%sM\033[37m \r" "${OELEC_SIZE}"
|
|
|
if read -n 1 -t 1 -s A; then
|
|
|
_wait_delay=30
|
|
|
if [ "${A}" = "+" ]; then
|
|
|
@@ -703,7 +631,6 @@ set_oelecsize() {
|
|
|
}
|
|
|
#------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
|
|
-
|
|
|
#------------------------------------------------------------------------------------------------
|
|
|
create_partitions_full() {
|
|
|
# == MULTI BOOT PARTITION LAYOUT ===
|
|
|
@@ -1036,6 +963,7 @@ install_boot_xu() {
|
|
|
install_multi_sel() {
|
|
|
echo "==== INSTALL MULTIBOOT SUPPORT ====" >> ${log_file}
|
|
|
|
|
|
+ umount /mnt2 >> ${log_file} 2>&1
|
|
|
# Update userdata partition for multiboot
|
|
|
/bin/mountx -t vfat ${DEST_CARD}p1 /mnt2 >> ${log_file} 2>&1
|
|
|
if [ $? -ne 0 ]; then
|
|
|
@@ -1342,6 +1270,8 @@ install_android() {
|
|
|
mkdir /mnt1 >> ${log_file} 2>&1
|
|
|
mkdir /mnt2 >> ${log_file} 2>&1
|
|
|
|
|
|
+ umount /mnt2 >> ${log_file} 2>&1
|
|
|
+ umount /mnt1 >> ${log_file} 2>&1
|
|
|
# === Copy system partition ===
|
|
|
printf " Installing \033[36msystem\033[37m ... "
|
|
|
# mount source
|
|
|
@@ -1381,9 +1311,7 @@ install_android() {
|
|
|
if [ -f /mnt2/${ODROID_FSTAB} ]; then
|
|
|
if [ "${O_BOARD}" = "C2" ]; then
|
|
|
# Change data partition number (4 -> 5)
|
|
|
- cat /mnt2/${ODROID_FSTAB} | sed "s/\/dev\/block\/mmcblk0p4/\/dev\/block\/mmcblk0p5/g" > _fstab_
|
|
|
- cp _fstab_ /mnt2/${ODROID_FSTAB}
|
|
|
- rm _fstab_
|
|
|
+ sed -i "s/\/dev\/block\/mmcblk0p4/\/dev\/block\/mmcblk0p5/g" /mnt2/${ODROID_FSTAB}
|
|
|
else
|
|
|
cp /mnt2/${ODROID_FSTAB} /mnt2/${ODROID_FSTAB}.original
|
|
|
cp /mnt2/${ODROID_FSTAB}.sdboot /mnt2/${ODROID_FSTAB}.sdboot.original
|
|
|
@@ -1597,26 +1525,24 @@ get_lin_partstruct() {
|
|
|
#----------------------------------------------------------------------------------------------------------------------------
|
|
|
prepare_linux_boot() {
|
|
|
echo "==== PREPARE LINUX BOOT ====" >> ${log_file}
|
|
|
- # Prepare for multi boot
|
|
|
- if [ -d /mnt2/etc ]; then
|
|
|
+ # Prepare for multi boot
|
|
|
+ if [ -d /mnt2/etc ]; then
|
|
|
if [ "${LINUX_FSTYPE}" = "btrfs" ] ; then
|
|
|
- echo "LABEL=${label_pref}linux / btrfs noatime,nodiratime,compress=lzo 0 1" > /mnt2/etc/fstab
|
|
|
+ echo "LABEL=${label_pref}linux / btrfs noatime,nodiratime,compress=lzo 0 1" > /mnt2/etc/fstab
|
|
|
else
|
|
|
- echo "LABEL=${label_pref}linux / ext4 errors=remount-ro,noatime,nodiratime 0 1" > /mnt2/etc/fstab
|
|
|
+ echo "LABEL=${label_pref}linux / ext4 errors=remount-ro,noatime,nodiratime 0 1" > /mnt2/etc/fstab
|
|
|
fi
|
|
|
- echo "LABEL=${label_pref}userdata /media/boot vfat defaults 0 1" >> /mnt2/etc/fstab
|
|
|
+ echo "LABEL=${label_pref}userdata /media/boot vfat rw,user,sync,exec,dev,suid,uid=1000,gid=1000,dmask=000,fmask=111,iocharset=utf8 0 0" >> /mnt2/etc/fstab
|
|
|
|
|
|
if [ -f /mnt2/etc/rc.local ]; then
|
|
|
- cat /mnt2/etc/rc.local | sed "s/^exit 0//g" > _rcloc_
|
|
|
- if [ -f /mnt2/.first_boot ]; then
|
|
|
- echo "if [ -f /.first_boot ]; then" >> _rcloc_
|
|
|
- echo " rm -f /.first_boot" >> _rcloc_
|
|
|
- echo " [ ! -f /etc/ssh/ssh_host_rsa_key ] && dpkg-reconfigure openssh-server" >> _rcloc_
|
|
|
- echo "fi" >> _rcloc_
|
|
|
- fi
|
|
|
- echo "exit 0" >> _rcloc_
|
|
|
- cp _rcloc_ /mnt2/etc/rc.local
|
|
|
- rm _rcloc_
|
|
|
+ echo "#!/bin/sh -e" > /mnt2/etc/rc.local
|
|
|
+ echo "# This script is executed at the end of each multiuser runlevel." >> /mnt2/etc/rc.local
|
|
|
+ echo "# Make sure that the script will 'exit 0' on success or any other value on error." >> /mnt2/etc/rc.local
|
|
|
+ echo "if [ -f /.first_boot ]; then" >> /mnt2/etc/rc.local
|
|
|
+ echo " rm -f /.first_boot" >> /mnt2/etc/rc.local
|
|
|
+ echo " [ ! -f /etc/ssh/ssh_host_rsa_key ] && dpkg-reconfigure openssh-server" >> /mnt2/etc/rc.local
|
|
|
+ echo "fi" >> /mnt2/etc/rc.local
|
|
|
+ echo "exit 0" >> /mnt2/etc/rc.local
|
|
|
chmod 0755 /mnt2/etc/rc.local
|
|
|
if [ -f /mnt2/aafirstboot ]; then
|
|
|
rm -f /mnt2/aafirstboot
|
|
|
@@ -1631,14 +1557,15 @@ prepare_linux_boot() {
|
|
|
chown 1000:1000 /mnt2/media/odroid >> ${log_file} 2>&1
|
|
|
chmod 0666 /mnt2/media/odroid >> ${log_file} 2>&1
|
|
|
fi
|
|
|
-
|
|
|
+ mkdir /mnt2/media/boot >> ${log_file} 2>&1
|
|
|
+ chown 1000:1000 /mnt2/media/boot >> ${log_file} 2>&1
|
|
|
+ chmod 0666 /mnt2/media/boot >> ${log_file} 2>&1
|
|
|
return 0
|
|
|
}
|
|
|
#----------------------------------------------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
#----------------------------------------------------------------------------------------------------------
|
|
|
-# shellcheck disable=SC2050
|
|
|
install_linux() {
|
|
|
echo "==== INSTALL LINUX ====" >> ${log_file}
|
|
|
|
|
|
@@ -1666,6 +1593,8 @@ install_linux() {
|
|
|
|
|
|
mkdir /mnt1 >> ${log_file} 2>&1
|
|
|
mkdir /mnt2 >> ${log_file} 2>&1
|
|
|
+ umount /mnt2 >> ${log_file} 2>&1
|
|
|
+ umount /mnt1 >> ${log_file} 2>&1
|
|
|
|
|
|
local _linpart="p7"
|
|
|
local _linsufix=""
|
|
|
@@ -1753,13 +1682,10 @@ install_linux() {
|
|
|
if [ -f ${boot_src}/${ODROID_DTB} ] && [ -f ${boot_src}/${ODROID_IMAGE} ] && [ -f ${boot_src}/uInitrd ]; then
|
|
|
mkdir /mnt2/multiboot >> ${log_file} 2>&1
|
|
|
cp /multi/boot.ini.linux${_linsufix} /mnt2/multiboot/boot.ini.linux${_linsufix}
|
|
|
- cat /mnt2/multiboot/boot.ini.linux${_linsufix} | sed "s/root=LABEL=XXlinux/root=LABEL=${label_pref}linux/g" > _bini_
|
|
|
- cp _bini_ /mnt2/multiboot/boot.ini.linux${_linsufix}
|
|
|
+ sed -i "s/root=LABEL=XXlinux/root=LABEL=${label_pref}linux/g" /mnt2/multiboot/boot.ini.linux${_linsufix}
|
|
|
cp ${boot_src}/${ODROID_DTB} /mnt2/multiboot/${ODROID_DTB}.linux${_linsufix} >> ${log_file} 2>&1
|
|
|
cp ${boot_src}/${ODROID_IMAGE} /mnt2/multiboot/${ODROID_IMAGE}.linux${_linsufix} >> ${log_file} 2>&1
|
|
|
cp ${boot_src}/uInitrd /mnt2/multiboot/uInitrd.linux${_linsufix} >> ${log_file} 2>&1
|
|
|
- rm _bini_ >> ${log_file} 2>&1
|
|
|
-
|
|
|
else
|
|
|
echo "ERROR: not all Linux boot files found! "
|
|
|
umount /mnt1 >> ${log_file} 2>&1
|
|
|
@@ -1776,13 +1702,17 @@ install_linux() {
|
|
|
|
|
|
|
|
|
#------------------------------------------------------------------------------------------------------------------------------------------------------
|
|
|
-# shellcheck disable=SC2059
|
|
|
install_oelec() {
|
|
|
echo "==== INSTALL OpenElec ====" >> ${log_file}
|
|
|
printf "\n \033[33mInstalling \033[1mOpenELEC\033[22m\033[37m\n"
|
|
|
|
|
|
_oelec_source="/run/oelec"
|
|
|
|
|
|
+ mkdir /mnt1 >> ${log_file} 2>&1
|
|
|
+ mkdir /mnt2 >> ${log_file} 2>&1
|
|
|
+ umount /mnt2 >> ${log_file} 2>&1
|
|
|
+ umount /mnt1 >> ${log_file} 2>&1
|
|
|
+
|
|
|
if [ "${O_FROMDIR}" = "yes" ]; then
|
|
|
_name="${source_mount}/${BKP_PREFIX}_backup/oelec"
|
|
|
|
|
|
@@ -1810,17 +1740,23 @@ install_oelec() {
|
|
|
else
|
|
|
_ramfs_free=$(df | grep tmpfs | awk '{print $4}')
|
|
|
_ramfs_free=$(( $_ramfs_free / 1024 - 100 ))
|
|
|
- _tarsize_=$(/bin/tar -vtf ${source_mount}/oelec.tar |awk '{SUM += $3} END {print SUM}')
|
|
|
+ _tarsize_=$(/bin/tar -vtf ${source_mount}/oelec.tar | awk '{SUM += $3} END {print SUM}')
|
|
|
_tarsize_=$(( $_tarsize_ / 1024 / 1024 ))
|
|
|
+ if [ $? -ne 0 ]; then
|
|
|
+ echo "ERROR testing archive."
|
|
|
+ cd /
|
|
|
+ rm -rf ${_oelec_source:?}/* >> ${log_file} 2>&1
|
|
|
+ return 1
|
|
|
+ fi
|
|
|
|
|
|
printf " Unpacking archive "
|
|
|
if [ $_tarsize_ -lt $_ramfs_free ]; then
|
|
|
mkdir /run/oelec >> ${log_file} 2>&1
|
|
|
- printf "to RAMfs (${_tarsize_}M) ... "
|
|
|
+ printf "to RAMfs (%sM) ... " "${_tarsize_}"
|
|
|
else
|
|
|
mkdir ${source_mount}/tmp_oelec >> ${log_file} 2>&1
|
|
|
_oelec_source="${source_mount}/tmp_oelec"
|
|
|
- printf "to source drive (${_tarsize_}M) ... "
|
|
|
+ printf "to source drive (%sM) ... " "${_tarsize_}"
|
|
|
fi
|
|
|
rm -rf ${_oelec_source:?}/* >> ${log_file} 2>&1
|
|
|
|
|
|
@@ -1882,9 +1818,7 @@ install_oelec() {
|
|
|
cd /
|
|
|
|
|
|
cp /multi/boot.ini.oelec /mnt2/multiboot
|
|
|
- cat /mnt2/multiboot/boot.ini.oelec | sed "s/boot=LABEL=userdata disk=LABEL=oelec/boot=LABEL=${label_pref}userdata disk=LABEL=${label_pref}${_part6_label}/g" > _bsel_
|
|
|
- cp _bsel_ /mnt2/multiboot/boot.ini.oelec
|
|
|
- rm _bsel_
|
|
|
+ sed -i "s/boot=LABEL=userdata disk=LABEL=oelec/boot=LABEL=${label_pref}userdata disk=LABEL=${label_pref}${_part6_label}/g" /mnt2/multiboot/boot.ini.oelec
|
|
|
sync
|
|
|
|
|
|
umount /mnt2 >> ${log_file} 2>&1
|
|
|
@@ -1899,10 +1833,8 @@ install_oelec() {
|
|
|
#-----------------------------------------------------------------------------------------------------------------
|
|
|
check_inst() {
|
|
|
# INSTALLATION DRIVE IS MOUNTED ON /MNT
|
|
|
- if [ "${INST_ANDROID}" != "yes" ] && [ "${INST_LINUX}" != "yes" ]; then
|
|
|
- printf " \033[33m\033[1mNo installation file found!\033[22m\033[37m\n"
|
|
|
- printf " \033[33m\033[1mTo install from image\033[22m\033[37m\n"
|
|
|
- printf " \033[33m\033[1m\"update.zip\" and/or \"linux.img\" must be on source drive.\033[22m\033[37m\n"
|
|
|
+ if [ "${INST_ANDROID}" != "yes" ] && [ "${INST_LINUX}" != "yes" ] && [ "${INST_OELEC}" != "yes" ]; then
|
|
|
+ printf " \033[33m\033[1mNOTHING TO INSTALL !\033[22m\033[37m\n"
|
|
|
printf " \033[33m\033[1mInstallation aborted.\033[22m\033[37m\n"
|
|
|
umount ${source_mount} > /dev/null 2>&1
|
|
|
exit_script
|
|
|
@@ -2016,14 +1948,6 @@ if [ "${INST_ANDROID}" = "yes" ]; then
|
|
|
if [ $? -ne 0 ]; then
|
|
|
echo " ANDROID won't be installed!"
|
|
|
INST_ANDROID="no"
|
|
|
- if [ "${INST_LINUX}" = "yes" ] && [ "${INST_ANDROID}" != "yes" ] && [ "${INST_OELEC}" != "yes" ] && [ "${INST_LINUX2}" != "yes" ]; then
|
|
|
- ONLY_LINUX="yes"
|
|
|
- MULTI_BOOT="no"
|
|
|
- fi
|
|
|
- if [ "${INST_ANDROID}" = "yes" ] && [ "${INST_LINUX}" != "yes" ] && [ "${INST_OELEC}" != "yes" ]; then
|
|
|
- ONLY_ANDROID="yes"
|
|
|
- MULTI_BOOT="no"
|
|
|
- fi
|
|
|
sleep 1
|
|
|
fi
|
|
|
else
|
|
|
@@ -2033,14 +1957,6 @@ if [ "${INST_ANDROID}" = "yes" ]; then
|
|
|
if [ $? -ne 0 ]; then
|
|
|
echo " ANDROID won't be installed!"
|
|
|
INST_ANDROID="no"
|
|
|
- if [ "${INST_LINUX}" = "yes" ] && [ "${INST_ANDROID}" != "yes" ] && [ "${INST_OELEC}" != "yes" ] && [ "${INST_LINUX2}" != "yes" ]; then
|
|
|
- ONLY_LINUX="yes"
|
|
|
- MULTI_BOOT="no"
|
|
|
- fi
|
|
|
- if [ "${INST_ANDROID}" = "yes" ] && [ "${INST_LINUX}" != "yes" ] && [ "${INST_OELEC}" != "yes" ]; then
|
|
|
- ONLY_ANDROID="yes"
|
|
|
- MULTI_BOOT="no"
|
|
|
- fi
|
|
|
sleep 1
|
|
|
fi
|
|
|
rm -rf rm ${source_mount}/android/* >> ${log_file} 2>&1
|
|
|
@@ -2057,38 +1973,37 @@ print_settings
|
|
|
#---- Main menu -------------------
|
|
|
_inst_delay=${INST_DELAY}
|
|
|
|
|
|
-# shellcheck disable=SC2059
|
|
|
while [ $_inst_delay -gt 0 ]; do
|
|
|
- [ $INST_DELAY -lt 60 ] && printf " Auto start install in $_inst_delay sec \r"
|
|
|
+ [ $INST_DELAY -lt 60 ] && printf " Auto start install in %s sec \r" "$_inst_delay"
|
|
|
A="z"
|
|
|
if read -n 1 -t 1 -s A; then
|
|
|
_inst_delay=${INST_DELAY}
|
|
|
- if [ "${A}" = "1" ] && [ "${TWO_CARDS}" = "yes" ]; then
|
|
|
+ if [ "${A}" = "1" ] && [ "${NUMCARDS}" = "2" ]; then
|
|
|
print_header
|
|
|
set_dest
|
|
|
print_header
|
|
|
print_settings
|
|
|
- elif [ "${A}" = "2" ] && [ "${INST_LINUX}" = "yes" ]; then
|
|
|
+ elif [ "${A}" = "2" ]; then
|
|
|
print_header
|
|
|
set_userdatasize
|
|
|
print_header
|
|
|
print_settings
|
|
|
- elif [ "${A}" = "3" ] && [ "${INST_ANDROID}" = "yes" ]; then
|
|
|
+ elif [ "${A}" = "3" ]; then
|
|
|
print_header
|
|
|
set_systemsize
|
|
|
print_header
|
|
|
print_settings
|
|
|
- elif [ "${A}" = "4" ] && [ "${INST_ANDROID}" = "yes" ]; then
|
|
|
+ elif [ "${A}" = "4" ]; then
|
|
|
print_header
|
|
|
set_datasize
|
|
|
print_header
|
|
|
print_settings
|
|
|
- elif [ "${A}" = "5" ] && [ "${INST_ANDROID}" = "yes" ]; then
|
|
|
+ elif [ "${A}" = "5" ]; then
|
|
|
print_header
|
|
|
set_cachesize
|
|
|
print_header
|
|
|
print_settings
|
|
|
- elif [ "${A}" = "6" ] && [ "${MULTI_BOOT}" = "yes" ]; then
|
|
|
+ elif [ "${A}" = "6" ]; then
|
|
|
print_header
|
|
|
set_oelecsize
|
|
|
print_header
|
|
|
@@ -2102,7 +2017,7 @@ while [ $_inst_delay -gt 0 ]; do
|
|
|
echo ""
|
|
|
_reboot_delay=10
|
|
|
while [ $_reboot_delay -gt 0 ]; do
|
|
|
- printf " \033[33m\033[1mEXIT in $_reboot_delay sec, press \033[22ma\033[1m to abort, \033[22me\033[1m to exit \033[22m\033[37m\r"
|
|
|
+ printf " \033[33m\033[1mEXIT in %s sec, press \033[22ma\033[1m to abort, \033[22me\033[1m to exit \033[22m\033[37m\r" "$_reboot_delay"
|
|
|
if read -n 1 -t 1 -s B; then
|
|
|
_reboot_delay=10
|
|
|
if [ "${B}" = "a" ] || [ "${B}" = "A" ]; then
|
|
|
@@ -2126,7 +2041,7 @@ while [ $_inst_delay -gt 0 ]; do
|
|
|
echo ""
|
|
|
_reboot_delay=15
|
|
|
while [ $_reboot_delay -gt 0 ]; do
|
|
|
- printf " \033[31m\033[1mWARNING: !! ALL DATA ON ${DEST_EMMC} CARD WILL BE ERASED !!, PRESS Y TO CONTINUE\033[22m\033[37m\r"
|
|
|
+ printf " \033[31m\033[1mWARNING: !! ALL DATA ON %s CARD WILL BE ERASED !!, PRESS Y TO CONTINUE\033[22m\033[37m\r" "${DEST_EMMC}"
|
|
|
B="Z"
|
|
|
if read -n 1 -t 1 -s B; then
|
|
|
break
|
|
|
@@ -2173,7 +2088,6 @@ prepare_card
|
|
|
if [ $? -ne 0 ]; then
|
|
|
printf " \033[35mERROR PREPARING SD/EMMC CARD!\033[37m\n"
|
|
|
else
|
|
|
- # shellcheck disable=SC2059
|
|
|
# install bootloader
|
|
|
if [ "${O_BOARD}" = "C2" ]; then
|
|
|
install_boot_c2
|