├── LICENSE ├── README.md ├── Lakka ├── README.md ├── installLakka └── berryboot-init ├── LibreELEC ├── README.md ├── installLibreELEC └── berryboot-init └── Volumio2 ├── README.md ├── installVolumio2 └── berryboot-init /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 macmpi 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # berryboot integration scripts 2 | Repo for (hopefully) usefull [berryboot](http://www.berryterminal.com/doku.php/berryboot) integration scripts for few popular distributions 3 | 4 | For each supported Distibution, a 1-line shell command is provided to run the installer which downloads a genuine image, patches-it, and then installs it for use inside berryboot. 5 | 6 | Such patched image is then capable of supporting all Distribution features by itself, including auto-updates, resets, etc... 7 | 8 | Therefore, the 1-line install command is only needed (once) for initial image creation: such installed image is then totally "autonomous", as would be a regular native Distribution install. 9 | 10 | 11 | 12 | 13 | #### Prerequisite(s): 14 | - *the obvious:* install Berryboot on a media, and do initial setup as per [this](http://www.berryterminal.com/doku.php/berryboot) (screen & keyboard strongly advised). 15 | 16 | - **either** (preferred) install Raspbian image (lite is fine) under berryboot and open shell there, **or** plug your configured berryboot media into any Debian-based Linux machine under shell (Ubuntu & derivatives, Mint, Pixel, Debian, etc...) 17 | -------------------------------------------------------------------------------- /Lakka/README.md: -------------------------------------------------------------------------------- 1 | # Scripts for Lakka 2 | 3 | This integration supports all [Lakka](http://www.lakka.tv/) (Libretro-RetroArch) native functions, including software updates, etc... 4 | 5 | 6 | Short tip: from any Debian-based distribution (Raspbian under berryboot advised), run the following 1-line command: 7 | ``` 8 | curl -Ls --output installLakka https://bit.ly/InstLakka; chmod u+x installLakka; ./installLakka 9 | ``` 10 | and follow onscreen instructions to install a patched Lakka image on your berryboot media. 11 | 12 | That patched image will then natively support all features, as would the standalone distribution. 13 | 14 | 15 | 16 | #### Prerequisite(s): 17 | - *the obvious:* install Berryboot on a media, and do initial setup as per [this](http://www.berryterminal.com/doku.php/berryboot) (screen & keyboard strongly advised). 18 | 19 | - **either** (preferred) install Raspbian image (lite is fine) under berryboot and open shell there, **or** plug your configured berryboot media into any Debian-based Linux machine under shell (Ubuntu & derivatives, Mint, Pixel, Debian, etc...) 20 | 21 | 22 | ### supported features: 23 | - ~~Software update through Lakka UI~~ (note: updated image will automatically be patched with latest patch version available) will work as soon as a [longstanding Lakka/RetroArch bug](https://github.com/libretro/Lakka-LibreELEC/issues/281) is fixed... 24 | - patch log available in system journal 25 | 26 | 27 | 28 | ### changelog: 29 | 1.6: (March 29th 2020) 30 | - fix UUID extraction 31 | 32 | 1.5: (September 4th 2019) 33 | - supports berryboot 20190612 & later 34 | 35 | 1.2: (December 31st 2018) 36 | - bootdev= parameter in cmdline.txt not mandatory anymore 37 | 38 | 1.1: (October 28th 2018) 39 | - change redirector 40 | 41 | 1.0: (October 31st 2017) 42 | - initial version 43 | -------------------------------------------------------------------------------- /LibreELEC/README.md: -------------------------------------------------------------------------------- 1 | # Scripts for LibreELEC 2 | 3 | This integration supports all [LibreELEC](https://libreelec.tv/) native functions, including software updates, reset (soft/hard), backup restore, etc... 4 | 5 | 6 | Short tip: from any Debian-based distribution (Raspbian under berryboot advised), run the following 1-line command: 7 | ``` 8 | curl -Ls --output installLibreELEC https://bit.ly/InstLibreELEC; chmod u+x installLibreELEC; ./installLibreELEC 9 | ``` 10 | and follow onscreen instructions to install a patched LibreELEC image on your berryboot media. 11 | 12 | That patched image will then natively support all features, as would the standalone distribution. 13 | 14 | 15 | 16 | #### Prerequisite(s): 17 | - *the obvious:* install Berryboot on a media, and do initial setup as per [this](http://www.berryterminal.com/doku.php/berryboot) (screen & keyboard strongly advised). 18 | 19 | - **either** (preferred) install Raspbian image (lite is fine) under berryboot and open shell there, **or** plug your configured berryboot media into any Debian-based Linux machine under shell (Ubuntu & derivatives, Mint, Pixel, Debian, etc...) 20 | 21 | 22 | ### supported features: 23 | - Software update through LibreELEC UI: manual & auto modes (note: updated image will automatically be patched with latest patch version available) 24 | - Soft / Hard reset through LibreELEC UI 25 | - Backup restore through LibreELEC UI 26 | - patch log available in system journal 27 | 28 | 29 | 30 | ### changelog: 31 | 1.6: (March 29th 2020) 32 | - fix UUID extraction 33 | 34 | 1.5: (September 4th 2019) 35 | - supports berryboot 20190612 & later 36 | 37 | 1.4: (December 31st 2018) 38 | - bootdev= parameter in cmdline.txt not mandatory anymore 39 | 40 | 1.3: (October 28th 2018) 41 | - change redirector 42 | 43 | 1.2: (August 12th 2018) 44 | - support for Milhouse [custom beta builds install](https://forum.kodi.tv/showthread.php?tid=298461) 45 | 46 | 1.1: (October 29th 2017) 47 | - support all update files 48 | 49 | 1.0: (October 22nd 2017) 50 | - initial version 51 | -------------------------------------------------------------------------------- /Volumio2/README.md: -------------------------------------------------------------------------------- 1 | # Scripts for Volumio 2 2 | 3 | This integration supports all [Volumio2](https://volumio.org/) native functions, including software updates, User-data / Factory reset, etc... 4 | 5 | 6 | You may refer [here](https://volumio.org/forum/multiboot-volumio2-with-kodi-under-berryboot-t6818.html#p33742) for detailed information and install procedure. 7 | 8 | Short tip: from any Debian-based distribution (Raspbian under berryboot advised), run the following 1-line command: 9 | ``` 10 | curl -Ls --output installVolumio2 https://bit.ly/InstVolumio2; chmod u+x installVolumio2; ./installVolumio2 11 | ``` 12 | and follow onscreen instructions to install a patched Volumio2 image on your berryboot media. 13 | 14 | That patched image will then natively support all features, as would the standalone distribution. 15 | 16 | 17 | 18 | #### Prerequisite(s): 19 | - *the obvious:* install Berryboot on a media, and do initial setup as per [this](http://www.berryterminal.com/doku.php/berryboot) (screen & keyboard strongly advised). 20 | 21 | - **either** (preferred) install Raspbian image (lite is fine) under berryboot and open shell there, **or** plug your configured berryboot media into any Debian-based Linux machine under shell (Ubuntu & derivatives, Mint, Pixel, Debian, etc...) 22 | 23 | 24 | 25 | ### supported features: 26 | - Software update through Volumio2 UI (note: updated image will automatically be patched with latest patch version available) 27 | - User Data / Factory reset through Volumio2 UI. 28 | - Swap on lower memory devices (note: may be disabled by adding /noswap file from Volumio2 shell) 29 | - patch log available in system journal. 30 | - `installVolumio2` script is available in volumio user home directory for installing more images if needed. 31 | 32 | 33 | 34 | ### changelog: 35 | 1.6: (March 19th 2020) 36 | - fix UUID extraction 37 | 38 | 1.5: (September 4th 2019) 39 | - supports berryboot 20190612 & later 40 | 41 | 1.3: (December 31st 2018) 42 | - bootdev= parameter in cmdline.txt not mandatory anymore 43 | 44 | 1.2: (October 28th 2018) 45 | - change redirector 46 | 47 | 1.1: (October 28th 2017) 48 | - improve `/boot` & `/berryboot` mounts scheduling and `dynamicswap.service` dependency 49 | - clean-up MrEngman drivers .conf 50 | 51 | 1.0: (October 19th 2017) 52 | - initial version 53 | -------------------------------------------------------------------------------- /Volumio2/installVolumio2: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Source & license at https://github.com/macmpi/berryboot-scripts 4 | # Feel free to report any issue or comment there. 5 | 6 | INSTVOLVERSION="1.2" 7 | 8 | BBINITURL="https://bit.ly/BBInitVolumio2" 9 | INSTV2URL="https://bit.ly/InstVolumio2" 10 | 11 | 12 | MOUNTDIR=${1:-""} 13 | 14 | UPDATE_SELF=${UPDATE_SELF:-1} 15 | WORK_PATH="$(pwd)" 16 | 17 | function update_self() { # function mostly borrowed from MrEngman install-wifi: thanks! 18 | echo " *** Performing self-update" 19 | _tempFileName="$0.tmp" 20 | 21 | if ! curl -Ls --output "${_tempFileName}" "${INSTV2URL}"; then 22 | echo " !!! Failed to download update for $0 !" 23 | echo " !!! Make sure you have ca-certificates installed and that time is set correctly" 24 | exit 1 25 | fi 26 | 27 | OCTAL_MODE=$(stat -c '%a' "$0") 28 | if ! chmod ${OCTAL_MODE} "${_tempFileName}" ; then 29 | echo " !!! Failed: Error while trying to set mode on ${_tempFileName}" 30 | exit 1 31 | fi 32 | 33 | cat > "${WORK_PATH}/.updateScript.sh" << EOF 34 | if mv "${_tempFileName}" "$0"; then 35 | rm -- "\$0" 36 | exec env UPDATE_SELF=0 /bin/bash "$0" "${MOUNTDIR}" 37 | else 38 | echo " !!! Failed!" 39 | fi 40 | EOF 41 | 42 | echo " *** Relaunching after update" 43 | exec /bin/bash "${WORK_PATH}/.updateScript.sh" 44 | } 45 | 46 | 47 | 48 | ############# Few general checks to run safely 49 | [ "$BASH_VERSION" != '' ] || { echo >&2 "Please run with bash, or as: ./$0 Exiting now..."; exit 1; } 50 | wget -q --tries=10 --timeout=20 --spider http://google.com > /dev/null 2>&1 || { echo >&2 "Please check your internet connection !! Exiting now..."; exit 1; } 51 | 52 | [ "${UPDATE_SELF}" -ne 0 ] && { update_self; } 53 | 54 | 55 | echo -n " 56 | ###################################################### 57 | ########### Volumio2 install on Berryboot ########### 58 | ########### version ${INSTVOLVERSION} by macmpi ########### 59 | This script prepares and installs Volumio2 image for use under berryboot on 60 | Raspberry Pi 61 | It MUST be run under a Debian Linux OS (like Raspbian-lite) and with 62 | internet access. 63 | At first run, it may install missing Debian packages: this can take time... 64 | (sudo rights are needed for Debian installs, mounts and image copy) 65 | If run under Pi with berryboot (recommended), it will try to install image into 66 | final location (SD/USB disk encrypted or not, iSCSI). 67 | If not run under berryboot (Pi, PC,...), it will try to copy image to 68 | any connected media eventually containing a berryboot partition. 69 | If no berryboot data partition is detected, image file may be produced in 70 | working directory, for later-on use... 71 | Hit any key to continue, or \"q\" to quit " 72 | read -n 1 resp 73 | echo "" 74 | if [ "${resp}" = "q" ]; then 75 | echo "Setup unmodified, quitting... Bye!" 76 | exit 1 77 | fi 78 | 79 | 80 | RUNBB=false 81 | 82 | ! uname -r | grep "\-aufs" > /dev/null 2>&1 || { echo >&2 "berryboot kernel detected !! "; RUNBB=true; } 83 | 84 | 85 | # Install required Debian tool packages if needed 86 | 87 | function check_install_packages() { 88 | APTUPDT=false 89 | for p 90 | do 91 | if ! dpkg-query -s $p 2> /dev/null | grep -q ^"Status: install ok installed" ; then 92 | [ ${APTUPDT} = true ] || { echo >&2 "We need to install a few Debian tools (only once)...please be patient"; echo >&2 ""; sudo apt-get update; } 93 | sudo apt-get install -y "$p" 94 | APTUPDT=true 95 | fi 96 | done 97 | [ ${APTUPDT} = false ] || { echo >&2 "Debian tools installed, let's move-on !"; echo >&2 ""; } 98 | } 99 | 100 | 101 | if [ ${RUNBB} = true ]; then 102 | check_install_packages zsync squashfs-tools # encrypted and iscsi are readily available 103 | else 104 | check_install_packages zsync squashfs-tools cryptsetup open-iscsi 105 | fi 106 | 107 | ################## Determine where to land image file 108 | 109 | if [ -z "${MOUNTDIR}" ]; then 110 | 111 | CRYPT_PART=$( sudo blkid | egrep "TYPE=\"crypto_LUKS\"" | awk -F ":" '{print $1}' ) 112 | if [ ! -z "${CRYPT_PART}" ] && [ ${RUNBB} = false ]; then # not on berryboot but encrypted data partition plugged-in 113 | echo "Encrypted Berryboot partition found !" 114 | sudo cryptsetup luksOpen "${CRYPT_PART}" lukstemp > /dev/null 2>&1 115 | fi 116 | 117 | DEVLIST=$( sudo blkid | egrep "LABEL=\"berryboot\"" | awk -F ":" '{print $1}' ) 118 | for p in ${DEVLIST} 119 | do 120 | echo -n "Found berryboot partition at $p : do you want to use this one? [Y/n] " 121 | read -n 1 resp 122 | echo "" 123 | if [ "${resp}" != "n" ]; then 124 | # on Berryboot: mounts any type (std, encrypted, iscsi); on other cases all mounted except iscsi 125 | MOUNTDIR="$(pwd)/berryboot" 126 | mkdir -p "${MOUNTDIR}" 127 | sudo mount "${p}" "${MOUNTDIR}" > /dev/null 2>&1 128 | break 129 | fi 130 | done 131 | fi 132 | 133 | 134 | # Handle missing berryboot folder 135 | DESTDIR="${MOUNTDIR}"/images 136 | if ! ls "${DESTDIR}" > /dev/null 2>&1; then 137 | DESTDIR="$(pwd)" 138 | echo -n " 139 | Could not find any berryboot data partition ! 140 | You may QUIT, and once you manually mount a target berryboot partition, you may 141 | relaunch and pass relevant mountpoint path as input paramater. 142 | Alternatively, you may choose to CONTINUE, and this script will produce image 143 | file into ${DESTDIR} directory. 144 | You may then move that image later-on yourself into \"images\" directory, 145 | within your berryboot data partition. 146 | Hit any key to continue, or \"q\" to quit : " 147 | read -n 1 resp 148 | echo "" 149 | if [ "${resp}" = "q" ]; then 150 | if [ -z "$1" ]; then 151 | sudo umount "${MOUNTDIR}" > /dev/null 2>&1 152 | rmdir "${MOUNTDIR}" > /dev/null 2>&1 153 | sudo cryptsetup luksClose lukstemp > /dev/null 2>&1 154 | fi 155 | echo "Setup unmodified, quitting... Bye!" 156 | exit 1 157 | fi 158 | fi 159 | 160 | 161 | #################### Now we start the actual work !... 162 | IMAGENAME="Volumio2" 163 | FBVERSION="2.296" # fallback Volumio2 version if latest can not be detected 164 | BB_MEM="240" # this corresponds to Volumio default 16MB gpu memory split. Change if you need different 165 | 166 | 167 | # Try to find latest Volumio2 version number 168 | VLATEST=$( curl -Ls --user-agent "fogent" "https://volumio.org/get-started/#pi" | grep -o 'http:\/\/updates.volumio.org\/pi\/volumio\/.*\/volumio' | awk -F "/" '{print $6}' ) 169 | echo "" 170 | if [ -z "${VLATEST}" ]; then 171 | echo "Could not identify latest version, falling-back to version ${FBVERSION}" 172 | VLATEST="${FBVERSION}" 173 | else 174 | echo "Volumio2 latest release version is: ${VLATEST}" 175 | fi 176 | 177 | 178 | echo -n " 179 | Please input desired Volumio2 version (format: 2.xxx 2.185 minimum advised) 180 | List of available versions here https://volumio.org/forum/changelog-t1575.html 181 | For default version ${VLATEST}, just hit [ENTER] : " 182 | read resp 183 | if [ ! -z "${resp}" ]; then 184 | VLATEST="${resp}" 185 | fi 186 | 187 | echo -n " 188 | Please input name for the image (no space or special characters) 189 | For default name ${IMAGENAME}, just hit [ENTER] : " 190 | read resp 191 | echo "" 192 | if [ ! -z "${resp}" ]; then 193 | IMAGENAME="${resp}" 194 | fi 195 | 196 | 197 | DONE=-1 198 | WORKDIR="tmp_workdir" 199 | 200 | mkdir "${WORKDIR}" 201 | cd "${WORKDIR}" 202 | 203 | FILENAME="${IMAGENAME}".img"${BB_MEM}" # Volumio image file name in Berryboot 204 | touch "${FILENAME}" 205 | 206 | echo "Downloading original image from Volumio2 repo, this may take a bit of time..." 207 | if zsync -i "${FILENAME}" http://updates.volumio.org/pi/volumio/"${VLATEST}"/volumio_current.sqsh.zsync; then 208 | echo "Obtaining patches..." 209 | if wget -O berryboot-init "${BBINITURL}" > /dev/null 2>&1; then 210 | echo "Applying patches..." 211 | if mksquashfs ./berryboot-init volumio_current.sqsh > /dev/null 2>&1; then 212 | echo "Moving image into place..." 213 | sudo mv -f volumio_current.sqsh "${DESTDIR}/${FILENAME}" > /dev/null 2>&1 214 | DONE=$? 215 | [ ${DONE} -eq 0 ] || { echo >&2 "Final Volumio2 image copy failed"; } 216 | else 217 | echo "Volumio2 image patch failed." 218 | fi 219 | else 220 | echo "Patch files download failed." 221 | fi 222 | else 223 | echo "Volumio2 image download failed, or wrong version." 224 | fi 225 | 226 | 227 | 228 | ###### clean-up and exit 229 | cd .. 230 | echo "cleaning-up..." 231 | rm -rf "${WORKDIR:?}" 232 | 233 | sync 234 | 235 | if [ ${RUNBB} = true ]; then 236 | sudo umount "${MOUNTDIR}" > /dev/null 2>&1 237 | rmdir "${MOUNTDIR}" 238 | [ ${DONE} -eq 0 ] && { echo "Install done. You may launch ${IMAGENAME} from berryboot UI at next reboot"; } 239 | else 240 | if [ -z "$1" ] && [ "${DESTDIR}" != "$(pwd)" ]; then # we mounted image so we will unmount 241 | sudo umount "${MOUNTDIR}" > /dev/null 2>&1 242 | rmdir "${MOUNTDIR}" > /dev/null 2>&1 243 | sudo cryptsetup luksClose lukstemp > /dev/null 2>&1 244 | [ ${DONE} -eq 0 ] && { echo "Install done. You may plug back your berryboot media into your Pi, 245 | and launch ${IMAGENAME} from berryboot UI at next boot"; } 246 | else 247 | [ ${DONE} -eq 0 ] && { echo "Install done; image file is available in: ${DESTDIR}/${FILENAME}"; } 248 | fi 249 | fi 250 | 251 | exit 0 252 | -------------------------------------------------------------------------------- /Lakka/installLakka: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Source & license at https://github.com/macmpi/berryboot-scripts 4 | # Feel free to report any issue or comment there. 5 | 6 | INSTALLVERSION="1.2" 7 | 8 | BBINITURL="https://bit.ly/BBInitLakka" 9 | INSTALLURL="https://bit.ly/InstLakka" 10 | 11 | 12 | MOUNTDIR=${1:-""} 13 | 14 | UPDATE_SELF=${UPDATE_SELF:-1} 15 | WORK_PATH="$(pwd)" 16 | 17 | function update_self() { # function mostly borrowed from MrEngman install-wifi: thanks! 18 | echo " *** Performing self-update" 19 | _tempFileName="$0.tmp" 20 | 21 | if ! curl -Ls --output "${_tempFileName}" "${INSTALLURL}"; then 22 | echo " !!! Failed to download update for $0 !" 23 | echo " !!! Make sure you have ca-certificates installed and that time is set correctly" 24 | exit 1 25 | fi 26 | 27 | OCTAL_MODE=$(stat -c '%a' "$0") 28 | if ! chmod ${OCTAL_MODE} "${_tempFileName}" ; then 29 | echo " !!! Failed: Error while trying to set mode on ${_tempFileName}" 30 | exit 1 31 | fi 32 | 33 | cat > "${WORK_PATH}/.updateScript.sh" << EOF 34 | if mv "${_tempFileName}" "$0"; then 35 | rm -- "\$0" 36 | exec env UPDATE_SELF=0 /bin/bash "$0" "${MOUNTDIR}" 37 | else 38 | echo " !!! Failed!" 39 | fi 40 | EOF 41 | 42 | echo " *** Relaunching after update" 43 | exec /bin/bash "${WORK_PATH}/.updateScript.sh" 44 | } 45 | 46 | 47 | 48 | ############# Few general checks to run safely 49 | [ "$BASH_VERSION" != '' ] || { echo >&2 "Please run with bash, or as: ./$0 Exiting now..."; exit 1; } 50 | wget -q --tries=10 --timeout=20 --spider http://google.com > /dev/null 2>&1 || { echo >&2 "Please check your internet connection !! Exiting now..."; exit 1; } 51 | 52 | [ "${UPDATE_SELF}" -ne 0 ] && { update_self; } 53 | 54 | 55 | echo -n " 56 | ################################################### 57 | ########### Lakka install on Berryboot ########### 58 | ########### version ${INSTALLVERSION} by macmpi ########### 59 | 60 | 61 | This script prepares and installs Lakka image for use under berryboot on 62 | Raspberry Pi 63 | It MUST be run under a Debian Linux OS (like Raspbian-lite) and with 64 | internet access. 65 | At first run, it may install missing Debian packages: this can take time... 66 | (sudo rights are needed for Debian installs, mounts and image copy) 67 | 68 | If run under Pi with berryboot (recommended), it will try to install image into 69 | final location (SD/USB disk encrypted or not, iSCSI). 70 | If not run under berryboot (Pi, PC,...), it will try to copy image to 71 | any connected media eventually containing a berryboot partition. 72 | If no berryboot data partition is detected, image file may be produced in 73 | working directory, for later-on use... 74 | 75 | Hit any key to continue, or \"q\" to quit " 76 | read -n 1 resp 77 | echo "" 78 | if [ "${resp}" = "q" ]; then 79 | echo "Setup unmodified, quitting... Bye!" 80 | exit 1 81 | fi 82 | 83 | 84 | RUNBB=false 85 | 86 | ! uname -r | grep "\-aufs" > /dev/null 2>&1 || { echo >&2 "berryboot kernel detected !! "; RUNBB=true; } 87 | 88 | # Install required Debian tool packages if needed 89 | 90 | function check_install_packages() { 91 | APTUPDT=false 92 | for p 93 | do 94 | if ! dpkg-query -s $p 2> /dev/null | grep -q ^"Status: install ok installed" ; then 95 | [ ${APTUPDT} = true ] || { echo >&2 "We need to install a few Debian tools (only once)...please be patient"; echo >&2 ""; sudo apt-get update; } 96 | sudo apt-get install -y "$p" 97 | APTUPDT=true 98 | fi 99 | done 100 | [ ${APTUPDT} = false ] || { echo >&2 "Debian tools installed, let's move-on !"; echo >&2 ""; } 101 | } 102 | 103 | 104 | if [ ${RUNBB} = true ]; then 105 | check_install_packages squashfs-tools # encrypted and iscsi are readily available 106 | else 107 | check_install_packages squashfs-tools cryptsetup open-iscsi 108 | fi 109 | 110 | ################## Determine where to land image file 111 | 112 | if [ -z "${MOUNTDIR}" ]; then 113 | 114 | CRYPT_PART=$( sudo blkid | egrep "TYPE=\"crypto_LUKS\"" | awk -F ":" '{print $1}' ) 115 | if [ ! -z "${CRYPT_PART}" ] && [ ${RUNBB} = false ]; then # not on berryboot but encrypted data partition plugged-in 116 | echo "Encrypted Berryboot partition found !" 117 | sudo cryptsetup luksOpen "${CRYPT_PART}" lukstemp > /dev/null 2>&1 118 | fi 119 | 120 | DEVLIST=$( sudo blkid | egrep "LABEL=\"berryboot\"" | awk -F ":" '{print $1}' ) 121 | for p in ${DEVLIST} 122 | do 123 | echo -n "Found berryboot partition at $p : do you want to use this one? [Y/n] " 124 | read -n 1 resp 125 | echo "" 126 | if [ "${resp}" != "n" ]; then 127 | # on Berryboot: mounts any type (std, encrypted, iscsi); on other cases all mounted except iscsi 128 | MOUNTDIR="$(pwd)/berryboot" 129 | mkdir -p "${MOUNTDIR}" 130 | sudo mount "${p}" "${MOUNTDIR}" > /dev/null 2>&1 131 | break 132 | fi 133 | done 134 | fi 135 | 136 | 137 | # Handle missing berryboot folder 138 | DESTDIR="${MOUNTDIR}"/images 139 | if ! ls "${DESTDIR}" > /dev/null 2>&1; then 140 | DESTDIR="$(pwd)" 141 | echo -n " 142 | Could not find any berryboot data partition ! 143 | 144 | You may QUIT, and once you manually mount a target berryboot partition, you may 145 | relaunch and pass relevant mountpoint path as input paramater. 146 | 147 | Alternatively, you may choose to CONTINUE, and this script will produce image 148 | file into ${DESTDIR} directory. 149 | You may then move that image later-on yourself into \"images\" directory, 150 | within your berryboot data partition. 151 | 152 | Hit any key to continue, or \"q\" to quit : " 153 | read -n 1 resp 154 | echo "" 155 | if [ "${resp}" = "q" ]; then 156 | if [ -z "$1" ]; then 157 | sudo umount "${MOUNTDIR}" > /dev/null 2>&1 158 | rmdir "${MOUNTDIR}" > /dev/null 2>&1 159 | sudo cryptsetup luksClose lukstemp > /dev/null 2>&1 160 | fi 161 | echo "Setup unmodified, quitting... Bye!" 162 | exit 1 163 | fi 164 | fi 165 | 166 | 167 | #################### Now we start the actual work !... 168 | IMAGENAME="Lakka" 169 | FBVERSION="2.0" # fallback Lakka version if latest can not be detected 170 | BB_MEM="128" # this corresponds to Lakka default 16MB gpu memory split. Change if you need different 171 | MODEL="" 172 | 173 | 174 | # try to identify Pi architecture 175 | MODEL=$( uname -m ) 176 | case $MODEL in 177 | armv6l) 178 | MODEL="Pi Zero/v1" 179 | ;; 180 | armv7l) 181 | MODEL="Pi v2/v3" 182 | ;; 183 | *) 184 | MODEL="" 185 | ;; 186 | esac 187 | 188 | echo "" 189 | if [ ! -z "${MODEL}" ]; then 190 | echo -n "We detected ${MODEL} model. Please hit [ENTER] to confirm, 191 | or type \"0\" for Pi Zero/v1, or \"2\" for Pi v2/v3: " 192 | else 193 | echo -n "Unknown Pi Model. Please type \"0\" for Pi Zero/v1, or \"2\" for Pi v2/v3: " 194 | fi 195 | 196 | read -n 1 resp 197 | echo "" 198 | case $resp in 199 | 0) 200 | MODEL="RPi.arm" 201 | ;; 202 | 2) 203 | MODEL="RPi2.arm" 204 | ;; 205 | "") 206 | case $MODEL in 207 | "Pi Zero/v1") 208 | MODEL="RPi.arm" 209 | ;; 210 | "Pi v2/v3") 211 | MODEL="RPi2.arm" 212 | ;; 213 | "") 214 | echo "Could not determine proper Pi Model, quitting..." 215 | exit 1 216 | ;; 217 | esac 218 | ;; 219 | *) 220 | echo "Could not determine proper Pi Model, quitting..." 221 | exit 1 222 | ;; 223 | esac 224 | 225 | # Try to find latest Lakka version number 226 | VLATEST=$( curl -Ls --user-agent "fogent" "http://www.lakka.tv/get/linux/rpi" | grep -o 'Lakka-RPi\.arm-.*\.img.gz' | head -n 1 | awk -F "-" '{print $3}' | sed "s/.......$//g" ) 227 | echo "" 228 | if [ -z "${VLATEST}" ]; then 229 | echo "Could not identify latest version, falling-back to version ${FBVERSION}" 230 | VLATEST="${FBVERSION}" 231 | else 232 | echo "Lakka latest release version is: ${VLATEST}" 233 | fi 234 | 235 | 236 | echo -n " 237 | Please input desired Lakka version (format: X.Y) 238 | List of available versions here: http://le.builds.lakka.tv/RPi.arm/ 239 | For default version ${VLATEST}, just hit [ENTER] : " 240 | read resp 241 | if [ ! -z "${resp}" ]; then 242 | VLATEST="${resp}" 243 | fi 244 | 245 | 246 | echo -n " 247 | Please input name for the image (no space or special characters) 248 | For default name ${IMAGENAME}, just hit [ENTER] : " 249 | read resp 250 | echo "" 251 | if [ ! -z "${resp}" ]; then 252 | IMAGENAME="${resp}" 253 | fi 254 | 255 | 256 | DONE=-1 257 | WORKDIR="tmp_workdir" 258 | 259 | mkdir "${WORKDIR}" 260 | cd "${WORKDIR}" 261 | 262 | FILENAME="${IMAGENAME}".img"${BB_MEM}" # Lakka image file name in Berryboot 263 | 264 | echo "Downloading original image from Lakka repo, this may take a bit of time..." 265 | if wget "http://le.builds.lakka.tv/${MODEL}/Lakka-${MODEL}-${VLATEST}.tar"; then 266 | echo "Expanding archive..." 267 | if tar --strip-components=2 -xf "Lakka-${MODEL}-${VLATEST}.tar" "Lakka-${MODEL}-${VLATEST}"/target/SYSTEM; then 268 | echo "Obtaining patches..." 269 | if wget -O berryboot-init "${BBINITURL}" > /dev/null 2>&1; then 270 | echo "Applying patches..." 271 | if mksquashfs ./berryboot-init SYSTEM > /dev/null 2>&1; then 272 | echo "Moving image into place..." 273 | sudo mv -f SYSTEM "${DESTDIR}/${FILENAME}" > /dev/null 2>&1 274 | DONE=$? 275 | [ ${DONE} -eq 0 ] || { echo >&2 "Final Lakka image copy failed"; } 276 | else 277 | echo "Lakka image patch failed." 278 | fi 279 | else 280 | echo "Patch files download failed." 281 | fi 282 | else 283 | echo "Archive expansion failed." 284 | fi 285 | else 286 | echo "Lakka image download failed, or wrong version." 287 | fi 288 | 289 | 290 | 291 | ###### clean-up and exit 292 | cd .. 293 | echo "cleaning-up..." 294 | rm -rf "${WORKDIR:?}" 295 | 296 | sync 297 | 298 | if [ ${RUNBB} = true ]; then 299 | sudo umount "${MOUNTDIR}" > /dev/null 2>&1 300 | rmdir "${MOUNTDIR}" 301 | [ ${DONE} -eq 0 ] && { echo "Install done. You may launch ${IMAGENAME} from berryboot UI at next reboot"; } 302 | else 303 | if [ -z "$1" ] && [ "${DESTDIR}" != "$(pwd)" ]; then # we mounted image so we will unmount 304 | sudo umount "${MOUNTDIR}" > /dev/null 2>&1 305 | rmdir "${MOUNTDIR}" > /dev/null 2>&1 306 | sudo cryptsetup luksClose lukstemp > /dev/null 2>&1 307 | [ ${DONE} -eq 0 ] && { echo "Install done. You may plug back your berryboot media into your Pi, 308 | and launch ${IMAGENAME} from berryboot UI at next boot"; } 309 | else 310 | [ ${DONE} -eq 0 ] && { echo "Install done; image file is available in: ${DESTDIR}/${FILENAME}"; } 311 | fi 312 | fi 313 | 314 | exit 0 315 | -------------------------------------------------------------------------------- /LibreELEC/installLibreELEC: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Source & license at https://github.com/macmpi/berryboot-scripts 4 | # Feel free to report any issue or comment there. 5 | 6 | INSTLEVERSION="1.3" 7 | 8 | BBINITURL="https://bit.ly/BBInitLibreELEC" 9 | INSTLEURL="https://bit.ly/InstLibreELEC" 10 | 11 | 12 | MOUNTDIR=${1:-""} 13 | 14 | UPDATE_SELF=${UPDATE_SELF:-1} 15 | WORK_PATH="$(pwd)" 16 | 17 | function update_self() { # function mostly borrowed from MrEngman install-wifi: thanks! 18 | echo " *** Performing self-update" 19 | _tempFileName="$0.tmp" 20 | 21 | if ! curl -Ls --output "${_tempFileName}" "${INSTLEURL}"; then 22 | echo " !!! Failed to download update for $0 !" 23 | echo " !!! Make sure you have ca-certificates installed and that time is set correctly" 24 | exit 1 25 | fi 26 | 27 | OCTAL_MODE=$(stat -c '%a' "$0") 28 | if ! chmod ${OCTAL_MODE} "${_tempFileName}" ; then 29 | echo " !!! Failed: Error while trying to set mode on ${_tempFileName}" 30 | exit 1 31 | fi 32 | 33 | cat > "${WORK_PATH}/.updateScript.sh" << EOF 34 | if mv "${_tempFileName}" "$0"; then 35 | rm -- "\$0" 36 | exec env UPDATE_SELF=0 /bin/bash "$0" "${MOUNTDIR}" 37 | else 38 | echo " !!! Failed!" 39 | fi 40 | EOF 41 | 42 | echo " *** Relaunching after update" 43 | exec /bin/bash "${WORK_PATH}/.updateScript.sh" 44 | } 45 | 46 | 47 | 48 | ############# Few general checks to run safely 49 | [ "$BASH_VERSION" != '' ] || { echo >&2 "Please run with bash, or as: ./$0 Exiting now..."; exit 1; } 50 | wget -q --tries=10 --timeout=20 --spider http://google.com > /dev/null 2>&1 || { echo >&2 "Please check your internet connection !! Exiting now..."; exit 1; } 51 | 52 | [ "${UPDATE_SELF}" -ne 0 ] && { update_self; } 53 | 54 | 55 | echo -n " 56 | ####################################################### 57 | ########### LibreELEC install on Berryboot ########### 58 | ########### version ${INSTLEVERSION} by macmpi ########### 59 | 60 | 61 | This script prepares and installs LibreELEC image for use under berryboot on 62 | Raspberry Pi 63 | It MUST be run under a Debian Linux OS (like Raspbian-lite) and with 64 | internet access. 65 | At first run, it may install missing Debian packages: this can take time... 66 | (sudo rights are needed for Debian installs, mounts and image copy) 67 | 68 | If run under Pi with berryboot (recommended), it will try to install image into 69 | final location (SD/USB disk encrypted or not, iSCSI). 70 | If not run under berryboot (Pi, PC,...), it will try to copy image to 71 | any connected media eventually containing a berryboot partition. 72 | If no berryboot data partition is detected, image file may be produced in 73 | working directory, for later-on use... 74 | 75 | Hit any key to continue, or \"q\" to quit " 76 | read -n 1 resp 77 | echo "" 78 | if [ "${resp}" = "q" ]; then 79 | echo "Setup unmodified, quitting... Bye!" 80 | exit 1 81 | fi 82 | 83 | 84 | RUNBB=false 85 | 86 | ! uname -r | grep "\-aufs" > /dev/null 2>&1 || { echo >&2 "berryboot kernel detected !! "; RUNBB=true; } 87 | 88 | # Install required Debian tool packages if needed 89 | 90 | function check_install_packages() { 91 | APTUPDT=false 92 | for p 93 | do 94 | if ! dpkg-query -s $p 2> /dev/null | grep -q ^"Status: install ok installed" ; then 95 | [ ${APTUPDT} = true ] || { echo >&2 "We need to install a few Debian tools (only once)...please be patient"; echo >&2 ""; sudo apt-get update; } 96 | sudo apt-get install -y "$p" 97 | APTUPDT=true 98 | fi 99 | done 100 | [ ${APTUPDT} = false ] || { echo >&2 "Debian tools installed, let's move-on !"; echo >&2 ""; } 101 | } 102 | 103 | 104 | if [ ${RUNBB} = true ]; then 105 | check_install_packages squashfs-tools # encrypted and iscsi are readily available 106 | else 107 | check_install_packages squashfs-tools cryptsetup open-iscsi 108 | fi 109 | 110 | ################## Determine where to land image file 111 | 112 | if [ -z "${MOUNTDIR}" ]; then 113 | 114 | CRYPT_PART=$( sudo blkid | egrep "TYPE=\"crypto_LUKS\"" | awk -F ":" '{print $1}' ) 115 | if [ ! -z "${CRYPT_PART}" ] && [ ${RUNBB} = false ]; then # not on berryboot but encrypted data partition plugged-in 116 | echo "Encrypted Berryboot partition found !" 117 | sudo cryptsetup luksOpen "${CRYPT_PART}" lukstemp > /dev/null 2>&1 118 | fi 119 | 120 | DEVLIST=$( sudo blkid | egrep "LABEL=\"berryboot\"" | awk -F ":" '{print $1}' ) 121 | for p in ${DEVLIST} 122 | do 123 | echo -n "Found berryboot partition at $p : do you want to use this one? [Y/n] " 124 | read -n 1 resp 125 | echo "" 126 | if [ "${resp}" != "n" ]; then 127 | # on Berryboot: mounts any type (std, encrypted, iscsi); on other cases all mounted except iscsi 128 | MOUNTDIR="$(pwd)/berryboot" 129 | mkdir -p "${MOUNTDIR}" 130 | sudo mount "${p}" "${MOUNTDIR}" > /dev/null 2>&1 131 | break 132 | fi 133 | done 134 | fi 135 | 136 | 137 | # Handle missing berryboot folder 138 | DESTDIR="${MOUNTDIR}"/images 139 | if ! ls "${DESTDIR}" > /dev/null 2>&1; then 140 | DESTDIR="$(pwd)" 141 | echo -n " 142 | Could not find any berryboot data partition ! 143 | 144 | You may QUIT, and once you manually mount a target berryboot partition, you may 145 | relaunch and pass relevant mountpoint path as input paramater. 146 | 147 | Alternatively, you may choose to CONTINUE, and this script will produce image 148 | file into ${DESTDIR} directory. 149 | You may then move that image later-on yourself into \"images\" directory, 150 | within your berryboot data partition. 151 | 152 | Hit any key to continue, or \"q\" to quit : " 153 | read -n 1 resp 154 | echo "" 155 | if [ "${resp}" = "q" ]; then 156 | if [ -z "$1" ]; then 157 | sudo umount "${MOUNTDIR}" > /dev/null 2>&1 158 | rmdir "${MOUNTDIR}" > /dev/null 2>&1 159 | sudo cryptsetup luksClose lukstemp > /dev/null 2>&1 160 | fi 161 | echo "Setup unmodified, quitting... Bye!" 162 | exit 1 163 | fi 164 | fi 165 | 166 | 167 | #################### Now we start the actual work !... 168 | IMAGENAME="LibreELEC" 169 | FBVERSION="9.0.2" # fallback LibreELEC version if latest can not be detected 170 | BB_MEM="128" # this corresponds to LibreELEC default 16MB gpu memory split. Change if you need different 171 | MODEL="" 172 | 173 | 174 | # try to identify Pi architecture 175 | MODEL=$( uname -m ) 176 | case $MODEL in 177 | armv6l) 178 | MODEL="Pi Zero/v1" 179 | ;; 180 | armv7l) 181 | MODEL="Pi v2/v3" 182 | ;; 183 | aarch64) 184 | MODEL="Pi v4" 185 | ;; 186 | *) 187 | MODEL="" 188 | ;; 189 | esac 190 | 191 | echo "" 192 | if [ ! -z "${MODEL}" ]; then 193 | echo -n "We detected ${MODEL} model. Please hit [ENTER] to confirm, 194 | or type \"0\" for Pi Zero/v1, or \"2\" for Pi v2/v3, or \"4\" for Pi v4: " 195 | else 196 | echo -n "Unknown Pi Model. Please type \"0\" for Pi Zero/v1, or \"2\" for Pi v2/v3, or \"4\" for Pi v4: " 197 | fi 198 | 199 | read -n 1 resp 200 | echo "" 201 | case $resp in 202 | 0) 203 | MODEL="RPi" 204 | ;; 205 | 2) 206 | MODEL="RPi2" 207 | ;; 208 | 4) 209 | MODEL="RPi4" 210 | ;; 211 | "") 212 | case $MODEL in 213 | "Pi Zero/v1") 214 | MODEL="RPi" 215 | ;; 216 | "Pi v2/v3") 217 | MODEL="RPi2" 218 | ;; 219 | "Pi v4") 220 | MODEL="RPi4" 221 | ;; 222 | "") 223 | echo "Could not determine proper Pi Model, quitting..." 224 | exit 1 225 | ;; 226 | esac 227 | ;; 228 | *) 229 | echo "Could not determine proper Pi Model, quitting..." 230 | exit 1 231 | ;; 232 | esac 233 | 234 | # Try to find latest LibreELEC version number 235 | VLATEST=$( curl -Ls --user-agent "fogent" "http://archive.libreelec.tv/?C=N;O=D" | grep -o 'LibreELEC-'$MODEL'\.arm-.*\.[0-9]\.[0-9]\.tar' | head -n 1 | awk -F "-" '{print $5}' | sed "s/....$//g" ) 236 | echo "" 237 | if [ -z "${VLATEST}" ]; then 238 | echo "Could not identify latest version, falling-back to version ${FBVERSION}" 239 | VLATEST="${FBVERSION}" 240 | else 241 | echo "LibreELEC latest release version is: ${VLATEST}" 242 | fi 243 | 244 | 245 | echo -n " 246 | Please input desired LibreELEC version (format: X.Y.Z) 247 | List of available versions here: http://archive.libreelec.tv/ 248 | For default version ${VLATEST}, just hit [ENTER] : " 249 | read resp 250 | if [ ! -z "${resp}" ]; then 251 | VLATEST="${resp}" 252 | fi 253 | 254 | 255 | echo -n " 256 | Please input name for the image (no space or special characters) 257 | For default name ${IMAGENAME}, just hit [ENTER] : " 258 | read resp 259 | echo "" 260 | if [ ! -z "${resp}" ]; then 261 | IMAGENAME="${resp}" 262 | fi 263 | 264 | 265 | DONE=-1 266 | WORKDIR="tmp_workdir" 267 | 268 | mkdir "${WORKDIR}" 269 | cd "${WORKDIR}" 270 | 271 | FILENAME="${IMAGENAME}".img"${BB_MEM}" # LibreELEC image file name in Berryboot 272 | 273 | echo "Downloading original image from LibreELEC repo, this may take a bit of time..." 274 | if wget "http://archive.libreelec.tv/LibreELEC-${MODEL}.arm-${VLATEST}.tar"; then 275 | echo "Expanding archive..." 276 | if tar --strip-components=2 -xf "LibreELEC-${MODEL}.arm-${VLATEST}.tar" "LibreELEC-${MODEL}.arm-${VLATEST}"/target/SYSTEM; then 277 | echo "Obtaining patches..." 278 | if wget -O berryboot-init "${BBINITURL}" > /dev/null 2>&1; then 279 | echo "Applying patches..." 280 | if mksquashfs ./berryboot-init SYSTEM > /dev/null 2>&1; then 281 | echo "Moving image into place..." 282 | sudo mv -f SYSTEM "${DESTDIR}/${FILENAME}" > /dev/null 2>&1 283 | DONE=$? 284 | [ ${DONE} -eq 0 ] || { echo >&2 "Final LibreELEC image copy failed"; } 285 | else 286 | echo "LibreELEC image patch failed." 287 | fi 288 | else 289 | echo "Patch files download failed." 290 | fi 291 | else 292 | echo "Archive expansion failed." 293 | fi 294 | else 295 | echo "LibreELEC image download failed, or wrong version." 296 | fi 297 | 298 | 299 | 300 | ###### clean-up and exit 301 | cd .. 302 | echo "cleaning-up..." 303 | rm -rf "${WORKDIR:?}" 304 | 305 | sync 306 | 307 | if [ ${RUNBB} = true ]; then 308 | sudo umount "${MOUNTDIR}" > /dev/null 2>&1 309 | rmdir "${MOUNTDIR}" 310 | [ ${DONE} -eq 0 ] && { echo "Install done. You may launch ${IMAGENAME} from berryboot UI at next reboot"; } 311 | else 312 | if [ -z "$1" ] && [ "${DESTDIR}" != "$(pwd)" ]; then # we mounted image so we will unmount 313 | sudo umount "${MOUNTDIR}" > /dev/null 2>&1 314 | rmdir "${MOUNTDIR}" > /dev/null 2>&1 315 | sudo cryptsetup luksClose lukstemp > /dev/null 2>&1 316 | [ ${DONE} -eq 0 ] && { echo "Install done. You may plug back your berryboot media into your Pi, 317 | and launch ${IMAGENAME} from berryboot UI at next boot"; } 318 | else 319 | [ ${DONE} -eq 0 ] && { echo "Install done; image file is available in: ${DESTDIR}/${FILENAME}"; } 320 | fi 321 | fi 322 | 323 | exit 0 324 | -------------------------------------------------------------------------------- /Lakka/berryboot-init: -------------------------------------------------------------------------------- 1 | #!/bin/busybox sh 2 | 3 | # Source & license at https://github.com/macmpi/berryboot-scripts 4 | # Feel free to report any issue or comment there. 5 | 6 | 7 | ### This file resides in Lakka read-only squashfs image 8 | # This script does Lakka backoffice supervisor stuff, similarly to Lakka original init 9 | # It is run by berryboot init BEFORE aufs overlay filesystem is composed 10 | # 11 | # Note: it is run under Berryboot busybox, with root privileges 12 | # this script is inlined into berryboot init, so be careful about variables, cd, ... 13 | # 14 | # we can use (but shall not modify) the following variables: 15 | # 16 | # IMAGE=`cat /tmp/answer` 17 | # DATADIR="/mnt/data/$IMAGE" 18 | # SHAREDDIR="/mnt/shared" 19 | # IMAGEPATH="/mnt/images/$IMAGE" 20 | # GOVERNOR 21 | 22 | ENTRYPATH=$(pwd) # we are now safe to eventually change directory 23 | 24 | 25 | ############## Self-patch init sequence and relaunch from next banner ################## 26 | # Required until https://github.com/maxnet/berryboot/pull/437 is resolved 27 | # berryboot-init is inlined into /init, but the file resides in /squashfs. 28 | # Therefore, while running, it prevents un-mounting squashfs image and then update image. 29 | # So the trick here is to relaunch this script (and following part of init) from another 30 | # location, hence exiting/freeing this original file... (circumvoluted? humm... yes! :p) 31 | 32 | echo "" 33 | echo "Prepping script relocation..." 34 | 35 | # we construct relocated all-in-one init script 36 | echo "#!/bin/busybox sh" > /reloc-init 37 | # we keep this script from next banner to execute beyond that point 38 | sed -n -e '/^#* We start from here !! #*/,$p' /squashfs/berryboot-init >> /reloc-init 39 | # we append the remaining part of inird 40 | sed -n -e '/^.*# Fedora and Arch symlink.*/,$p' /init >> /reloc-init 41 | chmod 770 /reloc-init 42 | 43 | # we need to make sure our new /reloc-init can access insofar variables we (and init) need 44 | export IMAGE 45 | export DATADIR 46 | export SHAREDDIR 47 | export IMAGEPATH 48 | export GOVERNOR 49 | export ENTRYPATH 50 | 51 | echo "Now we will continue from another location... see you soon !!" 52 | exec /reloc-init # exec ensures we keep PID 1, which is required for switch_root 53 | 54 | # now we are gone in hyperspace !!! 55 | 56 | 57 | ###################### We start from here !! ########################### 58 | 59 | BBINITVERSION="1.6" 60 | 61 | BBINITURL="https://bit.ly/BBInitLakka" 62 | 63 | 64 | echo " 65 | ################################################### 66 | ########### Lakka Berryboot Integration ########### 67 | ########### version ${BBINITVERSION} by macmpi ########### 68 | " 69 | 70 | 71 | ################ generic log utiliy function ################### 72 | # Display a message and aggregate it for Lakka journalctl 73 | LOGFILE="/data/Lklog.txt" # Lakka OS will consume it 74 | 75 | print_msg() { 76 | echo "$1" | tee -a /mnt"${LOGFILE}" 77 | } 78 | 79 | 80 | ########### detect Partitions devices ###################### 81 | 82 | # Actual berryboot boot partition is unknown and not mounted, so it can only be determined 83 | # by reading cmdline.txt. However berryboot install may not set it in default SD setup! 84 | BOOT_PART="" 85 | CMDLINE=$(cat /proc/cmdline) 86 | 87 | for p in ${CMDLINE}; 88 | do 89 | key=${p%%=*} 90 | value=${p#*=} 91 | 92 | case $key in 93 | bootdev) 94 | BOOT_PART=$value 95 | ;; 96 | esac 97 | done 98 | 99 | # sanity-check 100 | BOOT_PART=${BOOT_PART#UUID=} # extract actual UUID out of UUID=XXX if any 101 | 102 | if [ -z "${BOOT_PART}" ]; then 103 | BOOT_PART="/dev/mmcblk0p1" # default berryboot convention 104 | 105 | elif ( ls /dev/disk/by-uuid | grep -q "${BOOT_PART}"$ ); then 106 | BOOT_PART="/dev/disk/by-uuid/"${BOOT_PART} 107 | # fully qualify UUID reference to ensure mounting 108 | 109 | else # check device name & eventually complete if partial 110 | BOOT_PART=$(ls /dev/* | grep "${BOOT_PART}"$) 111 | # can result in empty path if device not found or wrong UUID! 112 | fi 113 | 114 | 115 | if [ -z "${BOOT_PART}" ]; then 116 | echo " 117 | WARNING !!! Something went wrong with bootdev definition: we will 118 | NOT be able to mount boot partition. Edit cmdline.txt to properly 119 | set bootdev= parameter." 120 | sleep 1 121 | fi 122 | 123 | 124 | # Berryboot data partiton (always exists at this point) may not be directly the one specified in 125 | # cmdline.txt by datadev= , namely in case of complex mounts such as encrypted partitions or iSCSI 126 | # so we look at which device corresponds to /mnt currently, as berryboot has completed it's own mounting work here 127 | # in case of encrypted partitions, fstab mount requires mount by UUID, so we always use it 128 | DATA_PART=$(df | egrep "/mnt" | awk '{print $1}') 129 | 130 | print_msg "Partitions found: boot: ${BOOT_PART} berryboot data: ${DATA_PART}" 131 | 132 | ########### Sanity-checks finished ####### 133 | 134 | 135 | 136 | ########################################################### 137 | ############## Lakka Reset & Updates functions ############ 138 | ########################################################### 139 | 140 | 141 | ################# LibreELEC-Lakka Updates section ########################## 142 | # Now we setup things so that LibreELEC-lakka built-in updates work. 143 | # We check if such update has been done previously, in order to replace image. 144 | # Note: after update we relaunch new-image script with it's own script do new own setup 145 | # so we stay away from any significant changes before doing update (do that first) 146 | 147 | 148 | # monitor /storage/.update directory (within overlay) that receives OS updates from LibreELEC app. 149 | UPDTDIR="${DATADIR}/storage/.update" 150 | if [ ! -d "${UPDTDIR}" ]; then 151 | mkdir -p "${UPDTDIR}" 152 | chmod 777 "${UPDTDIR}" 153 | fi 154 | 155 | cd "${UPDTDIR}" 156 | 157 | UPDATE_TAR=$( basename ./*.tar .tar | head -n 1 ) 158 | UPDATE_IMG_GZ=$( basename ./*.img.gz .img.gz | head -n 1 ) 159 | UPDATE_IMG=$( basename ./*.img .img | head -n 1) 160 | 161 | if [ -f "${UPDATE_TAR}".tar ]; then 162 | print_msg "Extracting archive update file..." 163 | if tar -xf "${UPDATE_TAR}".tar "${UPDATE_TAR}"/target/SYSTEM > /dev/null 2>&1; then 164 | mv "${UPDATE_TAR}"/target/SYSTEM "${IMAGE}" 165 | else 166 | print_msg "Update extraction failed, keeping current image" 167 | fi 168 | elif [ -f "$UPDATE_IMG_GZ".img.gz -o -f "$UPDATE_IMG".img ]; then 169 | if [ -f "$UPDATE_IMG_GZ".img.gz ]; then 170 | print_msg "Decompressing image update file...(this may be *very* long)" 171 | if gunzip "$UPDATE_IMG_GZ".img.gz > /dev/null 2>&1; then 172 | UPDATE_IMG="$UPDATE_IMG_GZ" 173 | sync 174 | else 175 | print_msg "Image file decompression failed" 176 | fi 177 | fi 178 | print_msg "Extracting image update file..." 179 | LOOP=$(losetup -f) 180 | LOOP_NUM=$(echo $LOOP | sed 's|/dev/loop||') 181 | mknod $LOOP b 7 $LOOP_NUM > /dev/null 2>&1 182 | losetup $LOOP "$UPDATE_IMG".img > /dev/null 2>&1 183 | 184 | # check for MBR partititon 185 | OFFSET=$(fdisk -u -l $LOOP 2>/dev/null | awk '/^[ ]*Device/{part=1; next}; part{if ($2 == "*") {print $3} else {print $2} ; exit}') 186 | if [ -z "$OFFSET" ]; then 187 | # check for GPT partititon 188 | OFFSET=$(fdisk -u -l $LOOP 2>/dev/null | awk '/^Number/{part=1; next}; part{print $2; exit}') 189 | fi 190 | 191 | if [ ! -z "$OFFSET" ]; then 192 | SECTOR_SIZE=$(cat /sys/devices/virtual/block/loop${LOOP_NUM}/queue/hw_sector_size) 193 | losetup -d $LOOP > /dev/null 2>&1 194 | sync 195 | 196 | OFFSET=$(($OFFSET * $SECTOR_SIZE)) 197 | losetup -o $OFFSET $LOOP "$UPDATE_IMG".img > /dev/null 2>&1 198 | mkdir -p .tmp/mnt 199 | if mount -t vfat -o ro,loop $LOOP .tmp/mnt > /dev/null 2>&1; then 200 | cp .tmp/mnt/SYSTEM "${IMAGE}" 201 | sync 202 | umount .tmp/mnt 203 | else 204 | print_msg "Incorrect image update file, keeping current image" 205 | fi 206 | losetup -d $LOOP > /dev/null 2>&1 207 | else 208 | print_msg "No valid system partition in image file, keeping current image" 209 | fi 210 | fi 211 | 212 | 213 | if [ -f "${IMAGE}" ]; then 214 | print_msg "Installing updated image" 215 | # we try to get latest patches from network or fallback with existing ones 216 | if ! wget -O berryboot-init "${BBINITURL}" > /dev/null 2>&1; then 217 | cp /squashfs/berryboot-init . 218 | fi 219 | chmod ug+x berryboot-init # needed because we will relaunch with exec command, not inline 220 | print_msg "Patching updated image" 221 | if mksquashfs ./berryboot-init "${IMAGE}" > /dev/null 2>&1; then 222 | print_msg "Unmounting previous image and replacing with new" 223 | umount -f /squashfs # we are now running from /reloc-init so we should be safe to keep running!... 224 | mv -f "${IMAGE}" "${IMAGEPATH}" 225 | rm -rf "${UPDTDIR:?}"/* 226 | sync 227 | clear 228 | print_msg "Mounting Updated image ${IMAGE}" 229 | mount -o loop,ro "${IMAGEPATH}" /squashfs 230 | cd "${ENTRYPATH}" 231 | print_msg "Relaunching with updated image & init..." 232 | exec /squashfs/berryboot-init # exec ensures we keep PID 1 233 | else 234 | print_msg "Patching new image failed, keeping current image" 235 | fi 236 | fi 237 | 238 | rm -rf "${UPDTDIR:?}"/* 239 | 240 | 241 | 242 | 243 | ########### Clean-up dangerous stuff ########### 244 | # There is a /flash recovery version in /usr/share/bootloader used by init (& elsewhere?) 245 | # One may remount /flash in read-write to update it or do recovery 246 | # as we do not want that to happen so we do hide that content in overlay. 247 | mkdir -p "${DATADIR}"/usr/share 248 | touch "${DATADIR}"/usr/share/.wh.bootloader 249 | 250 | mkdir -p "${DATADIR}"/usr/lib/libreelec 251 | # Hide fs-resize baseline script as we do not want it to be run at runtime 252 | touch "${DATADIR}"/usr/lib/libreelec/.wh.fs-resize 253 | 254 | ########### Swap management ########### 255 | # LibreELEC swap depends about /usr/lib/libreelec/mount-swap and /etc/swap.conf 256 | # Is disabled by default & can not be set by UI: we do not handle for now 257 | # we wipe script untill someone complains (keep the script as a service does launch it) 258 | [ -f "${DATADIR}"/usr/lib/libreelec/mount-swap ] || { echo "#!/bin/sh" > "${DATADIR}"/usr/lib/libreelec/mount-swap; } 259 | chmod 774 "${DATADIR}"/usr/lib/libreelec/mount-swap 260 | 261 | ################################################################## 262 | ############ General config for Lakka OS boot ############ 263 | ################################################################## 264 | 265 | BBMOUNT="/berryboot" 266 | 267 | 268 | ################ berryboot-integ script & systemd service ################################### 269 | # setup berryboot-integ script and related systemd service to launch berryboot-integ at Lakka OS startup 270 | # This allows to mount partitions and issue pre-boot berryboot-phase log into system journal 271 | # Lakka init mounts boot partition as read-only in /flash, so we do same. 272 | 273 | mkdir -p "${DATADIR}"/usr/lib/systemd/system 274 | mkdir -p "${DATADIR}"/usr/lib/systemd/system/multi-user.target.wants 275 | 276 | print_msg "Creating Berryboot integration systemd service for Lakka OS" 277 | 278 | echo "[Unit] 279 | Description = Berryboot integration service 280 | 281 | After=network.target 282 | 283 | [Service] 284 | Type=simple 285 | StandardOutput=syslog 286 | StandardError=syslog 287 | SyslogIdentifier=berryboot-integ 288 | User=root 289 | Group=root 290 | ExecStartPre=/bin/mkdir -p ${BBMOUNT} 291 | ExecStartPre=/bin/mount ${DATA_PART} ${BBMOUNT} -o defaults 292 | ExecStartPre=/bin/mount -t vfat ${BOOT_PART} /flash -o ro,noatime 293 | ExecStart=/bin/sh /.berryboot-integ 294 | 295 | [Install] 296 | WantedBy=multi-user.target" > "${DATADIR}"/usr/lib/systemd/system/berryboot-integ.service 297 | 298 | # Enable Systemd service 299 | ln -s /usr/lib/systemd/system/berryboot-integ.service "${DATADIR}"/usr/lib/systemd/system/multi-user.target.wants/berryboot-integ.service > /dev/null 2>&1 300 | 301 | 302 | # berryboot-integ script is always restored in original state 303 | echo "#!/bin/sh 304 | 305 | ### This file resides in Lakka image overlay filesystem 306 | # It is run as root during Lakka OS image startup through Systemd service. 307 | # As Lakka OS boots from aufs overlayed filesystem, one may modify this file 308 | # but such changes will have not effect at next boot, as file is restored in original state 309 | 310 | # dump early berryboot-init log file into system journal 311 | cat ${BBMOUNT}${LOGFILE} 312 | rm ${BBMOUNT}${LOGFILE} > /dev/null 2>&1 313 | 314 | echo Now fixing Lakka startup overlayfs mounts 315 | ln -s /usr/share/retroarch-assets /tmp/assets 316 | [ -h /storage/assets ] || { ln -s /usr/share/retroarch-assets /storage/assets; } 317 | 318 | ln -s /usr/lib/libretro /tmp/cores 319 | [ -h storage/cores ] || { ln -s /usr/lib/libretro storage/cores; } 320 | 321 | ln -s /usr/share/libretro-database /tmp/database 322 | [ -h /storage/database ] || { ln -s /usr/share/libretro-database /storage/database; } 323 | 324 | ln -s /etc/retroarch-joypad-autoconfig /tmp/joypads 325 | [ -h /storage/joypads ] || { ln -s /etc/retroarch-joypad-autoconfig /storage/joypads; } 326 | 327 | ln -s /usr/share/common-shaders /tmp/shaders 328 | [ -h /storage/shaders ] || { ln -s /usr/share/common-shaders /storage/shaders; } 329 | 330 | echo We are all set ! 331 | " > "${DATADIR}"/.berryboot-integ 332 | 333 | chmod 774 "${DATADIR}"/.berryboot-integ 334 | 335 | 336 | # Hide related mount scripts and their retroarch.target.wants 337 | mkdir -p "${DATADIR}"/usr/lib/systemd/system/retroarch.target.wants 338 | 339 | touch "${DATADIR}"/usr/lib/systemd/system/.wh.tmp-assets.mount 340 | touch "${DATADIR}"/usr/lib/systemd/system/retroarch.target.wants/.wh.tmp-assets.mount 341 | 342 | touch "${DATADIR}"/usr/lib/systemd/system/.wh.tmp-cores.mount 343 | touch "${DATADIR}"/usr/lib/systemd/system/retroarch.target.wants/.wh.tmp-cores.mount 344 | 345 | touch "${DATADIR}"/usr/lib/systemd/system/.wh.tmp-database.mount 346 | touch "${DATADIR}"/usr/lib/systemd/system/retroarch.target.wants/.wh.tmp-database.mount 347 | 348 | touch "${DATADIR}"/usr/lib/systemd/system/.wh.tmp-joypads.mount 349 | touch "${DATADIR}"/usr/lib/systemd/system/retroarch.target.wants/.wh.tmp-joypads.mount 350 | 351 | touch "${DATADIR}"/usr/lib/systemd/system/.wh.tmp-shaders.mount 352 | touch "${DATADIR}"/usr/lib/systemd/system/retroarch.target.wants/.wh.tmp-shaders.mount 353 | 354 | 355 | 356 | ############################################################# 357 | ############### now some FUN !!!! ############ 358 | ############################################################# 359 | 360 | # hide /berryboot-init file in overlay 361 | touch "${DATADIR}"/.wh.berryboot-init 362 | 363 | mkdir -p "${DATADIR}"/etc 364 | cat /squashfs/etc/issue > "${DATADIR}"/etc/issue 365 | cat << "EOF" >> "${DATADIR}"/etc/issue 366 | 367 | /\/\/\/\/\/\ 368 | < > 369 | | | 370 | | | 371 | | _ _ | 372 | -|_ / \/ \_ |- 373 | |I| \_/\_/ |I| Change is good. 374 | -| / \ |- You go first. 375 | | \__/ | 376 | | | 377 | | | 378 | |__________| 379 | /___/\__/\___\ 380 | / | \| \ 381 | /\ |\ | _@|#_ 382 | / /\ | \| | | 383 | \/ / \ / | | 384 | \_/___/ \_/ 385 | 386 | 387 | Reminder: we run under berryboot kernel now... 388 | 389 | EOF 390 | 391 | sync 392 | cd "${ENTRYPATH}" 393 | print_msg "Now we can finally boot Lakka image..., go!" 394 | echo "" 395 | 396 | # now we follow into the remaining of berryboot init... 397 | -------------------------------------------------------------------------------- /LibreELEC/berryboot-init: -------------------------------------------------------------------------------- 1 | #!/bin/busybox sh 2 | 3 | # Source & license at https://github.com/macmpi/berryboot-scripts 4 | # Feel free to report any issue or comment there. 5 | 6 | 7 | ### This file resides in LibreELEC read-only squashfs image 8 | # This script does LibreELEC backoffice supervisor stuff, similarly to LibreELEC original init 9 | # It is run by berryboot init BEFORE aufs overlay filesystem is composed 10 | # 11 | # Note: it is run under Berryboot busybox, with root privileges 12 | # this script is inlined into berryboot init, so be careful about variables, cd, ... 13 | # 14 | # we can use (but shall not modify) the following variables: 15 | # 16 | # IMAGE=`cat /tmp/answer` 17 | # DATADIR="/mnt/data/$IMAGE" 18 | # SHAREDDIR="/mnt/shared" 19 | # IMAGEPATH="/mnt/images/$IMAGE" 20 | # GOVERNOR 21 | 22 | ENTRYPATH=$(pwd) # we are now safe to eventually change directory 23 | 24 | 25 | ############## Self-patch init sequence and relaunch from next banner ################## 26 | # Required until https://github.com/maxnet/berryboot/pull/437 is resolved 27 | # berryboot-init is inlined into /init, but the file resides in /squashfs. 28 | # Therefore, while running, it prevents un-mounting squashfs image and then update image. 29 | # So the trick here is to relaunch this script (and following part of init) from another 30 | # location, hence exiting/freeing this original file... (circumvoluted? humm... yes! :p) 31 | 32 | echo "" 33 | echo "Prepping script relocation..." 34 | 35 | # we construct relocated all-in-one init script 36 | echo "#!/bin/busybox sh" > /reloc-init 37 | # we keep this script from next banner to execute beyond that point 38 | sed -n -e '/^#* We start from here !! #*/,$p' /squashfs/berryboot-init >> /reloc-init 39 | # we append the remaining part of inird 40 | sed -n -e '/^.*# Fedora and Arch symlink.*/,$p' /init >> /reloc-init 41 | chmod 770 /reloc-init 42 | 43 | # we need to make sure our new /reloc-init can access insofar variables we (and init) need 44 | export IMAGE 45 | export DATADIR 46 | export SHAREDDIR 47 | export IMAGEPATH 48 | export GOVERNOR 49 | export ENTRYPATH 50 | 51 | echo "Now we will continue from another location... see you soon !!" 52 | exec /reloc-init # exec ensures we keep PID 1, which is required for switch_root 53 | 54 | # now we are gone in hyperspace !!! 55 | 56 | 57 | ###################### We start from here !! ########################### 58 | 59 | BBINITVERSION="1.6" 60 | 61 | BBINITURL="https://bit.ly/BBInitLibreELEC" 62 | 63 | 64 | echo " 65 | ####################################################### 66 | ########### LibreELEC Berryboot Integration ########### 67 | ########### version ${BBINITVERSION} by macmpi ########### 68 | " 69 | 70 | 71 | ################ generic log utiliy function ################### 72 | # Display a message and aggregate it for LibreELEC journalctl 73 | LOGFILE="/data/LElog.txt" # LibreELEC OS will consume it 74 | 75 | print_msg() { 76 | echo "$1" | tee -a /mnt"${LOGFILE}" 77 | } 78 | 79 | 80 | ########### detect Partitions devices ###################### 81 | 82 | # Actual berryboot boot partition is unknown and not mounted, so it can only be determined 83 | # by reading cmdline.txt. However berryboot install may not set it in default SD setup! 84 | BOOT_PART="" 85 | CMDLINE=$(cat /proc/cmdline) 86 | 87 | for p in ${CMDLINE}; 88 | do 89 | key=${p%%=*} 90 | value=${p#*=} 91 | 92 | case $key in 93 | bootdev) 94 | BOOT_PART=$value 95 | ;; 96 | esac 97 | done 98 | 99 | # sanity-check 100 | BOOT_PART=${BOOT_PART#UUID=} # extract actual UUID out of UUID=XXX if any 101 | 102 | if [ -z "${BOOT_PART}" ]; then 103 | BOOT_PART="/dev/mmcblk0p1" # default berryboot convention 104 | 105 | elif ( ls /dev/disk/by-uuid | grep -q "${BOOT_PART}"$ ); then 106 | BOOT_PART="/dev/disk/by-uuid/"${BOOT_PART} 107 | # fully qualify UUID reference to ensure mounting 108 | 109 | else # check device name & eventually complete if partial 110 | BOOT_PART=$(ls /dev/* | grep "${BOOT_PART}"$) 111 | # can result in empty path if device not found or wrong UUID! 112 | fi 113 | 114 | 115 | if [ -z "${BOOT_PART}" ]; then 116 | echo " 117 | WARNING !!! Something went wrong with bootdev definition: we will 118 | NOT be able to mount boot partition. Edit cmdline.txt to properly 119 | set bootdev= parameter." 120 | sleep 1 121 | fi 122 | 123 | 124 | 125 | # Berryboot data partiton (always exists at this point) may not be directly the one specified in 126 | # cmdline.txt by datadev= , namely in case of complex mounts such as encrypted partitions or iSCSI 127 | # so we look at which device corresponds to /mnt currently, as berryboot has completed it's own mounting work here 128 | # in case of encrypted partitions, fstab mount requires mount by UUID, so we always use it 129 | DATA_PART=$(df | egrep "/mnt" | awk '{print $1}') 130 | 131 | print_msg "Partitions found: boot: ${BOOT_PART} berryboot data: ${DATA_PART}" 132 | 133 | ########### Sanity-checks finished ####### 134 | 135 | 136 | 137 | ############################################################### 138 | ############## LibreELEC Reset & Updates functions ############ 139 | ############################################################### 140 | 141 | # Deal with factory reset (as in /usr/lib/libreelec/factory-reset) 142 | # In both cases we just clean flags and just do soft reset 143 | 144 | if [ -f "${DATADIR}"/storage/.cache/reset_oe ]; then 145 | print_msg "Performing hard reset..." 146 | rm -rf "${DATADIR}" /dev/null 2>&1 # also wipes flags 147 | fi 148 | 149 | if [ -f "${DATADIR}"/storage/.cache/reset_xbmc ]; then 150 | print_msg "Performing soft reset..." 151 | rm -rf "${DATADIR}"/storage/.??* > /dev/null 2>&1 # also wipes flags 152 | fi 153 | 154 | 155 | ################# LibreELEC Updates section ########################## 156 | # Now we setup things so that LibreELEC built-in updates work. 157 | # We check if such update has been done previously, in order to replace image. 158 | # Note: after update we relaunch new-image script with it's own script do new own setup 159 | # so we stay away from any significant changes before doing update (do that first) 160 | 161 | 162 | # monitor /storage/.update directory (within overlay) that receives OS updates from LibreELEC app. 163 | UPDTDIR="${DATADIR}/storage/.update" 164 | if [ ! -d "${UPDTDIR}" ]; then 165 | mkdir -p "${UPDTDIR}" 166 | chmod 777 "${UPDTDIR}" 167 | fi 168 | 169 | cd "${UPDTDIR}" 170 | 171 | UPDATE_TAR=$( basename ./*.tar .tar | head -n 1 ) 172 | UPDATE_IMG_GZ=$( basename ./*.img.gz .img.gz | head -n 1 ) 173 | UPDATE_IMG=$( basename ./*.img .img | head -n 1) 174 | 175 | if [ -f "${UPDATE_TAR}".tar ]; then 176 | print_msg "Extracting archive update file..." 177 | if tar -xf "${UPDATE_TAR}".tar $( tar -tf "${UPDATE_TAR}".tar | grep 'SYSTEM$' ) > /dev/null 2>&1; then 178 | mv */target/SYSTEM "${IMAGE}" 179 | else 180 | print_msg "Update extraction failed, keeping current image" 181 | fi 182 | elif [ -f "$UPDATE_IMG_GZ".img.gz -o -f "$UPDATE_IMG".img ]; then 183 | if [ -f "$UPDATE_IMG_GZ".img.gz ]; then 184 | print_msg "Decompressing image update file...(this may be *very* long)" 185 | if gunzip "$UPDATE_IMG_GZ".img.gz > /dev/null 2>&1; then 186 | UPDATE_IMG="$UPDATE_IMG_GZ" 187 | sync 188 | else 189 | print_msg "Image file decompression failed" 190 | fi 191 | fi 192 | print_msg "Extracting image update file..." 193 | LOOP=$(losetup -f) 194 | LOOP_NUM=$(echo $LOOP | sed 's|/dev/loop||') 195 | mknod $LOOP b 7 $LOOP_NUM > /dev/null 2>&1 196 | losetup $LOOP "$UPDATE_IMG".img > /dev/null 2>&1 197 | 198 | # check for MBR partititon 199 | OFFSET=$(fdisk -u -l $LOOP 2>/dev/null | awk '/^[ ]*Device/{part=1; next}; part{if ($2 == "*") {print $3} else {print $2} ; exit}') 200 | if [ -z "$OFFSET" ]; then 201 | # check for GPT partititon 202 | OFFSET=$(fdisk -u -l $LOOP 2>/dev/null | awk '/^Number/{part=1; next}; part{print $2; exit}') 203 | fi 204 | 205 | if [ ! -z "$OFFSET" ]; then 206 | SECTOR_SIZE=$(cat /sys/devices/virtual/block/loop${LOOP_NUM}/queue/hw_sector_size) 207 | losetup -d $LOOP > /dev/null 2>&1 208 | sync 209 | 210 | OFFSET=$(($OFFSET * $SECTOR_SIZE)) 211 | losetup -o $OFFSET $LOOP "$UPDATE_IMG".img > /dev/null 2>&1 212 | mkdir -p .tmp/mnt 213 | if mount -t vfat -o ro,loop $LOOP .tmp/mnt > /dev/null 2>&1; then 214 | cp .tmp/mnt/SYSTEM "${IMAGE}" 215 | sync 216 | umount .tmp/mnt 217 | else 218 | print_msg "Incorrect image update file, keeping current image" 219 | fi 220 | losetup -d $LOOP > /dev/null 2>&1 221 | else 222 | print_msg "No valid system partition in image file, keeping current image" 223 | fi 224 | fi 225 | 226 | 227 | if [ -f "${IMAGE}" ]; then 228 | print_msg "Installing updated image" 229 | # we try to get latest patches from network or fallback with existing ones 230 | if ! wget -O berryboot-init "${BBINITURL}" > /dev/null 2>&1; then 231 | cp /squashfs/berryboot-init . 232 | fi 233 | chmod ug+x berryboot-init # needed because we will relaunch with exec command, not inline 234 | print_msg "Patching updated image" 235 | if mksquashfs ./berryboot-init "${IMAGE}" > /dev/null 2>&1; then 236 | print_msg "Unmounting previous image and replacing with new" 237 | umount -f /squashfs # we are now running from /reloc-init so we should be safe to keep running!... 238 | mv -f "${IMAGE}" "${IMAGEPATH}" 239 | rm -rf "${UPDTDIR:?}"/* 240 | sync 241 | clear 242 | print_msg "Mounting Updated image ${IMAGE}" 243 | mount -o loop,ro "${IMAGEPATH}" /squashfs 244 | cd "${ENTRYPATH}" 245 | print_msg "Relaunching with updated image & init..." 246 | exec /squashfs/berryboot-init # exec ensures we keep PID 1 247 | else 248 | print_msg "Patching new image failed, keeping current image" 249 | fi 250 | fi 251 | 252 | rm -rf "${UPDTDIR:?}"/* 253 | 254 | 255 | ################################################ 256 | ############ back-up / Restore ############ 257 | ################################################ 258 | # Deal with backup-restore (as in /usr/lib/libreelec/backup-restore) 259 | BACKUP_FILE=$( ls -1 "${DATADIR}"/storage/.restore/??????????????.tar 2>/dev/null | tail -1 ) 260 | 261 | if [ -f "$BACKUP_FILE" ]; then 262 | print_msg "Checking backup file... " 263 | if tar tf $BACKUP_FILE > /dev/null 2>&1; then 264 | print_msg "Restoring backup... " 265 | rm -rf "${DATADIR}"/storage/.kodi > /dev/null 2>&1 266 | rm -rf "${DATADIR}"/storage/.cache > /dev/null 2>&1 267 | rm -rf "${DATADIR}"/storage/.config > /dev/null 2>&1 268 | tar xf $BACKUP_FILE -C "${DATADIR}" > /dev/null 2>&1 269 | rm -f $BACKUP_FILE > /dev/null 2>&1 270 | else 271 | print_msg "Backup file is not valid, or corrupt." 272 | rm -f $BACKUP_FILE > /dev/null 2>&1 273 | fi 274 | fi 275 | 276 | 277 | ########### Clean-up dangerous stuff ########### 278 | # There is a /flash recovery version in /usr/share/bootloader used by init (& elsewhere?) 279 | # One may remount /flash in read-write to update it or do recovery 280 | # as we do not want that to happen so we do hide that content in overlay. 281 | mkdir -p "${DATADIR}"/usr/share 282 | touch "${DATADIR}"/usr/share/.wh.bootloader 283 | 284 | mkdir -p "${DATADIR}"/usr/lib/libreelec 285 | # Hide fs-resize baseline script as we do not want it to be run at runtime 286 | touch "${DATADIR}"/usr/lib/libreelec/.wh.fs-resize 287 | # Hide factory-reset baseline script as we do not want it to be run at runtime 288 | touch "${DATADIR}"/usr/lib/libreelec/.wh.factory-reset 289 | # Hide backup-restore baseline script as it not used at runtime 290 | touch "${DATADIR}"/usr/lib/libreelec/.wh.backup-restore 291 | 292 | ########### Swap management ########### 293 | # LibreELEC swap depends about /usr/lib/libreelec/mount-swap and /etc/swap.conf 294 | # Is disabled by default & can not be set by UI: we do not handle for now 295 | # we wipe script untill someone complains (keep the script as a service does launch it) 296 | [ -f "${DATADIR}"/usr/lib/libreelec/mount-swap ] || { echo "#!/bin/sh" > "${DATADIR}"/usr/lib/libreelec/mount-swap; } 297 | chmod 774 "${DATADIR}"/usr/lib/libreelec/mount-swap 298 | 299 | ################################################################## 300 | ############ General config for LibreELEC OS boot ############ 301 | ################################################################## 302 | 303 | BBMOUNT="/berryboot" 304 | 305 | ################ berryboot-integ script & systemd service ################################### 306 | # setup berryboot-integ script and related systemd service to launch berryboot-integ at LibreELEC OS startup 307 | # This allows to mount partitions and issue pre-boot berryboot-phase log into system journal 308 | # LibreELEC init mounts boot partition as read-only in /flash, so we do same. 309 | 310 | mkdir -p "${DATADIR}"/usr/lib/systemd/system 311 | mkdir -p "${DATADIR}"/usr/lib/systemd/system/multi-user.target.wants 312 | 313 | print_msg "Creating Berryboot integration systemd service for LibreELEC OS" 314 | 315 | echo "[Unit] 316 | Description = Berryboot integration service 317 | 318 | After=network.target 319 | 320 | [Service] 321 | Type=simple 322 | StandardOutput=syslog 323 | StandardError=syslog 324 | SyslogIdentifier=berryboot-integ 325 | User=root 326 | Group=root 327 | ExecStartPre=/bin/mkdir -p ${BBMOUNT} 328 | ExecStartPre=/bin/mount ${DATA_PART} ${BBMOUNT} -o defaults 329 | ExecStartPre=/bin/mount -t vfat ${BOOT_PART} /flash -o ro,noatime 330 | ExecStart=/bin/sh /.berryboot-integ 331 | 332 | [Install] 333 | WantedBy=multi-user.target" > "${DATADIR}"/usr/lib/systemd/system/berryboot-integ.service 334 | 335 | # Enable Systemd service 336 | ln -s /usr/lib/systemd/system/berryboot-integ.service "${DATADIR}"/usr/lib/systemd/system/multi-user.target.wants/berryboot-integ.service > /dev/null 2>&1 337 | 338 | 339 | # berryboot-integ script is always restored in original state 340 | echo "#!/bin/sh 341 | 342 | ### This file resides in LibreELEC image overlay filesystem 343 | # It is run as root during LibreELEC OS image startup through Systemd service. 344 | # As LibreELEC OS boots from aufs overlayed filesystem, one may modify this file 345 | # but such changes will have not effect at next boot, as file is restored in original state 346 | 347 | # dump early berryboot-init log file into system journal 348 | cat ${BBMOUNT}${LOGFILE} 349 | rm ${BBMOUNT}${LOGFILE} > /dev/null 2>&1 350 | " > "${DATADIR}"/.berryboot-integ 351 | 352 | chmod 774 "${DATADIR}"/.berryboot-integ 353 | 354 | 355 | 356 | ############################################################# 357 | ############### now some FUN !!!! ############ 358 | ############################################################# 359 | 360 | # hide /berryboot-init file in overlay 361 | touch "${DATADIR}"/.wh.berryboot-init 362 | 363 | mkdir -p "${DATADIR}"/etc 364 | cat /squashfs/etc/motd > "${DATADIR}"/etc/motd 365 | cat << "EOF" >> "${DATADIR}"/etc/motd 366 | 367 | /\/\/\/\/\/\ 368 | < > 369 | | | 370 | | | 371 | | _ _ | 372 | -|_ / \/ \_ |- 373 | |I| \_/\_/ |I| Change is good. 374 | -| / \ |- You go first. 375 | | \__/ | 376 | | | 377 | | | 378 | |__________| 379 | /___/\__/\___\ 380 | / | \| \ 381 | /\ |\ | _@|#_ 382 | / /\ | \| | | 383 | \/ / \ / | | 384 | \_/___/ \_/ 385 | 386 | 387 | Reminder: we run under berryboot kernel now... 388 | 389 | EOF 390 | 391 | sync 392 | cd "${ENTRYPATH}" 393 | print_msg "Now we can finally boot LibreELEC image..., go!" 394 | echo "" 395 | 396 | # now we follow into the remaining of berryboot init... 397 | -------------------------------------------------------------------------------- /Volumio2/berryboot-init: -------------------------------------------------------------------------------- 1 | #!/bin/busybox sh 2 | 3 | # Source & license at https://github.com/macmpi/berryboot-scripts 4 | # Feel free to report any issue or comment there. 5 | 6 | 7 | ### This file resides in Volumio read-only squashfs image 8 | # This script does Volumio backoffice supervisor stuff, similarly to Volumio original init 9 | # It is run by berryboot init BEFORE aufs overlay filesystem is composed 10 | # 11 | # Note: it is run under Berryboot busybox, with root privileges 12 | # this script is inlined into berryboot init, so be careful about variables, cd, ... 13 | # 14 | # we can use (but shall not modify) the following variables: 15 | # 16 | # IMAGE=`cat /tmp/answer` 17 | # DATADIR="/mnt/data/$IMAGE" 18 | # SHAREDDIR="/mnt/shared" 19 | # IMAGEPATH="/mnt/images/$IMAGE" 20 | # GOVERNOR 21 | 22 | ENTRYPATH=$(pwd) # we are now safe to eventually change directory 23 | 24 | 25 | ############## Self-patch init sequence and relaunch from next banner ################## 26 | # Required until https://github.com/maxnet/berryboot/pull/437 is resolved 27 | # berryboot-init is inlined into /init, but the file resides in /squashfs. 28 | # Therefore, while running, it prevents un-mounting squashfs image and then update image. 29 | # So the trick here is to relaunch this script (and following part of init) from another 30 | # location, hence exiting/freeing this original file... (circumvoluted? humm... yes! :p) 31 | 32 | echo "" 33 | echo "Prepping script relocation..." 34 | 35 | # we construct relocated all-in-one init script 36 | echo "#!/bin/busybox sh" > /reloc-init 37 | # we keep this script from next banner to execute beyond that point 38 | sed -n -e '/^#* We start from here !! #*/,$p' /squashfs/berryboot-init >> /reloc-init 39 | # we append the remaining part of inird 40 | sed -n -e '/^.*# Fedora and Arch symlink.*/,$p' /init >> /reloc-init 41 | chmod 770 /reloc-init 42 | 43 | # we need to make sure our new /reloc-init can access insofar variables we (and init) need 44 | export IMAGE 45 | export DATADIR 46 | export SHAREDDIR 47 | export IMAGEPATH 48 | export GOVERNOR 49 | export ENTRYPATH 50 | 51 | echo "Now we will continue from another location... see you soon !!" 52 | exec /reloc-init # exec ensures we keep PID 1, which is required for switch_root 53 | 54 | # now we are gone in hyperspace !!! 55 | 56 | 57 | ###################### We start from here !! ########################### 58 | 59 | BBINITVERSION="1.6" 60 | 61 | BBINITURL="https://bit.ly/BBInitVolumio2" 62 | 63 | 64 | echo " 65 | ###################################################### 66 | ########### Volumio2 Berryboot Integration ########### 67 | ########### version ${BBINITVERSION} by macmpi ########### 68 | " 69 | 70 | 71 | ################ generic log utiliy function ################### 72 | # Display a message and aggregate it for volumio2 journalctl 73 | LOGFILE="/data/V2log.txt" # Volumio2 OS will consume it 74 | 75 | print_msg() { 76 | echo "$1" | tee -a /mnt"${LOGFILE}" 77 | } 78 | 79 | 80 | ########### detect Partitions devices ###################### 81 | 82 | # Actual berryboot boot partition is unknown and not mounted, so it can only be determined 83 | # by reading cmdline.txt. However berryboot install may not set it in default SD setup! 84 | BOOT_PART="" 85 | CMDLINE=$(cat /proc/cmdline) 86 | 87 | for p in ${CMDLINE}; 88 | do 89 | key=${p%%=*} 90 | value=${p#*=} 91 | 92 | case $key in 93 | bootdev) 94 | BOOT_PART=$value 95 | ;; 96 | esac 97 | done 98 | 99 | # sanity-check 100 | BOOT_PART=${BOOT_PART#UUID=} # extract actual UUID out of UUID=XXX if any 101 | 102 | if [ -z "${BOOT_PART}" ]; then 103 | BOOT_PART="/dev/mmcblk0p1" # default berryboot convention 104 | 105 | elif ( ls /dev/disk/by-uuid | grep -q "${BOOT_PART}"$ ); then 106 | BOOT_PART="/dev/disk/by-uuid/"${BOOT_PART} 107 | # fully qualify UUID reference to ensure mounting 108 | 109 | else # check device name & eventually complete if partial 110 | BOOT_PART=$(ls /dev/* | grep "${BOOT_PART}"$) 111 | # can result in empty path if device not found or wrong UUID! 112 | fi 113 | 114 | 115 | if [ -z "${BOOT_PART}" ]; then 116 | echo " 117 | WARNING !!! Something went wrong with bootdev definition: we will 118 | NOT be able to mount boot partition. Edit cmdline.txt to properly 119 | set bootdev= parameter." 120 | sleep 1 121 | fi 122 | 123 | 124 | # Berryboot data partiton (always exists at this point) may not be directly the one specified in 125 | # cmdline.txt by datadev= , namely in case of complex mounts such as encrypted partitions or iSCSI 126 | # so we look at which device corresponds to /mnt currently, as berryboot has completed it's own mounting work here 127 | # in case of encrypted partitions, fstab mount requires mount by UUID, so we always use it 128 | DATA_PART=$(df | egrep "/mnt" | awk '{print $1}') 129 | 130 | print_msg "Partitions found: boot: ${BOOT_PART} berryboot data: ${DATA_PART}" 131 | 132 | ########### Sanity-checks finished ####### 133 | 134 | 135 | 136 | ############################################################# 137 | ############## Volumio Reset & Updates functions ############ 138 | ############################################################# 139 | BOOTMOUNT="/boottemp" # temp /boot mount 140 | mkdir -p "${BOOTMOUNT}" 141 | mount -t vfat -w "${BOOT_PART}" "${BOOTMOUNT}" 142 | 143 | 144 | ################# Reset data section ############################## 145 | # Now we deal with eventual factory reset & al 146 | # currently we do not do factory image save/reload; we just keep previous image 147 | # so factory and user data reset are same 148 | # Note: this has to be very-first as it wipes overlay: NO DATADIR setup stuff before this! 149 | # Follow-up sections should do all initial overlay setup 150 | 151 | # if there is factory or user reset files then format data partition 152 | if [ -e "${BOOTMOUNT}"/factory_reset ] || [ -e "${BOOTMOUNT}"/user_data ]; then 153 | rm "${BOOTMOUNT}"/factory_reset "${BOOTMOUNT}"/user_data > /dev/null 2>&1 154 | rm -rf "${DATADIR}" 155 | print_msg "Factory reset successfully executed" 156 | fi 157 | 158 | 159 | ################# Volumio Updates section ########################## 160 | # Now we setup things so that Volumio2 built-in differential updates work. 161 | # We check if such update has been done previously, in order to replace image. 162 | # Note: after update we relaunch new-image script with it's own script do new own setup 163 | # so we stay away from any significant changes before doing update (do that first after reset) 164 | 165 | BBMOUNT="/berryboot" 166 | 167 | # setting-up /imgpart directory (within overlay) that receives OS updates from Volumio app. 168 | UPDTDIR="${DATADIR}/imgpart" 169 | if [ ! -d "${UPDTDIR}" ]; then 170 | mkdir -p "${UPDTDIR}" 171 | chmod 777 "${UPDTDIR}" 172 | fi 173 | 174 | 175 | # discard eventual kernel updates as Berryboot runs its own kernel 176 | if [ -e "${BOOTMOUNT}"/kernel_update ]; then 177 | rm "${BOOTMOUNT}"/kernel_update 178 | fi 179 | 180 | 181 | # Manage Volumio squash image updates 182 | if [ ! -h "${UPDTDIR}"/volumio_current.sqsh ]; then 183 | if [ -f "${UPDTDIR}"/volumio_current.sqsh ]; then 184 | 185 | # if the update failed before completion 186 | if [ -e "${BOOTMOUNT}"/update_process ]; then 187 | print_msg "Image update attempt failed, keeping current image" 188 | rm "${BOOTMOUNT}"/update_process 189 | else 190 | print_msg "Installing updated image" 191 | cd "${UPDTDIR}" 192 | # we try to get latest patches from network or fallback with existing ones 193 | if ! wget -O berryboot-init "${BBINITURL}" > /dev/null 2>&1; then 194 | cp /squashfs/berryboot-init . 195 | fi 196 | chmod ug+x berryboot-init # needed because we will relaunch with exec command, not inline 197 | print_msg "Patching updated image" 198 | if mksquashfs ./berryboot-init volumio_current.sqsh > /dev/null 2>&1; then 199 | print_msg "Unmounting previous image and replacing with new" 200 | umount -f /squashfs # we are now running from /reloc-init so we should be safe to keep running!... 201 | mv -f volumio_current.sqsh "${IMAGEPATH}" 202 | rm -rf "${UPDTDIR:?}"/* 203 | umount "${BOOTMOUNT}" 204 | rmdir "${BOOTMOUNT}" 205 | sync 206 | clear 207 | print_msg "Mounting Updated image ${IMAGE}" 208 | mount -o loop,ro "${IMAGEPATH}" /squashfs 209 | cd "${ENTRYPATH}" 210 | print_msg "Relaunching with updated image & init..." 211 | exec /squashfs/berryboot-init # exec ensures we keep PID 1 212 | else 213 | print_msg "Patching new image failed, keeping current image" 214 | fi 215 | fi 216 | rm -rf "${UPDTDIR:?}"/* 217 | fi 218 | 219 | # We link Volumio image into /imgpart to (re)enable zsync differential updates again 220 | ln -s "${BBMOUNT}"/images/"${IMAGE}" "${UPDTDIR}"/volumio_current.sqsh # ${BBMOUNT} to be mounted at Volumio startup 221 | print_msg "Ready to accept eventual Volumio2 updates to come..." 222 | fi 223 | 224 | umount "${BOOTMOUNT}" 225 | rmdir "${BOOTMOUNT}" 226 | 227 | 228 | ################################################################## 229 | ############ General config for Volumio2 OS boot ############ 230 | ################################################################## 231 | 232 | 233 | ############ Manage OS mounts ######## 234 | # Remove eventual /boot mount from original fstab 235 | # do it at each squashfs mount, as partiton layout may have changed (image update, cloned setup from another media) 236 | # we do not add /berryboot mounts here because it will fail in case of encrypted Partitions 237 | # will mount within berryboot-integ service 238 | 239 | print_msg "Patching Volumio /etc/fstab to remove original /boot" 240 | mkdir -p "${DATADIR}"/etc 241 | sed '/^\/dev\/.*\/boot.*vfat.*/d' /squashfs/etc/fstab > "${DATADIR}"/etc/fstab 242 | 243 | 244 | ################ berryboot-integ script & systemd service ################################### 245 | # setup berryboot-integ script and related systemd service to launch berryboot-integ at Volumio OS startup 246 | # This allows to mount partitions and issue pre-boot berryboot-phase log into system journal 247 | # We also use it to schedule swap during OS boot as this shall not happen before berryboot partition is mounted 248 | mkdir -p "${DATADIR}"/lib/systemd/system 249 | mkdir -p "${DATADIR}"/etc/systemd/system/multi-user.target.wants 250 | 251 | print_msg "Creating Berryboot integration systemd service for Volumio OS" 252 | 253 | echo "[Unit] 254 | Description = Berryboot integration service 255 | DefaultDependencies=false 256 | 257 | After=network.target 258 | Before=sysinit.target 259 | Before=dynamicswap.service 260 | 261 | [Service] 262 | Type=simple 263 | StandardOutput=syslog 264 | StandardError=syslog 265 | SyslogIdentifier=berryboot-integ 266 | User=root 267 | Group=root 268 | ExecStartPre=/bin/mkdir -p ${BBMOUNT} 269 | ExecStartPre=/bin/mount -o defaults ${DATA_PART} ${BBMOUNT} 270 | ExecStartPre=/bin/mount -t vfat -o defaults,utf8,user,rw,umask=111,dmask=000 ${BOOT_PART} /boot 271 | ExecStart=/bin/sh /.berryboot-integ 272 | 273 | [Install] 274 | WantedBy=multi-user.target" > "${DATADIR}"/lib/systemd/system/berryboot-integ.service 275 | 276 | # Enable Systemd service 277 | ln -s /lib/systemd/system/berryboot-integ.service "${DATADIR}"/etc/systemd/system/multi-user.target.wants/berryboot-integ.service > /dev/null 2>&1 278 | 279 | 280 | # berryboot-integ script is always restored in original state 281 | echo "#!/bin/sh 282 | 283 | ### This file resides in Volumio image overlay filesystem 284 | # It is run as root during Volumio OS image startup through Systemd service. 285 | # As Volumio OS boots from aufs overlayed filesystem, one may modify this file 286 | # but such changes will have not effect at next boot, as file is restored in original state 287 | 288 | # dump early berryboot-init log file into system journal 289 | cat ${BBMOUNT}${LOGFILE} 290 | rm ${BBMOUNT}${LOGFILE} > /dev/null 2>&1 291 | " > "${DATADIR}"/.berryboot-integ 292 | 293 | chmod 774 "${DATADIR}"/.berryboot-integ 294 | 295 | 296 | ########### Swap management ########### 297 | # /berryboot/data/volumio_swapfile will be common to any Volumio2 image running under berryboot 298 | # 299 | # we add a feature: if /noswap file is present, then we disable swap at all 300 | 301 | print_msg "Optimizing swap management" 302 | 303 | # Patch original dynamicswap.service to ensure swap service is started after /berryboot mount 304 | # we only add or change [UNIT] header of service 305 | echo "[Unit] 306 | Description = Berryboot-modded dynamicswap service 307 | DefaultDependencies=false 308 | 309 | Before=swap.target umount.target 310 | Conflicts=umount.target 311 | Wants=swap.target 312 | 313 | After=berryboot-integ.service 314 | ConditionPathExists=${BBMOUNT}/data 315 | " > "${DATADIR}"/lib/systemd/system/dynamicswap.service 316 | sed -n -e '/^\[Service\]/,$p' /squashfs/lib/systemd/system/dynamicswap.service >> "${DATADIR}"/lib/systemd/system/dynamicswap.service 317 | 318 | # Enable Systemd service 319 | ln -s /lib/systemd/system/dynamicswap.service "${DATADIR}"/etc/systemd/system/multi-user.target.wants/dynamicswap.service > /dev/null 2>&1 320 | 321 | 322 | # Patch original /bin/dynswap.sh to relocate swap file and add noswap feature 323 | mkdir -p "${DATADIR}"/bin 324 | if [ -e "${DATADIR}"/noswap ]; then 325 | echo "#!/bin/sh" > "${DATADIR}"/bin/dynswap.sh 326 | else 327 | sed 's/\/\(data\|swap\)\/swapfile/\/'"${BBMOUNT#"/"}"'\/data\/volumio_swapfile/g' /squashfs/bin/dynswap.sh > "${DATADIR}"/bin/dynswap.sh 328 | fi 329 | chmod 774 "${DATADIR}"/bin/dynswap.sh 330 | 331 | 332 | ############ Remove MrEngman-related drivers /etc/modprobe.d/xxx.conf #################### 333 | # 8192cu.conf is in kernel so we keep 334 | # we also keep blacklist-rtl8xxxu.conf blacklist-rtl8192cu.conf as drivers are still unmature 335 | print_msg "Removing MrEngman drivers .conf" 336 | mkdir -p "${DATADIR}"/etc/modprobe.d 337 | touch "${DATADIR}"/etc/modprobe.d/.wh.8188eu.conf 338 | touch "${DATADIR}"/etc/modprobe.d/.wh.8192eu.conf 339 | touch "${DATADIR}"/etc/modprobe.d/.wh.8812au.conf 340 | 341 | 342 | ################ Add installVolumio2 script as bonus ######################### 343 | 344 | if [ ! -x "${DATADIR}"/home/volumio/installVolumio2 ]; then 345 | mkdir -p "${DATADIR}"/home/volumio 346 | chown 1000:1000 "${DATADIR}"/home/volumio 347 | if wget -O "${DATADIR}"/home/volumio/installVolumio2 "${INSTV2URL}" > /dev/null 2>&1; then 348 | chown 1000:1000 "${DATADIR}"/home/volumio/installVolumio2 349 | chmod 744 "${DATADIR}"/home/volumio/installVolumio2 350 | print_msg "Added installVolumio2 script in volumio home directory" 351 | fi 352 | fi 353 | 354 | 355 | 356 | ############################################################# 357 | ############### now some FUN !!!! ############ 358 | ############################################################# 359 | 360 | # hide /berryboot-init file in overlay 361 | touch "${DATADIR}"/.wh.berryboot-init 362 | 363 | cat /squashfs/etc/motd > "${DATADIR}"/etc/motd 364 | cat << "EOF" >> "${DATADIR}"/etc/motd 365 | 366 | /\/\/\/\/\/\ 367 | < > 368 | | | 369 | | | 370 | | _ _ | 371 | -|_ / \/ \_ |- 372 | |I| \_/\_/ |I| Change is good. 373 | -| / \ |- You go first. 374 | | \__/ | 375 | | | 376 | | | 377 | |__________| 378 | /___/\__/\___\ 379 | / | \| \ 380 | /\ |\ | _@|#_ 381 | / /\ | \| | | 382 | \/ / \ / | | 383 | \_/___/ \_/ 384 | 385 | 386 | Reminder: we run under berryboot kernel now... 387 | 388 | EOF 389 | 390 | sync 391 | cd "${ENTRYPATH}" 392 | print_msg "Now we can finally boot Volumio2 image..., go!" 393 | echo "" 394 | 395 | # now we follow into the remaining of berryboot init... 396 | --------------------------------------------------------------------------------