├── Examples ├── Raspbian │ ├── nc-helpers │ │ ├── Raspbian_root.txt │ │ ├── README.md │ │ └── nc-helpers.tar │ ├── AutoMountDataPartition │ │ ├── Raspbian_root.txt │ │ ├── README.md │ │ └── AutoMountDataPartition │ ├── wifi │ │ ├── Raspbian_root.txt │ │ ├── wifi │ │ │ ├── wpa_supplicant.conf │ │ │ └── interfaces │ │ └── README.md │ └── direct-network │ │ ├── direct │ │ ├── network │ │ │ ├── cmdline.txt │ │ │ ├── cmdline.normal │ │ │ ├── cmdline.direct │ │ │ ├── cmdline.internet │ │ │ ├── README.txt │ │ │ ├── switchip.sh │ │ │ ├── WINsetNORM.bat │ │ │ ├── WINsetDirect.bat │ │ │ └── WINsetICS.bat │ │ └── cmdline.txt │ │ ├── Raspbian_boot.txt │ │ └── README.md └── README.md ├── noobsconfig.zip ├── Helpers ├── nc-create-custom-tar ├── nc-create-custom-xz ├── nc-capture-wifi ├── nc-get-label ├── nc-set-wifi └── README.md ├── dev ├── os │ ├── data_partition │ │ └── partition_setup.sh │ ├── Raspbian │ │ └── partition_setup.sh │ ├── Pidora │ │ └── partition_setup.sh │ ├── RaspBMC │ │ └── partition_setup.sh │ ├── Arch │ │ └── partition_setup.sh │ └── OpenELEC │ │ └── partition_setup.sh ├── retro.sh └── customise.sh ├── zeroconf_wifi.md └── README.md /Examples/Raspbian/nc-helpers/Raspbian_root.txt: -------------------------------------------------------------------------------- 1 | nc-helpers.tar 2 | -------------------------------------------------------------------------------- /noobsconfig.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/procount/noobsconfig/HEAD/noobsconfig.zip -------------------------------------------------------------------------------- /Examples/Raspbian/AutoMountDataPartition/Raspbian_root.txt: -------------------------------------------------------------------------------- 1 | #file destinationFolder Attributes user group 2 | AutoMountDataPartition /home/pi +x -------------------------------------------------------------------------------- /Helpers/nc-create-custom-tar: -------------------------------------------------------------------------------- 1 | label=$1 2 | if [ -z "$label" ];then 3 | label=$(nc-get-label) 4 | fi 5 | 6 | sudo tar cvf $label.tar -T $label 7 | -------------------------------------------------------------------------------- /Examples/Raspbian/wifi/Raspbian_root.txt: -------------------------------------------------------------------------------- 1 | wifi/interfaces /etc/network 0644 root root 2 | wifi/wpa_supplicant.conf /etc/wpa_supplicant 0600 root root 3 | -------------------------------------------------------------------------------- /Helpers/nc-create-custom-xz: -------------------------------------------------------------------------------- 1 | label=$1 2 | if [ -z "$label" ];then 3 | label=$(nc-get-label) 4 | fi 5 | 6 | sudo tar cvf $label.tar -T $label 7 | sudo xz $label.tar 8 | -------------------------------------------------------------------------------- /dev/os/data_partition/partition_setup.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | #PWD=/mnt2 = root of 1st FAT partition of OS. 3 | 4 | set -ex 5 | 6 | if [ -e /mnt/customise.sh ]; then /mnt/customise.sh; fi 7 | 8 | -------------------------------------------------------------------------------- /Examples/Raspbian/direct-network/direct/network/cmdline.txt: -------------------------------------------------------------------------------- 1 | dwc_otg.lpm_enable=0 console=ttyAMA0,115200 kgdboc=ttyAMA0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait -------------------------------------------------------------------------------- /Examples/Raspbian/direct-network/direct/network/cmdline.normal: -------------------------------------------------------------------------------- 1 | dwc_otg.lpm_enable=0 console=ttyAMA0,115200 kgdboc=ttyAMA0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait 2 | -------------------------------------------------------------------------------- /Examples/Raspbian/direct-network/direct/cmdline.txt: -------------------------------------------------------------------------------- 1 | dwc_otg.lpm_enable=0 console=ttyAMA0,115200 kgdboc=ttyAMA0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait ip=169.254.0.10 2 | -------------------------------------------------------------------------------- /Examples/Raspbian/wifi/wifi/wpa_supplicant.conf: -------------------------------------------------------------------------------- 1 | ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev 2 | update_config=1 3 | 4 | network={ 5 | ssid="MyNetwork" 6 | psk="MyPassword" 7 | } 8 | -------------------------------------------------------------------------------- /Examples/Raspbian/direct-network/direct/network/cmdline.direct: -------------------------------------------------------------------------------- 1 | dwc_otg.lpm_enable=0 console=ttyAMA0,115200 kgdboc=ttyAMA0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait ip=169.254.0.10 2 | -------------------------------------------------------------------------------- /Examples/Raspbian/direct-network/direct/network/cmdline.internet: -------------------------------------------------------------------------------- 1 | dwc_otg.lpm_enable=0 console=ttyAMA0,115200 kgdboc=ttyAMA0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait ip=192.168.137.10::192.168.137.1 2 | -------------------------------------------------------------------------------- /Examples/Raspbian/direct-network/Raspbian_boot.txt: -------------------------------------------------------------------------------- 1 | direct/cmdline.txt 2 | direct/network/cmdline.direct /network 3 | direct/network/cmdline.internet /network 4 | direct/network/cmdline.normal /network 5 | direct/network/cmdline.txt /network 6 | direct/network/README.txt /network 7 | direct/network/switchip.sh /network 0644 8 | -------------------------------------------------------------------------------- /Helpers/nc-capture-wifi: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if [ -z $1 ]; then 4 | #Create a custom file name from the flavour and partition names 5 | partLabel=$(nc-get-label) 6 | else 7 | #Use the given name 8 | partLabel=$1 9 | fi 10 | 11 | echo "/etc/network/interfaces">>$partLabel 12 | echo "/etc/wpa_supplicant/wpa_supplicant.conf">>$partLabel 13 | 14 | -------------------------------------------------------------------------------- /Examples/Raspbian/wifi/wifi/interfaces: -------------------------------------------------------------------------------- 1 | auto lo 2 | 3 | iface lo inet loopback 4 | iface eth0 inet dhcp 5 | 6 | allow-hotplug wlan0 7 | iface wlan0 inet manual 8 | wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf 9 | iface default inet dhcp 10 | 11 | auto eth0:1 12 | iface eth0:1 inet static 13 | address 169.254.64.64 14 | netmask 255.255.0.0 15 | -------------------------------------------------------------------------------- /Examples/Raspbian/nc-helpers/README.md: -------------------------------------------------------------------------------- 1 | NOOBSConfig - helper scripts 2 | ============================ 3 | This example provides a TAR file containing the helper scripts located and described in the Helpers folder. 4 | 5 | Copying the files in this folder into the /os/Raspbian folder on your NOOBS recovery partition will install the helper scripts into the /usr/local/bin folder of your Raspbian installation, so that they can be used to help make other custom tarballs. 6 | -------------------------------------------------------------------------------- /dev/os/Raspbian/partition_setup.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -ex 4 | 5 | if [ -z "$part1" ] || [ -z "$part2" ]; then 6 | printf "Error: missing environment variable part1 or part2\n" 1>&2 7 | exit 1 8 | fi 9 | 10 | mkdir -p /tmp/1 /tmp/2 11 | 12 | mount "$part1" /tmp/1 13 | mount "$part2" /tmp/2 14 | 15 | if [ -e /mnt/customise.sh ]; then /mnt/customise.sh; fi 16 | 17 | sed /tmp/1/cmdline.txt -i -e "s|root=/dev/[^ ]*|root=${part2}|" 18 | sed /tmp/2/etc/fstab -i -e "s|^.* / |${part2} / |" 19 | sed /tmp/2/etc/fstab -i -e "s|^.* /boot |${part1} /boot |" 20 | 21 | 22 | umount /tmp/1 23 | umount /tmp/2 24 | -------------------------------------------------------------------------------- /Examples/Raspbian/direct-network/direct/network/README.txt: -------------------------------------------------------------------------------- 1 | -------Version 1.0 June2013 2 | -------Created by Tim Cox (meltwater) 3 | -------www.pihardware.com 4 | -------Free to use - must include above details. 5 | -------Modified by ProCount for use with noobsconfig 6 | 7 | The files must be extracted to the Raspberry Pi's SD-Card. 8 | In windows, you should have a single folder on the SD-Card called "network" which will contian the files. 9 | 10 | On the Raspberry Pi, the files should be located at "/boot/network". 11 | 12 | Default direct IP address is 169.254.0.10 13 | 14 | Ensure you update the cmdline.internet file if you intend to use this. -------------------------------------------------------------------------------- /Examples/README.md: -------------------------------------------------------------------------------- 1 | Noobsconfig - Examples 2 | ====================== 3 | The folders below here contain a few examples of how noobsconfig can be used to customise a distro during installation with NOOBS, grouped into distro folders. 4 | 5 | The current examples focus on Raspbian, but I welcome other examples, particularly for the other distros. 6 | 7 | After unzipping the noobsconfig.zip file over your noobs files, copy the examples files you want to use into the appropriate /os/distro folder in noobs according to the individual README.md files. If you want to use several customisations at once, you must merge the Raspbian_root.txt (or Raspbian_boot.txt) files together. 8 | -------------------------------------------------------------------------------- /dev/os/Pidora/partition_setup.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if [[ ${part1} == '' || ${part2} == '' ]]; then 4 | echo "error: part1 and part2 not specified" 5 | exit 1 6 | fi 7 | 8 | # create mount points 9 | mkdir /tmp/1 10 | mkdir /tmp/2 11 | 12 | # mount partitions 13 | mount ${part1} /tmp/1 14 | mount ${part2} /tmp/2 15 | 16 | if [ -e /mnt/customise.sh ]; then /mnt/customise.sh; fi 17 | 18 | # adjust files 19 | sed -ie "s|root=/dev/mmcblk0p[0-9]|root=${part2}|" /tmp/1/cmdline.txt 20 | sed -ie "s|^.* / |${part2} / |" /tmp/2/etc/fstab 21 | sed -ie "s|^.* /boot |${part1} /boot |" /tmp/2/etc/fstab 22 | 23 | # clean up 24 | umount /tmp/1 25 | umount /tmp/2 26 | 27 | 28 | -------------------------------------------------------------------------------- /dev/os/RaspBMC/partition_setup.sh: -------------------------------------------------------------------------------- 1 | #!/bin/ash 2 | 3 | # Let OSIRIS see what we are doing 4 | set -x 5 | # We really don't want automated fscking 6 | tune2fs -c 0 $part2 7 | # Temporary mounting directory 8 | mkdir -p /tmp/mount 9 | 10 | if [ -e /mnt/customise.sh ]; then /mnt/customise.sh; fi 11 | 12 | # Fix the cmdline.txt 13 | mount $part1 /tmp/mount 14 | eval "sed -e s:/dev/mmcblk0p2:$part2: -i /tmp/mount/cmdline.txt" 15 | umount /tmp/mount 16 | # Wait 17 | sync 18 | # Fix the fstab 19 | mount $part2 /tmp/mount 20 | eval "sed -e s:/dev/mmcblk0p1:$part1: -i /tmp/mount/etc/fstab" 21 | eval "sed -e s:/dev/mmcblk0p2:$part2: -i /tmp/mount/etc/fstab" 22 | umount /tmp/mount 23 | # Wait 24 | sync 25 | 26 | 27 | -------------------------------------------------------------------------------- /dev/os/Arch/partition_setup.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # NOOBS partition setup script for Arch Linux ARM 4 | # - part1 == boot partition (FAT), part2 == root partitions (ext4) 5 | # - example usage: 6 | # part1=/dev/mmcblk0p7 part2=/dev/mmcblk0p8 ./partition_setup.sh 7 | 8 | # extract and set part1 and part2 variables 9 | 10 | if [[ ${part1} == '' || ${part2} == '' ]]; then 11 | echo "error: part1 and part2 not specified" 12 | exit 1 13 | fi 14 | 15 | # create mount points 16 | mkdir /tmp/1 17 | mkdir /tmp/2 18 | 19 | # mount partitions 20 | mount ${part1} /tmp/1 21 | mount ${part2} /tmp/2 22 | 23 | if [ -e /mnt/customise.sh ];then /mnt/customise.sh; fi 24 | 25 | # adjust files 26 | sed -ie "s|@ROOT@|${part2}|" /tmp/1/cmdline.txt 27 | sed -ie "s|@BOOT@|${part1}|" /tmp/2/etc/fstab 28 | 29 | # clean up 30 | umount /tmp/1 31 | umount /tmp/2 32 | -------------------------------------------------------------------------------- /Examples/Raspbian/direct-network/direct/network/switchip.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | #Function to swap to Direct IP Address 4 | direct () { sudo cp /boot/network/cmdline.direct /boot/cmdline.txt;} 5 | 6 | #Function to swap to Normal Automatic IP Address 7 | normal () { sudo cp /boot/network/cmdline.normal /boot/cmdline.txt;} 8 | 9 | #Function to swap to Internet IP Address 10 | internet () { sudo cp /boot/network/cmdline.internet /boot/cmdline.txt;} 11 | 12 | # Menu using case-esac 13 | echo "Select IP Address? Use: Direct / ICS / Auto / Keep (d/i/a/k)?" 14 | read answer 15 | case $answer in 16 | d|D) echo "Use Direct IP;direct";; 17 | i|I) echo "Use Internet (ICS) Direct IP";internet;; 18 | a|A) echo "Use Auto IP (normal LAN)";normal;; 19 | *) echo "Keep - No Change";; 20 | esac 21 | 22 | echo cmdline.txt 23 | echo ____________ 24 | cat /boot/cmdline.txt 25 | -------------------------------------------------------------------------------- /Examples/Raspbian/AutoMountDataPartition/README.md: -------------------------------------------------------------------------------- 1 | NOOBSConfig - AutoMountDataPartition script 2 | =========================================== 3 | This example provides a script that can be used to mount the additional Data_Partition created by NOOBS into Raspbian. 4 | 5 | Copying the files in this folder into the /os/Raspbian folder on your NOOBS recovery partition will install the AutoMountDataPartition script into the /home/pi folder of Raspbian. 6 | 7 | Exceute `./AutoMountDataPartition ` in Raspbian to mount the Data_Partition to ``. If `` is not given, it will mount the Data_Partition to `/mnt/DATA` by default. You can optionally specify the filesystem type of the data partion as the 2nd argument. If none is given, it is assumed to be `ext4`. 8 | 9 | The mount is made permanent by updating /etc/fstab, so this script need only be executed once. 10 | -------------------------------------------------------------------------------- /Examples/Raspbian/direct-network/direct/network/WINsetNORM.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | @setlocal enableextensions 3 | @cd /d "%~dp0" 4 | REM -------Version 1.0 June2013 5 | REM -------Created by Tim Cox (meltwater) 6 | REM -------www.pihardware.com 7 | REM -------Free to use - must include above details. 8 | set SOURCE=cmdline.normal 9 | set TARGET=cmdline.txt 10 | set DESC=automatic DHCP 11 | set INFO1=# Connect RPi to DHCP enabled router or similar 12 | set INFO2= 13 | set INFO3= 14 | set IP1=# Use hostname -I on RPi to find IP address allocated 15 | set IP2= 16 | 17 | echo.### Setting Raspberry Pi network to %DESC% ### 18 | echo. 19 | echo.%INFO1% 20 | echo.%INFO2% 21 | echo.%INFO3% 22 | echo. 23 | echo.# Copy %SOURCE% to %TARGET% 24 | copy %SOURCE% ..\%TARGET% 25 | echo. 26 | echo.%IP1% 27 | echo.%IP2% 28 | echo.# Contents of cmdline.txt: 29 | type ..\cmdline.txt 30 | echo. 31 | pause -------------------------------------------------------------------------------- /Examples/Raspbian/direct-network/direct/network/WINsetDirect.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | @setlocal enableextensions 3 | @cd /d "%~dp0" 4 | REM -------Version 1.0 June2013 5 | REM -------Created by Tim Cox (meltwater) 6 | REM -------www.pihardware.com 7 | REM -------Free to use - must include above details. 8 | set SOURCE=cmdline.direct 9 | set TARGET=cmdline.txt 10 | set DESC=direct (PC to RPi) 11 | set INFO1=# Ensure the PC's network adaptor is set to auto/DHCP 12 | set INFO2=# and internet connection sharing (ICS) is disabled. 13 | set INFO3= 14 | set IP1=# See below, ip=x.x.x.x will be the new address of the RPi 15 | 16 | echo.### Setting Raspberry Pi network to %DESC% ### 17 | echo. 18 | echo.%INFO1% 19 | echo.%INFO2% 20 | echo.%INFO3% 21 | echo. 22 | echo.# Copy %SOURCE% to %TARGET% 23 | copy %SOURCE% ..\%TARGET% 24 | echo. 25 | echo.%IP1% 26 | echo.%IP2% 27 | echo.# Contents of cmdline.txt: 28 | type ..\cmdline.txt 29 | echo. 30 | pause -------------------------------------------------------------------------------- /Helpers/nc-get-label: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | #set -x 4 | 5 | #Get the location of the OS images 6 | imagefolder=`sed -n "s/.*\"imagefolder\".*:.*\"\(.*\)\".*/\1/p" tmp/etc/wpa_supplicant/wpa_supplicant.conf<tmp/etc/network/interfaces<tmp/$fname< 4 | 5 | #Mounts the noobs Data_Partition at the folder location given by the first argument. 6 | #If no argument is given, it mounts the data partition at /mnt/DATA 7 | 8 | set -x 9 | 10 | #The partition filesystem is assumed to be ext4. If you want to use a different file system, 11 | #specify the type as the second argument. e.g. 'vfat' or 'auto'. 12 | 13 | #Create a temporary mount point for the noobs settings partition 14 | tmpdir=`sudo mktemp -d /media/settingXXX` 15 | #Mount the NOOBS setting partition 16 | sudo mount /dev/mmcblk0p3 $tmpdir 17 | 18 | #Identify the mountpoint 19 | if [ "$1" ]; then 20 | export MountPoint="$1" 21 | else 22 | export MountPoint="/mnt/DATA" 23 | fi 24 | 25 | #Identify the filesystem 26 | if [ "$2" ]; then 27 | export MyFsType="$2" 28 | else 29 | export MyFsType="ext4" 30 | fi 31 | 32 | #Identify the partition of the Data_Partition 33 | while read line 34 | do 35 | #complicated expression to extract the partition name from installed_os.json 36 | name=`echo $line | sed -n "s/\"name\".*:.*\"\(.*\)\".*/\1\r\n/p" | sed "s/ \+/_/g" | tr -d '\r'` 37 | if [ "$name" ]; then 38 | partname=$name 39 | fi 40 | #Extract any line with 'partitions' in it 41 | name=`echo $line | sed -n "s/\"partitions\"/partitions/p"` 42 | if [ "$name" ]; then 43 | read line 44 | if [ "$partname" = "Data_Partition" ]; then 45 | #Get the 1st partition of the Data_Partition 46 | export data_part=`echo $line | sed -n "s/\"\(.*\)\"/\1/p"` 47 | fi 48 | read line 49 | fi 50 | done <$tmpdir/installed_os.json 51 | 52 | #Remove the SETTINGS mount 53 | sudo umount $tmpdir 54 | sudo rmdir $tmpdir 55 | 56 | #Mount the Data_Partition 57 | if [ "$data_part" ]; then 58 | sudo sh -c "echo '$data_part $MountPoint $MyFsType defaults 0 0'>>/etc/fstab" 59 | sudo mkdir -p "$MountPoint" 60 | sudo mount "$data_part" "$MountPoint" -t "$MyFsType" 61 | fi 62 | 63 | unset data_part 64 | unset MountPoint 65 | unset MyFsType 66 | -------------------------------------------------------------------------------- /dev/os/OpenELEC/partition_setup.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh -x 2 | ################################################################################ 3 | # This file is part of OpenELEC - http://www.openelec.tv 4 | # Copyright (C) 2009-2013 Stephan Raue (stephan@openelec.tv) 5 | # 6 | # This Program is free software; you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation; either version 2, or (at your option) 9 | # any later version. 10 | # 11 | # This Program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with OpenELEC.tv; see the file COPYING. If not, write to 18 | # the Free Software Foundation, 51 Franklin Street, Suite 500, Boston, MA 02110, USA. 19 | # http://www.gnu.org/copyleft/gpl.html 20 | ################################################################################ 21 | 22 | MOUNTPOINT="/tmp/OpenELEC-System" 23 | 24 | md5sumCheck() { 25 | ( cd $MOUNTPOINT 26 | echo "checking MD5: $1" 27 | md5sum -c $1.md5 28 | if [ "$?" = "1" ]; then 29 | echo "######################################################" 30 | echo "# #" 31 | echo "# OpenELEC failed md5 check - Installation will quit #" 32 | echo "# #" 33 | echo "# Your original download was probably corrupt. #" 34 | echo "# Please visit www.openelec.tv and get another copy #" 35 | echo "# #" 36 | echo "######################################################" 37 | exit 1 38 | fi 39 | rm -rf $1.md5 40 | ) 41 | } 42 | 43 | if [ -z $part1 -o -z $part2 -o -z $id1 -o -z $id2]; then 44 | echo "error: part1, part2, id1 or id2 not specified" 45 | echo "actual values:" 46 | echo "part1:" $part1 47 | echo "part2:" $part2 48 | echo "id1 :" $id1 49 | echo "id2 :" $id2 50 | exit 1 51 | fi 52 | 53 | # create mountpoint 54 | mkdir -p $MOUNTPOINT 55 | 56 | # mount needed partition 57 | mount $part1 $MOUNTPOINT 58 | 59 | # check md5sum 60 | md5sumCheck kernel.img 61 | md5sumCheck SYSTEM 62 | 63 | # create bootloader configuration 64 | echo "creating bootloader configuration..." 65 | echo "boot=$id1 disk=$id2 quiet" > $MOUNTPOINT/cmdline.txt 66 | 67 | # cleanup mountpoint 68 | umount $MOUNTPOINT 69 | rmdir $MOUNTPOINT 70 | 71 | if [-e /mnt/customise.sh ]; then /mnt/customise.sh; fi 72 | -------------------------------------------------------------------------------- /Helpers/README.md: -------------------------------------------------------------------------------- 1 | NOOBSConfig - helper scripts 2 | =========== 3 | 4 | ###Introduction### 5 | This folder contains script files to help the user create a customised tarball to be installed with a standard NOOBS installation of Raspbian on a Raspberry Pi. 6 | (They may also work with Arch, Pidora and RaspBMC, but these have not been tested yet) 7 | 8 | I have also included an installation package in the examples\nc-helpers folder to install them with noobsconfig, which may be easier. 9 | 10 | First you should use NOOBS to install the standard installation of Raspbian, then boot into the Raspbian OS. 11 | The files in this repository folder should be copied to the /usr/local/bin directory in Raspbian so that they are available from anywhere. 12 | 13 | * /usr/local/bin/nc-get-label 14 | * /usr/local/bin/nc-set-wifi 15 | * /usr/local/bin/nc-capture-wifi 16 | * /usr/local/bin/nc-create-custom-tar 17 | * /usr/local/bin/nc-create-custom-xz 18 | 19 | You will need to make these executable as follows: 20 | 21 | `cd /usr/local/bin` 22 | `sudo chmod +x nc-*` 23 | 24 | It is probably a good idea to to go back to your /home/pi directory before using these files using: 25 | `$ cd ~` 26 | 27 | ###nc-get-label### 28 | This script file determines the base filename of the tarball to be used, based on the name of OS flavour and partition names installed. 29 | (It assumes the first partition is mapped to /boot). 30 | With no arguments provided, it returns the name for the highest partition number, so `Raspbian_root` for Raspbian. 31 | If you want the name of the tarball that should be used for the first partition, you can use `nc-get-label 1`, or `nc-get-label 2` for the second. 32 | See `nc-set-wifi` for how to use this from within another script. 33 | 34 | ###nc-capture-wifi### 35 | This script is used to capture the network and wifi settings after they have been setup by other means, either manually or using a program such as wpa_gui, wpa_cli etc. 36 | It simply creates a text file containing the names of the files to be captured: 37 | * /etc/network/interfaces 38 | * /etc/wpa_supplicant/wpa_supplicant.conf 39 | 40 | If your configuration requires additional files to be customised, add them manually to the generated text file. 41 | This script uses `nc-get-label` to determine the name of the text file to create. If you want to use another name, just specify it as the first argument, but note that only tarballs with the appropriate name will be installed automatically. 42 | 43 | Note that this script will APPEND data to the text file, without first deleting its contents. This allows it to be used in conjunction with other similar scripts to capture other file names that should be included in your customised OS. 44 | 45 | ###nc-create-custom-tar### 46 | This script will take the list of files specified in a text file, and create a tarball comprising those files. 47 | It uses `nc-get-label` to determine the name of the text file and the name of the resultant tarball (with .tar appended). If you want to use a different name, specify it as the first argument, but note that only tarballs with the appropriate name will be installed automatically. 48 | 49 | This tar file can now be copied to your NOOBS /os/Raspbian directory to be installed during installation of a new copy of the OS. 50 | 51 | ###nc-create-custom-xz### 52 | This script does exactly the same thing as `nc-create-custom-tar`, except it adds an extra step to compress the tarball using the XZ compression algorithm. 53 | The resultant `filename.tar.xz` file can now be copied to your NOOBS /os/Raspbian directory to be installed during installation of a new copy of the OS. 54 | 55 | ###nc-set-wifi### 56 | This is an example of a very simple script to setup the wifi and network configuration of a new installation. 57 | It only supports WPA/WPA2 wifi networks, but it could be easily modified for other types. 58 | On execution of this script it will ask for the wifi network ID (SSID) and the password. It will then create a temporary sample '/etc/network/interfaces' and a `/etc/wpa_supplicant/wpa_supplicant.conf` file. These will be archived into a `Raspbian_root.tar` file (using `nc-get-label`) ready for copying to the NOOBS /os/Raspbian folder. 59 | Again, if you want to use a different name for the tar file, specify it as the 1st argument. But note that only customised tar files with the appropriate name will be installed automatically. 60 | 61 | If you notice some strange settings at the end of `interfaces` relating to eth0:1, these were suggested by @Cymplecy to provide a default wired IP address. If you don't need them they can be safely deleted. -------------------------------------------------------------------------------- /dev/retro.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | #installs a Distro's customisations restrospectively. 4 | #Put customisations on USB stick and mount somewhere 5 | #Only does 1 partition at a time 6 | 7 | #Args: 8 | #$1 = source imagefolder = /usbmount/os/distro 9 | #$2 = destination partition = / or /boot/ 10 | #$3 = flavour_label = name of customisation. 11 | 12 | set -x 13 | 14 | process_file() 15 | { 16 | local arg1="" 17 | local arg2="" 18 | local arg3="" 19 | local arg4="" 20 | local arg5="" 21 | 22 | #Complicated rubbish to process quoted spaced arguments to this function! 23 | local inquote=0 #State of inside/outside quotations 24 | local inarg=0 #State of within an argument 25 | local narg=0 #number of arguments processed 26 | local arg="" #the current argument 27 | 28 | #Treat the arguments as one string and process each character. 29 | #inarg & inquote keep track of the state. 30 | for pos in `seq 1 ${#@}` 31 | do 32 | add=0; 33 | inc=0; 34 | c=`expr substr "$@" $pos 1` 35 | # echo "$c" 36 | case "$c" in 37 | "\"") 38 | inquote=`expr 1 - $inquote` 39 | if [ $inquote -eq 0 ]; then 40 | inc=1 #indicate end of an argument 41 | else 42 | inarg=1; #indicate we have started an argument 43 | fi 44 | ;; 45 | 46 | " ") 47 | if [ $inarg -eq 1 ]; then 48 | if [ $inquote -eq 0 ]; then 49 | inc=1 #indicate end of an argument 50 | else 51 | add=1 #add embedded space to argument 52 | fi 53 | fi 54 | ;; 55 | *) 56 | inarg=1 #indicate we have started an argument 57 | add=1 #add character to argument 58 | ;; 59 | esac 60 | 61 | if [ $add -eq 1 ]; then 62 | arg="$arg$c" #Append the current character 63 | fi 64 | 65 | if [ $inc -eq 1 ]; then 66 | #assign the current argument to the next variable 67 | narg=`expr $narg + 1` 68 | var="arg$narg" 69 | cmd="${var}=\"$arg\"" 70 | eval "$cmd" 71 | inarg=0 72 | arg="" 73 | fi 74 | done 75 | if [ $inarg -eq 1 ]; then 76 | #last incomplete argument needs to be assigned to the next variable 77 | narg=`expr $narg + 1` 78 | var="arg$narg" 79 | cmd="${var}=\"$arg\"" 80 | eval "$cmd" 81 | inarg=0 82 | arg="" 83 | fi 84 | ############ 85 | 86 | #Here we just give the arguments meaningful names 87 | local tarfile="$arg1" 88 | local dstsubfolder="$arg2" 89 | local attributes="$arg3" 90 | local user="$arg4" 91 | local group="$arg5" 92 | 93 | if [ "$dstsubfolder" = "#" ]; then dstsubfolder=""; fi 94 | if [ "$attributes" = "#" ]; then attributes=""; fi 95 | if [ "$user" = '#' ]; then user=""; fi 96 | if [ "$group" = '#' ]; then group=""; fi 97 | 98 | if [ -e "$arg_srcfolder/$tarfile" ]; then 99 | #Copy custom file to the SD card partition root 100 | #cp $arg_srcfolder/$tarfile $arg_dstfolder 101 | #decompress & Untar the custom file 102 | #cd $arg_dstfolder 103 | ext=`echo $tarfile|awk -F . '{print $NF}'` 104 | case "$ext" in 105 | "xz" ) 106 | xz -dc "$arg_srcfolder/$tarfile" | tar x -C "$arg_dstfolder" 107 | ;; 108 | "tar" ) 109 | tar xvf "$arg_srcfolder/$tarfile" -C "$arg_dstfolder" 110 | ;; 111 | * ) 112 | fname=`basename "$tarfile"` 113 | pathname=`dirname "$tarfile"` 114 | mkdir -p "$arg_dstfolder$dstsubfolder" 115 | cp "$arg_srcfolder/$tarfile" "$arg_dstfolder$dstsubfolder/$fname" 116 | if [ "$attributes" != "" ]; then chmod $attributes "$arg_dstfolder$dstsubfolder/$fname"; fi 117 | ug="" 118 | if [ "$user" != "" ]; then ug=$user; else ug=""; fi 119 | if [ "$group" != "" ]; then ug=$ug:$group; fi 120 | if [ "$ug" != "" ]; then chown $ug "$arg_dstfolder$dstsubfolder/$fname"; fi 121 | ;; 122 | esac 123 | fi 124 | } 125 | 126 | custom_part() 127 | { 128 | #parameters 129 | # $1 = srcfolder eg /mnt/os/xxxxx 130 | # $2 = dest folder eg /usbmount 131 | # $3 = imagename eg Flavour_label 132 | local arg_srcfolder=$1 133 | local arg_imagename=$3 134 | local arg_dstfolder=$2 135 | 136 | #Look for a tar file 137 | tarfile=$arg_imagename.tar 138 | process_file "$tarfile" 139 | 140 | #Look for a tar.xz file 141 | tarfile=$tarfile.xz 142 | process_file "$tarfile" 143 | 144 | #Look for a txt file 145 | local txtfile=$arg_imagename.txt 146 | #Does the custom file exist? 147 | if [ -e $arg_srcfolder/$txtfile ]; then 148 | while read line 149 | do 150 | #remove trailing CR 151 | tarfile=`echo $line | tr -d '\r'` 152 | if [ ! -z "$tarfile" ]; then 153 | #remove lines starting with '#' 154 | tarfile=`echo $tarfile | sed '/^#/d'` 155 | fi 156 | if [ ! -z "$tarfile" ]; then 157 | #Only process non-blank lines 158 | process_file "$tarfile" 159 | fi 160 | done<$arg_srcfolder/$txtfile 161 | fi 162 | cd /mnt 163 | 164 | sync 165 | } 166 | 167 | custom_part "$1" "$2" "$3" 168 | 169 | -------------------------------------------------------------------------------- /dev/customise.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -x 4 | 5 | #Get the location of the OS images 6 | imagefolder=`sed -n "s/.*\"imagefolder\".*:.*\"\(.*\)\".*/\1/p" >$partLabel 12 | echo "/etc/wpa_supplicant/wpa_supplicant.conf">>$partLabel 13 | 14 | nc-create-custom-tar0000755000000000000620000000014012314410406013555 0ustar rootstafflabel=$1 15 | if [ -z "$label" ];then 16 | label=$(nc-get-label) 17 | fi 18 | 19 | sudo tar cvf $label.tar -T $label 20 | nc-create-custom-xz0000755000000000000620000000016312314410406013435 0ustar rootstafflabel=$1 21 | if [ -z "$label" ];then 22 | label=$(nc-get-label) 23 | fi 24 | 25 | sudo tar cvf $label.tar -T $label 26 | sudo xz $label.tar 27 | nc-get-label0000755000000000000620000000147412263131704012071 0ustar rootstaff#!/bin/sh 28 | 29 | #set -x 30 | 31 | #Get the location of the OS images 32 | imagefolder=`sed -n "s/.*\"imagefolder\".*:.*\"\(.*\)\".*/\1/p" tmp/etc/wpa_supplicant/wpa_supplicant.conf<tmp/etc/network/interfaces<tmp/$fname< 87 | Arch_boot 88 | Arch_root 89 | Data_Partition_data 90 | OpenELEC_Storage 91 | OpenELEC_System 92 | Pidora_boot 93 | Pidora_rootfs 94 | Raspbian_boot 95 | Raspbian_root 96 | Raspbian_-_Boot_to_Scratch_boot 97 | Raspbian_-_Boot_to_Scratch_root 98 | RaspBMC_boot 99 | RaspBMC_root 100 | 101 | 102 | If a file is found with the appropriate base filename above and one of the following extensions, then the following actions are carried out: 103 | A filename ending in `.tar` is untarred onto the appropriate partition. 104 | A filename ending in `.tar.xz` is decompressed, and untarred onto the appropriate partition. 105 | 106 | So to add/replace some custom files on your distro, you just need to create a tar ball with the correct name, optionally compress it using XZ, drop it into the distro folder and install the distro as usual - simples! Some helper scripts are provided to help create these tarballs (see the Helpers folder). 107 | 108 | (A filename with the appropriate basename ending in `.txt` is processed according to the Advanced Customisation section described below.) 109 | 110 | If you add any other distros, flavours or OS partition names, you need to name the custom files according to the filename format above and add the following line to the partition_setup.sh script for that distro: 111 | `if [ -e /mnt/customise.sh ]; then . /mnt/customise.sh; fi` 112 | This technique can also be used on the data partition - just create a partition_setup.sh file containing just this line. However, it is not really necessary as you could more easily just replace the original data.tar.xz file with your own, since it only contains a README.txt file. 113 | 114 | ### How to Create a Custom Tarball 115 | 116 | These instructions assume you already have a working installation of a distro on the RPi and you want to capture the customisations you have made for future installations of the same distro. 117 | 118 | 1. Firstly you need to start from a working installation of the distro. I suggest you use NOOBS to install the distro first. 119 | 2. Modify any existing, or create any new files that you want to be included in your customisation. 120 | 3. For manageability I suggest creating a simple text file that contains a list of all the new/modified files that you want, with one fullpathname on each line. 121 | For example: 122 | 123 | ```$>sudo nano files.txt
124 | /etc/network/interfaces 125 | /etc/init.d/rc.local 126 | ``` 127 | 128 | 4. Now create the tar ball using this text file as input, as follows: 129 | 130 | ```$>sudo tar cvf <flavour>_<partitionName>.tar -T files.txt 131 | $>sudo xz <flavour>_<partitionName>.tar 132 | ``` 133 | 134 | (See the Helpers folder for alternative ways to do this using scripts). 135 | 5. Copy the tarball to the appropriate OS folder. 136 | 137 | ### Advanced Customisation 138 | Sometimes, you may want to have greater control over your customisations. Maybe you want to: 139 | * segregate them into separate tar files for distinct uses. 140 | * give them better names according to their use. 141 | * have easier control over which ones should be installed. 142 | * share files between different flavours of the same distro. 143 | * provide raw files that are not tarred or compressed, e.g. by direct copying on to the recovery partition using Windows. 144 | For these and other uses, the (flavour)_(partitionName).txt file can be useful. 145 | 146 | This text file contains a list of files (one per line) to be installed to the distro AFTER the above `.tar` or `.tar.xz` files have been installed. In this way some tweaks can be applied to existing .tar files without having to modify/rebuild them. 147 | 148 | The text file is processed a line at a time to extract the filenames to be processed. 149 | Any filename ending in `.tar` is untarred to the root of the partition. 150 | Any filename ending in `.tar.xz` is decompressed and then untarred to the root of the partition. 151 | Any other filename is copied directly to the partition. 152 | 153 | NOTE: If you are already using a `(flavour)_(partitionName).tar(.xz)` file, you should NOT specify it in this text file as well, otherwise it would be installed twice. 154 | 155 | If you are directly copying files, you may need to provide additional information in the form of optional fields on the same line. 156 | 157 | There are five fields as follows (separated by spaces): 158 | 159 | Filename destination attributes user group 160 | 161 | Only the filename field is mandatory and it is the only field used for TAR and XZ files; the others can be omitted and default values will then be applied. If you want to omit a field but follow it with another field, then use a '#' instead to keep the relative placement of the fields. 162 | 163 | Blank lines will be ignored. 164 | Comments can be added by starting the line with a '#' in the first column, or adding the comment after field 5. 165 | 166 | Here are some examples to illustrate this: 167 | * Readme.txt 168 | * Readme.txt # 0644 169 | * nc-helpers.tar 170 | * wifi/interfaces /etc/network 0644 root root 171 | * wifi/wpa_supplicant.conf /etc/wpa_supplicant 0600 root root 172 | 173 | (The last 2 examples above show how using this direct copy technique, it is possible to specify the '/etc/network/interfaces' and '/etc/wpa_supplicant/wpa_supplicant.conf' files for easy wifi setup from Windows, whilst specifying the correct attributes and avoiding the problem of creating Tar files from Windows.) 174 | 175 | #### Filename 176 | This is the name of the file you want to copy from the recovery partition. 177 | It can be stored in the /os/distro folder, or any subfolder. If you put it in a subfolder then this must be specified. 178 | e.g. 179 | To copy the file `/os/Raspbian/readme.txt`, use `readme.txt` 180 | To copy the file `/os/Raspbian/folder/readme.txt`, use `folder/readme.txt` 181 | The folder name is only used to locate the source file. It is not used as part of the destination folder. 182 | This field is mandatory. 183 | 184 | If you need to include a filename that has embedded spaces in it, then you must enclose it in double quotation marks: 185 | e.g. 186 | * "my wifi/interfaces" /etc/network 0644 root root 187 | 188 | #### Destination 189 | This is the name of the destination folder where the file is to be stored on the target partition, relative to the root. E.g. `/home/pi`. It must begin with a slash, but have no trailing slash. 190 | This field is optional. If not specified, then the root directory is used. 191 | If you need to include a destination pathname that includes embedded spaces,then enclose this in double quotations. 192 | 193 | #### Attributes 194 | This specifies the attributes to be applied to the new file using the chmod command. e.g. `0644`. I guess options such as `+x` would also work but I've not tried. 195 | 196 | #### User 197 | This specifies the new user of the file e.g. `pi` or `root` etc. 198 | 199 | #### Group 200 | This specifies the new group of the file e.g. `root` 201 | 202 | ### Selecting a Method of customisation 203 | It can be confusing to decide which type of customisation to use, so here is a short guide. 204 | * TAR files are very convenient when there are many related files to be installed, possibly in different folders, and where file permissions or ownership are important. They capture the contents, ownership and permissions of each file into a single TAR file which is then easily managed. So they are best created directly on an existing distro on the RPi. Not so many compression programs allow you to create a TAR file on Windows (7-zip can), but nevertheless, the file permissions and attributes cannot be set. Plain TAR files are not compressed and append 2 blocks of 512 bytes at the end. So the minimum size of a TAR file is 10kB. This can be quite an overhead if you only want to install a couple of small script files. 205 | * TAR.XZ files are TAR files that have been compressed using the XZ program. They therefore retain the advantages of the TAR file's manageability, but also avoid the TAR file's largish size. It is best to compress them on the RPi, but it can be done on another Linux distro, but not so easily on Windows. 206 | * If you want to create your customisation on Windows, referencing files from the TXT file may be the easiest method. This does not provide any compression, nor does it collect the separate files into one single file for manageability. However, it does provide control of user permissions and ownership. This is also a convenient method if you only want to install 1 or 2 small files. If you are creating script files on Windows, be careful to choose Linux line endings. Some editing programs, like Notepad++ allow you to visualise the line endings and change them from Windows to Linux and vice versa. 207 | 208 | ## Testing & Retrospective customisation 209 | 210 | Since noobsconfig executes after NOOBS has installed a distro, it can be a lengthy process to test any customisations as they are developed, because each test potentially means installing a distro and waiting to see the result. Also, if you already have a Raspbian distro installed by noobs, then you probably don't want to have to overwrite it all just to test your scripts. Or maybe you have created a new 'flavour' to install your customisations and you want to install them onto your existing distro that was installed as another flavour. 211 | 212 | There is a script called `retro.sh` that is placed on the root of the recovery partition to aid testing, or to apply a customisation retrospectively, i.e. after a distro has already been installed by NOOBS. 213 | 214 | The purpose of `retro.sh` is to apply a set of customisations from the recovery partition to the currently installed distro, after that distro has been installed and is now executing. It works on a partition at a time, so if your distro has 2 partitions that you want to customise, you need to run it once for each partition. It requires a bit of work to setup the environment first, and a few arguments to tell it what it does, but these are easily captured into a script. 215 | 216 | The main thing that needs to be done is to mount the recovery partition so that it is accessible. Also note that the installation has to be done by the root user (or using sudo) since it may need to (over)write system files. 217 | 218 | ### retro.sh 219 | Usage: sudo ./retro.sh [source folder] [destination folder] [(flavour)_(partitionName)] 220 | Example1: sudo ./retro.sh /mnt/os/Raspbian / Raspbian_root 221 | Example2: sudo ./retro.sh /mnt/os/Raspbian /boot/ Raspbian_boot 222 | 223 | ### Example use of retro.sh 224 | Here is an example script file that automates the retrospective installation or testing of a Raspbian customisation. 225 | 226 | #!/bin/sh 227 | # Make sure only root can run our script 228 | if [ "$(id -u)" != "0" ]; then 229 | echo "This script must be run as root" 1>&2 230 | exit 1 231 | fi 232 | 233 | #Mount the recovery partition 234 | mount /dev/mmcblk0p1 /mnt 235 | cdir=`pwd` 236 | cd /mnt 237 | #Install the customisations 238 | ./retro.sh /mnt/os/Raspbian /boot/ RaspbianMyFlavour_boot 239 | ./retro.sh /mnt/os/Raspbian / RaspbianMyFlavour_root 240 | #Restore 241 | cd $cdir 242 | sync 243 | sleep 1 244 | umount /mnt 245 | echo "Customisation done." 246 | 247 | ## Further Examples 248 | You will find some examples of how to apply some configurations to Raspbian in the Examples/Raspbian folder. 249 | Please see zeroconf_wifi.md for a very quick setup of a WPA/WPA2 wifi network. 250 | I welcome other examples, particularly for the other Linux distros. 251 | --------------------------------------------------------------------------------