2022-01-13 20:56:30 +01:00
#!/usr/bin/env bash
2021-12-14 23:34:35 +01:00
2019-01-27 11:03:07 +01:00
#########################################################################
2022-05-05 10:59:50 +02:00
# Build your SD card image based on: 2022-04-04-raspios-bullseye-arm64.img.xz
2023-07-08 15:31:39 +02:00
# https://downloads.raspberrypi.org/raspios_arm64/images/raspios_arm64-2023-05-03/
# SHA256: e7c0c89db32d457298fbe93195e9d11e3e6b4eb9e0683a7beb1598ea39a0a7aa
2021-12-14 23:34:35 +01:00
# PGP fingerprint: 8738CD6B956F460C
# PGP key: https://www.raspberrypi.org/raspberrypi_downloads.gpg.key
2019-06-04 11:01:52 +02:00
# setup fresh SD card with image above - login per SSH and run this script:
2019-01-27 11:03:07 +01:00
##########################################################################
2023-07-08 19:38:08 +02:00
defaultRepo = "raspiblitz" #user that hosts a `raspiblitz` repo
defaultBranch = "v1.10"
2021-03-09 16:23:19 +01:00
2022-12-16 00:19:12 +01:00
defaultAPIuser = "fusion44"
defaultAPIrepo = "blitz_api"
defaultWEBUIuser = "cstenglein"
defaultWEBUIrepo = "raspiblitz-web"
2022-01-11 14:39:15 +01:00
me = " ${ 0 ##/* } "
nocolor = "\033[0m"
red = "\033[31m"
## usage as a function to be called whenever there is a huge mistake on the options
usage( ) {
printf %s" ${ me } [--option <argument>]
Options:
2022-12-22 00:38:44 +01:00
-EXPORT just print build parameters & exit'
2022-01-11 14:39:15 +01:00
-h, --help this help info
-i, --interaction [ 0| 1] interaction before proceeding with exection ( default: 1)
-f, --fatpack [ 0| 1] fatpack mode ( default: 1)
-u, --github-user [ rootzoll| other] github user to be checked from the repo ( default: ${ defaultRepo } )
-b, --branch [ v1.7| v1.8] branch to be built on ( default: ${ defaultBranch } )
-d, --display [ lcd| hdmi| headless] display class ( default: lcd)
-t, --tweak-boot-drive [ 0| 1] tweak boot drives ( default: 1)
-w, --wifi-region [ off| US| GB| other] wifi iso code ( default: US) or 'off'
Notes:
all options, long and short accept --opt= value mode also
[ 0| 1] can also be referenced as [ false| true]
"
2021-04-09 16:09:57 +02:00
exit 1
2022-01-11 14:39:15 +01:00
}
if [ " $1 " = "-h" ] || [ " $1 " = "--help" ] ; then
usage
2021-04-09 16:09:57 +02:00
fi
2023-05-03 17:21:44 +02:00
# check if started with sudo
2023-07-08 14:58:00 +02:00
if [ " $EUID " -ne 0 ] ; then
2023-05-03 17:21:44 +02:00
echo "error='run as root / may use sudo'"
exit 1
fi
2022-12-22 00:38:44 +01:00
if [ " $1 " = "-EXPORT" ] || [ " $1 " = "EXPORT" ] ; then
cd /home/admin/raspiblitz 2>/dev/null
activeBranch = $( git rev-parse --abbrev-ref HEAD 2>/dev/null)
if [ " ${ activeBranch } " = = "" ] ; then
activeBranch = " ${ defaultBranch } "
fi
echo " githubUser=' ${ defaultRepo } ' "
echo " githubBranch=' ${ activeBranch } ' "
echo " defaultAPIuser=' ${ defaultAPIuser } ' "
echo " defaultAPIrepo=' ${ defaultAPIrepo } ' "
echo " defaultWEBUIuser=' ${ defaultWEBUIuser } ' "
echo " defaultWEBUIrepo=' ${ defaultWEBUIrepo } ' "
exit 0
fi
2022-01-11 14:39:15 +01:00
## default user message
error_msg( ) { printf %s" ${ red } ${ me } : ${ 1 } ${ nocolor } \n " ; exit 1; }
## assign_value variable_name "${opt}"
## it strips the dashes and assign the clean value to the variable
## assign_value status --on IS status=on
## variable_name is the name you want it to have
## $opt being options with single or double dashes that don't require arguments
assign_value( ) {
case " ${ 2 } " in
--*) value = " ${ 2 #-- } " ; ;
-*) value = " ${ 2 #- } " ; ;
*) value = " ${ 2 } "
esac
2022-01-26 00:26:50 +01:00
case " ${ value } " in
0) value = "false" ; ;
1) value = "true" ; ;
esac
2022-01-11 14:39:15 +01:00
## Escaping quotes is needed because else if will fail if the argument is quoted
# shellcheck disable=SC2140
eval " ${ 1 } " = " \" ${ value } \" "
}
## get_arg variable_name "${opt}" "${arg}"
## get_arg service --service ssh
## variable_name is the name you want it to have
## $opt being options with single or double dashes
## $arg is requiring and argument, else it fails
## assign_value "${1}" "${3}" means it is assining the argument ($3) to the variable_name ($1)
get_arg( ) {
case " ${ 3 } " in
"" | -*) error_msg " Option ' ${ 2 } ' requires an argument. " ; ;
esac
assign_value " ${ 1 } " " ${ 3 } "
}
## hacky getopts
## 1. if the option requires argument, and the option is preceeded by single or double dash and it
## can be it can be specified with '-s=ssh' or '-s ssh' or '--service=ssh' or '--service ssh'
## use: get_arg variable_name "${opt}" "${arg}"
## 2. if a bunch of options that does different things are to be assigned to the same variable
## and the option is preceeded by single or double dash use: assign_value variable_name "${opt}"
## as this option does not require argument, specifu $shift_n=1
## 3. if the option does not start with dash and does not require argument, assign to command manually.
while :; do
case " ${ 1 } " in
-*= *) opt = " ${ 1 %=* } " ; arg = " ${ 1 #*= } " ; shift_n = 1; ;
-*) opt = " ${ 1 } " ; arg = " ${ 2 } " ; shift_n = 2; ;
*) opt = " ${ 1 } " ; arg = " ${ 2 } " ; shift_n = 1; ;
esac
case " ${ opt } " in
-i| -i= *| --interaction| --interaction= *) get_arg interaction " ${ opt } " " ${ arg } " ; ;
-f| -f= *| --fatpack| --fatpack= *) get_arg fatpack " ${ opt } " " ${ arg } " ; ;
-u| -u= *| --github-user| --github-user= *) get_arg github_user " ${ opt } " " ${ arg } " ; ;
-b| -b= *| --branch| --branch= *) get_arg branch " ${ opt } " " ${ arg } " ; ;
-d| -d= *| --display| --display= *) get_arg display " ${ opt } " " ${ arg } " ; ;
-t| -t= *| --tweak-boot-drive| --tweak-boot-drive= *) get_arg tweak_boot_drive " ${ opt } " " ${ arg } " ; ;
-w| -w= *| --wifi-region| --wifi-region= *) get_arg wifi_region " ${ opt } " " ${ arg } " ; ;
"" ) break; ;
*) error_msg " Invalid option: ${ opt } " ; ;
esac
shift " ${ shift_n } "
done
## if there is a limited option, check if the value of variable is within this range
## $ range_argument variable_name possible_value_1 possible_value_2
range_argument( ) {
name = " ${ 1 } "
eval var = '$' " ${ 1 } "
shift
if [ -n " ${ var :- } " ] ; then
success = 0
for tests in " ${ @ } " ; do
[ " ${ var } " = " ${ tests } " ] && success = 1
done
[ ${ success } -ne 1 ] && error_msg " Option '-- ${ name } ' cannot be ' ${ var } '! It can only be: ${ * } . "
fi
}
2023-07-08 14:58:00 +02:00
apt_install( ) {
for package in " $@ " ; do
apt install -y -q " $package "
2022-05-17 19:13:13 +02:00
if [ $? -eq 100 ] ; then
2023-07-08 14:58:00 +02:00
echo " FAIL! apt failed to install package: $package "
exit 1
2022-05-17 19:13:13 +02:00
fi
2023-07-08 14:58:00 +02:00
done
2022-05-17 19:13:13 +02:00
}
2022-01-14 20:52:21 +01:00
general_utils = "curl"
2022-01-26 00:26:50 +01:00
## loop all general_utils to see if program is installed (placed on PATH) and if not, add to the list of commands to be installed
for prog in ${ general_utils } ; do
! command -v ${ prog } >/dev/null && general_utils_install = " ${ general_utils_install } ${ prog } "
done
## if any of the required programs are not installed, update and if successfull, install packages
if [ -n " ${ general_utils_install } " ] ; then
echo -e "\n*** SOFTWARE UPDATE ***"
2023-05-03 17:21:44 +02:00
apt update -y || exit 1
2022-05-17 19:13:13 +02:00
apt_install ${ general_utils_install }
2022-01-26 00:26:50 +01:00
fi
2022-01-14 20:52:21 +01:00
2022-01-11 14:39:15 +01:00
## use default values for variables if empty
# INTERACTION
# ----------------------------------------
# When 'false' then no questions will be asked on building .. so it can be used in build scripts
# for containers or as part of other build scripts (default is true)
: " ${ interaction : =true } "
range_argument interaction "0" "1" "false" "true"
# FATPACK
2021-03-09 16:23:19 +01:00
# -------------------------------
2022-01-26 00:26:50 +01:00
# could be 'true' (default) or 'false'
2021-03-09 16:23:19 +01:00
# When 'true' it will pre-install needed frameworks for additional apps and features
# as a convenience to safe on install and update time for additional apps.
# When 'false' it will just install the bare minimum and additional apps will just
# install needed frameworks and libraries on demand when activated by user.
# Use 'false' if you want to run your node without: go, dot-net, nodejs, docker, ...
2022-01-11 14:39:15 +01:00
: " ${ fatpack : =true } "
range_argument fatpack "0" "1" "false" "true"
2018-12-22 13:57:49 +01:00
2022-01-11 14:39:15 +01:00
# GITHUB-USERNAME
2021-03-09 16:23:19 +01:00
# ---------------------------------------
# could be any valid github-user that has a fork of the raspiblitz repo - 'rootzoll' is default
2022-01-11 14:39:15 +01:00
# The 'raspiblitz' repo of this user is used to provisioning sd card with raspiblitz assets/scripts later on.
: " ${ github_user : = $defaultRepo } "
2022-12-16 11:12:56 +01:00
curl --header "X-GitHub-Api-Version:2022-11-28" -s " https://api.github.com/repos/ ${ github_user } /raspiblitz " | grep -q "\"message\": \"Not Found\"" && error_msg " Repository 'raspiblitz' not found for user ' ${ github_user } "
2021-03-09 16:23:19 +01:00
2022-01-11 14:39:15 +01:00
# GITHUB-BRANCH
2021-03-09 16:23:19 +01:00
# -------------------------------------
2021-12-14 23:34:35 +01:00
# could be any valid branch or tag of the given GITHUB-USERNAME forked raspiblitz repo
2022-01-11 14:39:15 +01:00
: " ${ branch : = $defaultBranch } "
2022-12-16 11:12:56 +01:00
curl --header "X-GitHub-Api-Version:2022-11-28" -s " https://api.github.com/repos/ ${ github_user } /raspiblitz/branches/ ${ branch } " | grep -q "\"message\": \"Branch not found\"" && error_msg " Repository 'raspiblitz' for user ' ${ github_user } ' does not contain branch ' ${ branch } ' "
2020-06-21 23:47:26 +02:00
2022-01-11 14:39:15 +01:00
# DISPLAY-CLASS
2021-03-09 16:23:19 +01:00
# ----------------------------------------
2021-09-09 18:24:49 +02:00
# Could be 'hdmi', 'headless' or 'lcd' (lcd is default)
2022-01-11 14:39:15 +01:00
: " ${ display : =lcd } "
range_argument display "lcd" "hdmi" "headless"
2020-06-21 23:47:26 +02:00
2022-01-11 14:39:15 +01:00
# TWEAK-BOOTDRIVE
2021-03-09 16:23:19 +01:00
# ---------------------------------------
# could be 'true' (default) or 'false'
# If 'true' it will try (based on the base OS) to optimize the boot drive.
# If 'false' this will skipped.
2022-01-11 14:39:15 +01:00
: " ${ tweak_boot_drive : =true } "
range_argument tweak_boot_drive "0" "1" "false" "true"
# WIFI
2021-03-09 16:23:19 +01:00
# ---------------------------------------
2022-01-11 14:39:15 +01:00
# WIFI country code like 'US' (default)
2021-03-09 16:23:19 +01:00
# If any valid wifi country code Wifi will be activated with that country code by default
2022-01-11 14:39:15 +01:00
: " ${ wifi_region : =US } "
echo "*****************************************"
echo "* RASPIBLITZ SD CARD IMAGE SETUP *"
echo "*****************************************"
echo "For details on optional parameters - call with '--help' or check source code."
2022-01-26 00:26:50 +01:00
# output
2022-01-11 14:39:15 +01:00
for key in interaction fatpack github_user branch display tweak_boot_drive wifi_region; do
eval val = '$' " ${ key } "
[ -n " ${ val } " ] && printf '%s\n' " ${ key } = ${ val } "
done
2020-06-21 23:47:26 +02:00
2021-03-15 23:16:27 +01:00
# AUTO-DETECTION: CPU-ARCHITECTURE
# ---------------------------------------
2022-01-11 14:39:15 +01:00
cpu = " $( uname -m) " && echo " cpu= ${ cpu } "
architecture = " $( dpkg --print-architecture 2>/dev/null) " && echo " architecture= ${ architecture } "
2021-12-14 23:34:35 +01:00
case " ${ cpu } " in
arm*| aarch64| x86_64| amd64) ; ;
2022-07-18 22:07:14 +02:00
*) echo -e " # FAIL #\nCan only build on ARM, aarch64, x86_64 not on: cpu= ${ cpu } " ; exit 1; ;
2021-12-14 23:34:35 +01:00
esac
2018-10-13 22:43:07 +02:00
2021-03-15 23:16:27 +01:00
# AUTO-DETECTION: OPERATINGSYSTEM
# ---------------------------------------
2022-01-11 14:39:15 +01:00
if [ $( cat /etc/os-release 2>/dev/null | grep -c 'Debian' ) -gt 0 ] ; then
Add automated image builds for VM, bare metal (amd64) and RPi (arm64-rpi) (#3486)
* add amd64 image build with lean and fatpack option
* use the pi user for setup
* add notes to ci readme
* add gnome desktop to fatpack image, reduce to 30GB
* documentation updates
* install gnome with --force-yes
* install gnome desktop non-interactively
* change links to rootzoll dev
* pass user and branch to build_sdcard.sh from PR
* add user and branch to Makefile
* Add arm64 rpi image build (#74)
ci:
* add arm64-rpi image build
* rename to raspiblitz-amd64-debian-11.5-lean/fatpack
* use rm -f to not exit with error
* place amd64 images under ci/amd64/builds/
* make /dev/shm world writable for fatpack
* fix vlc remove and --var syntax
* remove sudo-s
* leave update and upgrade to the build_sdcard.sh
* increase image size to 16GB, rename build dir
build_sdcard.sh:
* detect raspios_arm64 with raspi.list
* switch ssmtp to msmtp
related: https://github.com/rootzoll/raspiblitz/pull/2232
Co-authored-by: rootzoll <johndoe@example.com>
* i2pd: unified install from repo, /usr/sbin to PATH
related: #2413, fixes amd64 build
* update CHANGES.md
* fix amd64 path in Makefile
* use only qemu image, run on ubuntu-22.04
* use file_checksum for the arm64-rpi base image
* Fix the local arm64-rpi image generation (#75)
* add selfrun script
* ubuntu: add universe repo and qemu-user-static
* test on ubuntu live (jammy)
* build from branches: [ "dev", "v1.8", "v1.9" ]
* correct Makefile paths for the local run
* make the local run non-interactive
* improve readme and Makefile
* increase disk image sizes to 32GB
* set image sizes to 30 GB for amd64 and arm64-rpi
* add network-manager for amd64
* add to readme
* skip Code&Compile for VM builds
* add to readme
* amd64 base image update to debian 11.6.0
* remove debian version from filenames
* skip Code&Compile for amd64 builds
* Merge branch 'dev' into add-amd64-image-build
* amd64: increase cpu and RAM, compile mempool last
* trigger workflows only on scripts used or called
* Update ci/arm64-rpi/packer.build.arm64-rpi.sh
Co-authored-by: Daniel Bast <2790401+dbast@users.noreply.github.com>
* arm64 remove setup-qemu-action, leave npm last
* set only manual trigger for fatpack, edit triggers
Co-authored-by: rootzoll <johndoe@example.com>
Co-authored-by: Daniel Bast <2790401+dbast@users.noreply.github.com>
2022-12-20 15:31:51 +01:00
if [ -f /etc/apt/sources.list.d/raspi.list ] && [ " ${ cpu } " = aarch64 ] ; then
2021-12-14 23:34:35 +01:00
# default image for RaspberryPi
2021-04-03 12:24:50 +02:00
baseimage = "raspios_arm64"
2021-03-09 09:37:19 +01:00
else
2023-07-08 14:58:00 +02:00
# experimental: fallback for all to debian
2021-04-03 12:24:50 +02:00
baseimage = "debian"
2021-03-09 09:37:19 +01:00
fi
2022-01-11 14:39:15 +01:00
elif [ $( cat /etc/os-release 2>/dev/null | grep -c 'Ubuntu' ) -gt 0 ] ; then
2021-04-03 12:24:50 +02:00
baseimage = "ubuntu"
2021-12-14 23:34:35 +01:00
else
2022-07-18 22:07:14 +02:00
echo "\n# FAIL: Base Image cannot be detected or is not supported."
2018-10-13 22:43:07 +02:00
cat /etc/os-release 2>/dev/null
2021-12-14 23:34:35 +01:00
uname -a
2018-10-13 22:43:07 +02:00
exit 1
2021-03-15 23:16:27 +01:00
fi
2022-01-11 14:39:15 +01:00
echo " baseimage= ${ baseimage } "
2021-03-15 23:16:27 +01:00
# USER-CONFIRMATION
2022-01-11 14:39:15 +01:00
if [ " ${ interaction } " = "true" ] ; then
2021-12-14 23:34:35 +01:00
echo -n "# Do you agree with all parameters above? (yes/no) "
read -r installRaspiblitzAnswer
[ " $installRaspiblitzAnswer " != "yes" ] && exit 1
2021-03-15 23:16:27 +01:00
fi
2021-12-14 23:34:35 +01:00
echo -e "Building RaspiBlitz ...\n"
sleep 3 ## give time to cancel
2021-03-15 23:16:27 +01:00
2021-12-14 23:34:35 +01:00
export DEBIAN_FRONTEND = noninteractive
2021-03-15 23:16:27 +01:00
2023-02-03 19:38:20 +01:00
echo "*** Prevent sleep ***" # on all platforms https://wiki.debian.org/Suspend
2023-05-03 17:21:44 +02:00
systemctl mask sleep.target suspend.target hibernate.target hybrid-sleep.target
mkdir /etc/systemd/sleep.conf.d
2023-02-03 19:38:20 +01:00
echo " [Sleep]
AllowSuspend = no
AllowHibernation = no
AllowSuspendThenHibernate = no
2023-05-03 17:21:44 +02:00
AllowHybridSleep = no" | tee /etc/systemd/sleep.conf.d/nosuspend.conf
mkdir /etc/systemd/logind.conf.d
2023-02-03 19:38:20 +01:00
echo " [Login]
HandleLidSwitch = ignore
2023-05-03 17:21:44 +02:00
HandleLidSwitchDocked = ignore" | tee /etc/systemd/logind.conf.d/nosuspend.conf
2022-09-29 21:04:39 +02:00
2021-03-15 23:16:27 +01:00
# FIXING LOCALES
# https://github.com/rootzoll/raspiblitz/issues/138
# https://daker.me/2014/10/how-to-fix-perl-warning-setting-locale-failed-in-raspbian.html
# https://stackoverflow.com/questions/38188762/generate-all-locales-in-a-docker-image
2023-07-08 14:58:00 +02:00
if [ " ${ baseimage } " = "raspios_arm64" ] || [ " ${ baseimage } " = "debian" ] ; then
2021-12-14 23:34:35 +01:00
echo -e "\n*** FIXING LOCALES FOR BUILD ***"
2019-08-07 23:11:45 +02:00
2023-05-03 17:21:44 +02:00
sed -i "s/^# en_US.UTF-8 UTF-8.*/en_US.UTF-8 UTF-8/g" /etc/locale.gen
sed -i "s/^# en_US ISO-8859-1.*/en_US ISO-8859-1/g" /etc/locale.gen
locale-gen
2020-01-20 20:37:30 +01:00
export LANGUAGE = en_US.UTF-8
export LANG = en_US.UTF-8
2021-03-09 09:37:19 +01:00
if [ ! -f /etc/apt/sources.list.d/raspi.list ] ; then
echo "# Add the archive.raspberrypi.org/debian/ to the sources.list"
2023-05-03 17:21:44 +02:00
echo "deb http://archive.raspberrypi.org/debian/ bullseye main" | tee /etc/apt/sources.list.d/raspi.list
2021-03-09 09:37:19 +01:00
fi
2019-04-14 12:08:18 +02:00
fi
2018-12-01 22:33:18 +01:00
2021-12-14 23:34:35 +01:00
echo "*** Remove unnecessary packages ***"
2023-05-03 17:21:44 +02:00
apt remove --purge -y libreoffice* oracle-java* chromium-browser nuscratch scratch sonic-pi plymouth python2 vlc* cups
apt clean -y
apt autoremove -y
2019-11-27 08:49:11 +01:00
2021-12-14 23:34:35 +01:00
echo -e "\n*** UPDATE Debian***"
2023-05-03 17:21:44 +02:00
apt update -y
apt upgrade -f -y
2021-08-19 18:52:12 +02:00
2021-12-14 23:34:35 +01:00
echo -e "\n*** SOFTWARE UPDATE ***"
2021-12-23 14:57:38 +01:00
# based on https://raspibolt.org/system-configuration.html#system-update
2021-12-14 23:34:35 +01:00
# htop git curl bash-completion vim jq dphys-swapfile bsdmainutils -> helpers
# autossh telnet vnstat -> network tools bandwidth monitoring for future statistics
2023-07-08 14:58:00 +02:00
# parted dosfstools -> prepare for format data drive
2021-12-14 23:34:35 +01:00
# btrfs-progs -> prepare for BTRFS data drive raid
# fbi -> prepare for display graphics mode. https://github.com/rootzoll/raspiblitz/pull/334
# sysbench -> prepare for powertest
# build-essential -> check for build dependencies on Ubuntu, Armbian
# dialog -> dialog bc python3-dialog
# rsync -> is needed to copy from HDD
# net-tools -> ifconfig
# xxd -> display hex codes
2023-07-08 14:51:11 +02:00
# netcat-openbsd -> for proxy
2021-12-14 23:34:35 +01:00
# openssh-client openssh-sftp-server sshpass -> install OpenSSH client + server
# psmisc -> install killall, fuser
# ufw -> firewall
# sqlite3 -> database
2022-09-29 21:00:39 +02:00
# fdisk -> create partitions
2022-07-18 22:14:30 +02:00
# lsb-release -> needed to know which distro version we're running to add APT sources
2023-07-08 14:58:00 +02:00
general_utils = "policykit-1 htop git curl bash-completion vim jq dphys-swapfile bsdmainutils autossh telnet vnstat parted dosfstools fbi sysbench build-essential dialog bc python3-dialog unzip whois fdisk lsb-release smartmontools"
# add btrfs-progs if not bookworm on aarch64
[ " ${ architecture } " = "aarch64" ] && ! grep "12 (bookworm)" < /etc/os-release && general_utils = " ${ general_utils } btrfs-progs "
2022-11-21 21:15:18 +01:00
# python3-mako --> https://github.com/rootzoll/raspiblitz/issues/3441
python_dependencies = "python3-venv python3-dev python3-wheel python3-jinja2 python3-pip python3-mako"
2023-07-08 14:51:11 +02:00
server_utils = "rsync net-tools xxd netcat-openbsd openssh-client openssh-sftp-server sshpass psmisc ufw sqlite3"
2021-12-14 23:34:35 +01:00
[ " ${ baseimage } " = "armbian" ] && armbian_dependencies = "armbian-config" # add armbian-config
Add automated image builds for VM, bare metal (amd64) and RPi (arm64-rpi) (#3486)
* add amd64 image build with lean and fatpack option
* use the pi user for setup
* add notes to ci readme
* add gnome desktop to fatpack image, reduce to 30GB
* documentation updates
* install gnome with --force-yes
* install gnome desktop non-interactively
* change links to rootzoll dev
* pass user and branch to build_sdcard.sh from PR
* add user and branch to Makefile
* Add arm64 rpi image build (#74)
ci:
* add arm64-rpi image build
* rename to raspiblitz-amd64-debian-11.5-lean/fatpack
* use rm -f to not exit with error
* place amd64 images under ci/amd64/builds/
* make /dev/shm world writable for fatpack
* fix vlc remove and --var syntax
* remove sudo-s
* leave update and upgrade to the build_sdcard.sh
* increase image size to 16GB, rename build dir
build_sdcard.sh:
* detect raspios_arm64 with raspi.list
* switch ssmtp to msmtp
related: https://github.com/rootzoll/raspiblitz/pull/2232
Co-authored-by: rootzoll <johndoe@example.com>
* i2pd: unified install from repo, /usr/sbin to PATH
related: #2413, fixes amd64 build
* update CHANGES.md
* fix amd64 path in Makefile
* use only qemu image, run on ubuntu-22.04
* use file_checksum for the arm64-rpi base image
* Fix the local arm64-rpi image generation (#75)
* add selfrun script
* ubuntu: add universe repo and qemu-user-static
* test on ubuntu live (jammy)
* build from branches: [ "dev", "v1.8", "v1.9" ]
* correct Makefile paths for the local run
* make the local run non-interactive
* improve readme and Makefile
* increase disk image sizes to 32GB
* set image sizes to 30 GB for amd64 and arm64-rpi
* add network-manager for amd64
* add to readme
* skip Code&Compile for VM builds
* add to readme
* amd64 base image update to debian 11.6.0
* remove debian version from filenames
* skip Code&Compile for amd64 builds
* Merge branch 'dev' into add-amd64-image-build
* amd64: increase cpu and RAM, compile mempool last
* trigger workflows only on scripts used or called
* Update ci/arm64-rpi/packer.build.arm64-rpi.sh
Co-authored-by: Daniel Bast <2790401+dbast@users.noreply.github.com>
* arm64 remove setup-qemu-action, leave npm last
* set only manual trigger for fatpack, edit triggers
Co-authored-by: rootzoll <johndoe@example.com>
Co-authored-by: Daniel Bast <2790401+dbast@users.noreply.github.com>
2022-12-20 15:31:51 +01:00
[ " ${ architecture } " = "amd64" ] && amd64_dependencies = "network-manager" # add amd64 dependency
2023-07-08 14:58:00 +02:00
apt_install ${ general_utils } ${ python_dependencies } ${ server_utils } ${ amd64_dependencies }
2023-05-03 17:21:44 +02:00
apt clean -y
apt autoremove -y
2021-12-14 23:34:35 +01:00
echo -e "\n*** Python DEFAULT libs & dependencies ***"
2023-07-08 14:51:11 +02:00
if [ -f "/usr/bin/python3.11" ] ; then
# use python 3.11 if available
update-alternatives --install /usr/bin/python python /usr/bin/python3.11 1
2023-07-08 14:58:00 +02:00
# keep python backwards compatible
2023-07-08 14:51:11 +02:00
ln -s /usr/bin/python3.11 /usr/bin/python3.9
ln -s /usr/bin/python3.11 /usr/bin/python3.10
2023-07-08 14:58:00 +02:00
echo "python calls python3.11"
2021-12-14 23:34:35 +01:00
elif [ -f "/usr/bin/python3.10" ] ; then
# use python 3.10 if available
2023-05-03 17:21:44 +02:00
update-alternatives --install /usr/bin/python python /usr/bin/python3.10 1
2023-07-08 14:58:00 +02:00
# keep python backwards compatible
2023-05-03 17:21:44 +02:00
ln -s /usr/bin/python3.10 /usr/bin/python3.9
2021-12-14 23:34:35 +01:00
echo "python calls python3.10"
2023-07-08 14:51:11 +02:00
elif [ -f "/usr/bin/python3.9" ] ; then
# use python 3.9 if available
update-alternatives --install /usr/bin/python python /usr/bin/python3.9 1
echo "python calls python3.9"
2022-03-09 22:31:19 +01:00
elif [ -f "/usr/bin/python3.8" ] ; then
# use python 3.8 if available
2023-05-03 17:21:44 +02:00
update-alternatives --install /usr/bin/python python /usr/bin/python3.8 1
2022-03-09 22:31:19 +01:00
echo "python calls python3.8"
2020-06-04 10:54:01 +02:00
else
2022-07-18 22:07:14 +02:00
echo "# FAIL #"
2020-06-04 10:54:01 +02:00
echo "There is no tested version of python present"
exit 1
fi
2019-11-27 08:49:11 +01:00
2022-12-10 00:04:15 +01:00
# make sure /usr/bin/pip exists (and calls pip3 in Debian Buster)
2023-05-03 17:21:44 +02:00
update-alternatives --install /usr/bin/pip pip /usr/bin/pip3 1
2022-12-10 00:04:15 +01:00
# 1. libs (for global python scripts)
# grpcio==1.42.0 googleapis-common-protos==1.53.0 toml==0.10.2 j2cli==0.3.10 requests[socks]==2.21.0
# 2. For TorBox bridges python scripts (pip3) https://github.com/radio24/TorBox/blob/master/requirements.txt
# pytesseract mechanize PySocks urwid Pillow requests
# 3. Nyx
# setuptools
sudo -H python3 -m pip install --upgrade pip
sudo -H python3 -m pip install grpcio = = 1.42.0 googleapis-common-protos= = 1.53.0 toml = = 0.10.2 j2cli = = 0.3.10 requests[ socks] = = 2.21.0 protobuf = = 3.20.1 pathlib2 = = 2.3.7.post1
sudo -H python3 -m pip install pytesseract mechanize PySocks urwid Pillow requests setuptools
2021-12-14 23:34:35 +01:00
echo -e " \n*** PREPARE ${ baseimage } *** "
2019-04-14 12:08:18 +02:00
2021-03-09 09:37:19 +01:00
# make sure the pi user is present
2021-12-14 23:34:35 +01:00
if [ " $( compgen -u | grep -c pi) " -eq 0 ] ; then
2021-03-09 09:37:19 +01:00
echo "# Adding the user pi"
2023-05-03 17:21:44 +02:00
adduser --disabled-password --gecos "" pi
adduser pi sudo
2018-10-13 22:43:07 +02:00
fi
# special prepare when Raspbian
2023-07-08 14:58:00 +02:00
if [ " ${ baseimage } " = "raspios_arm64" ] || [ " ${ architecture } " = "aarch64" ] && [ " ${ baseimage } " = "debian" ] ; then
2022-10-05 00:42:47 +02:00
echo -e "\n*** PREPARE RASPBERRY OS VARIANTS ***"
2022-05-17 19:13:13 +02:00
apt_install raspi-config
2018-10-13 22:43:07 +02:00
# do memory split (16MB)
2023-05-03 17:21:44 +02:00
raspi-config nonint do_memory_split 16
2018-10-13 22:43:07 +02:00
# set to wait until network is available on boot (0 seems to yes)
2023-05-03 17:21:44 +02:00
raspi-config nonint do_boot_wait 0
2018-10-19 15:35:38 +02:00
# set WIFI country so boot does not block
2021-12-14 23:34:35 +01:00
# this will undo the softblock of rfkill on RaspiOS
2023-05-03 17:21:44 +02:00
[ " ${ wifi_region } " != "off" ] && raspi-config nonint do_wifi_country $wifi_region
2019-03-14 13:14:04 +01:00
# see https://github.com/rootzoll/raspiblitz/issues/428#issuecomment-472822840
2020-06-22 18:55:30 +02:00
configFile = "/boot/config.txt"
max_usb_current = "max_usb_current=1"
2021-03-23 14:03:03 +01:00
max_usb_currentDone = $( grep -c " $max_usb_current " $configFile )
2020-06-22 18:55:30 +02:00
if [ ${ max_usb_currentDone } -eq 0 ] ; then
2023-05-03 17:21:44 +02:00
echo | tee -a $configFile
echo "# Raspiblitz" | tee -a $configFile
echo " $max_usb_current " | tee -a $configFile
2020-06-22 18:55:30 +02:00
else
echo " $max_usb_current already in $configFile "
fi
2020-07-16 15:20:33 +02:00
# run fsck on sd root partition on every startup to prevent "maintenance login" screen
2019-12-12 13:12:51 +01:00
# see: https://github.com/rootzoll/raspiblitz/issues/782#issuecomment-564981630
2020-03-19 06:57:12 +01:00
# see https://github.com/rootzoll/raspiblitz/issues/1053#issuecomment-600878695
2023-05-03 17:21:44 +02:00
# use command to check last fsck check: tune2fs -l /dev/mmcblk0p2
2022-01-11 14:39:15 +01:00
if [ " ${ tweak_boot_drive } " = = "true" ] ; then
2021-03-15 23:16:27 +01:00
echo "* running tune2fs"
2023-05-03 17:21:44 +02:00
tune2fs -c 1 /dev/mmcblk0p2
2021-03-09 16:23:19 +01:00
else
2022-01-11 14:39:15 +01:00
echo "* skipping tweak_boot_drive"
2021-03-09 16:23:19 +01:00
fi
2020-06-21 23:47:26 +02:00
# edit kernel parameters
kernelOptionsFile = /boot/cmdline.txt
fsOption1 = "fsck.mode=force"
fsOption2 = "fsck.repair=yes"
2021-03-23 14:03:03 +01:00
fsOption1InFile = $( grep -c ${ fsOption1 } ${ kernelOptionsFile } )
fsOption2InFile = $( grep -c ${ fsOption2 } ${ kernelOptionsFile } )
2020-06-21 23:47:26 +02:00
if [ ${ fsOption1InFile } -eq 0 ] ; then
2023-05-03 17:21:44 +02:00
sed -i " s/^/ $fsOption1 /g " " $kernelOptionsFile "
2021-03-09 09:37:19 +01:00
echo " $fsOption1 added to $kernelOptionsFile "
2020-06-22 18:55:30 +02:00
else
2021-03-09 09:37:19 +01:00
echo " $fsOption1 already in $kernelOptionsFile "
2020-06-21 23:47:26 +02:00
fi
if [ ${ fsOption2InFile } -eq 0 ] ; then
2023-05-03 17:21:44 +02:00
sed -i " s/^/ $fsOption2 /g " " $kernelOptionsFile "
2021-03-09 09:37:19 +01:00
echo " $fsOption2 added to $kernelOptionsFile "
2020-06-22 18:55:30 +02:00
else
2021-03-09 09:37:19 +01:00
echo " $fsOption2 already in $kernelOptionsFile "
2020-06-21 23:47:26 +02:00
fi
2019-04-14 12:08:18 +02:00
fi
2019-10-06 12:57:48 +02:00
# special prepare when Nvidia Jetson Nano
2021-12-07 15:00:44 +01:00
if [ $( uname -a | grep -c 'tegra' ) -gt 0 ] ; then
2021-08-19 16:04:13 +02:00
echo "Nvidia --> disable GUI on boot"
2023-05-03 17:21:44 +02:00
systemctl set-default multi-user.target
2019-05-19 16:25:47 +02:00
fi
2021-12-14 23:34:35 +01:00
echo -e "\n*** CONFIG ***"
2021-11-11 15:53:16 +01:00
# based on https://raspibolt.github.io/raspibolt/raspibolt_20_pi.html#raspi-config
2018-08-06 01:03:17 +02:00
2020-06-21 23:47:26 +02:00
# set new default password for root user
2023-05-03 17:21:44 +02:00
echo "root:raspiblitz" | chpasswd
echo "pi:raspiblitz" | chpasswd
2018-08-06 01:03:17 +02:00
2021-04-09 16:09:57 +02:00
# prepare auto-start of 00infoLCD.sh script on pi user login (just kicks in if auto-login of pi is activated in HDMI or LCD mode)
2023-07-08 14:58:00 +02:00
if [ " ${ baseimage } " = "raspios_arm64" ] || [ " ${ baseimage } " = "debian" ] || [ " ${ baseimage } " = "ubuntu" ] ; then
2021-04-09 16:09:57 +02:00
homeFile = /home/pi/.bashrc
autostartDone = $( grep -c "automatic start the LCD" $homeFile )
if [ ${ autostartDone } -eq 0 ] ; then
# bash autostart for pi
# run as exec to dont allow easy physical access by keyboard
# see https://github.com/rootzoll/raspiblitz/issues/54
2023-05-03 17:21:44 +02:00
bash -c 'echo "# automatic start the LCD info loop" >> /home/pi/.bashrc'
bash -c 'echo "SCRIPT=/home/admin/00infoLCD.sh" >> /home/pi/.bashrc'
bash -c 'echo "# replace shell with script => logout when exiting script" >> /home/pi/.bashrc'
bash -c 'echo "exec \$SCRIPT" >> /home/pi/.bashrc'
2021-04-09 16:09:57 +02:00
echo " autostart LCD added to $homeFile "
2021-04-08 00:02:57 +02:00
else
2021-04-09 16:09:57 +02:00
echo " autostart LCD already in $homeFile "
fi
2021-04-08 00:02:57 +02:00
else
2021-04-09 16:09:57 +02:00
echo " WARN: Script Autostart not available for baseimage( ${ baseimage } ) - may just run on 'headless' "
2019-04-14 12:08:18 +02:00
fi
2022-01-27 18:39:32 +01:00
# limit journald system use
2023-05-03 17:21:44 +02:00
sed -i "s/^#SystemMaxUse=.*/SystemMaxUse=250M/g" /etc/systemd/journald.conf
sed -i "s/^#SystemMaxFileSize=.*/SystemMaxFileSize=50M/g" /etc/systemd/journald.conf
2022-01-27 18:39:32 +01:00
2019-03-13 17:00:44 +01:00
# change log rotates
# see https://github.com/rootzoll/raspiblitz/issues/394#issuecomment-471535483
2021-12-14 23:34:35 +01:00
echo "
/var/log/syslog
{
2023-02-03 19:38:20 +01:00
rotate 7
daily
missingok
notifempty
delaycompress
2021-12-14 23:34:35 +01:00
compress
postrotate
invoke-rc.d rsyslog rotate > /dev/null
endscript
}
/var/log/mail.info
/var/log/mail.warn
/var/log/mail.err
/var/log/mail.log
/var/log/daemon.log
{
rotate 4
size = 100M
missingok
notifempty
compress
delaycompress
sharedscripts
postrotate
invoke-rc.d rsyslog rotate > /dev/null
2023-02-03 19:38:20 +01:00
endscript
2021-12-14 23:34:35 +01:00
}
/var/log/kern.log
/var/log/auth.log
{
2023-02-03 19:38:20 +01:00
rotate 4
size = 100M
missingok
notifempty
compress
delaycompress
sharedscripts
postrotate
invoke-rc.d rsyslog rotate > /dev/null
endscript
2021-12-14 23:34:35 +01:00
}
/var/log/user.log
/var/log/lpr.log
/var/log/cron.log
/var/log/debug
/var/log/messages
{
2023-02-03 19:38:20 +01:00
rotate 4
weekly
missingok
notifempty
compress
delaycompress
sharedscripts
postrotate
invoke-rc.d rsyslog rotate > /dev/null
endscript
2021-12-14 23:34:35 +01:00
}
2023-05-03 17:21:44 +02:00
" | tee ./rsyslog
mv ./rsyslog /etc/logrotate.d/rsyslog
chown root:root /etc/logrotate.d/rsyslog
service rsyslog restart
2019-03-13 17:00:44 +01:00
2021-12-14 23:34:35 +01:00
echo -e "\n*** ADDING MAIN USER admin ***"
2021-12-23 14:57:38 +01:00
# based on https://raspibolt.org/system-configuration.html#add-users
2018-08-06 01:03:17 +02:00
# using the default password 'raspiblitz'
2023-05-03 17:21:44 +02:00
adduser --disabled-password --gecos "" admin
echo "admin:raspiblitz" | chpasswd
adduser admin sudo
chsh admin -s /bin/bash
2018-08-06 01:03:17 +02:00
# configure sudo for usage without password entry
2018-08-06 21:33:16 +02:00
echo '%sudo ALL=(ALL) NOPASSWD:ALL' | sudo EDITOR = 'tee -a' visudo
2021-12-14 23:34:35 +01:00
# check if group "admin" was created
if [ $( sudo cat /etc/group | grep -c "^admin" ) -lt 1 ] ; then
echo -e "\nMissing group admin - creating it ..."
2023-05-03 17:21:44 +02:00
/usr/sbin/groupadd --force --gid 1002 admin
usermod -a -G admin admin
2021-12-14 23:34:35 +01:00
else
echo -e "\nOK group admin exists"
fi
2018-08-06 01:03:17 +02:00
2021-12-14 23:34:35 +01:00
echo -e "\n*** ADDING SERVICE USER bitcoin"
2022-05-17 22:39:33 +02:00
# based on https://raspibolt.org/guide/raspberry-pi/system-configuration.html
2018-08-06 01:03:17 +02:00
# create user and set default password for user
2023-05-03 17:21:44 +02:00
adduser --disabled-password --gecos "" bitcoin
echo "bitcoin:raspiblitz" | chpasswd
2021-12-07 15:00:44 +01:00
# make home directory readable
2023-05-03 17:21:44 +02:00
chmod 755 /home/bitcoin
2018-08-06 01:03:17 +02:00
2021-12-14 23:34:35 +01:00
# WRITE BASIC raspiblitz.info to sdcard
# if further info gets added .. make sure to keep that on: blitz.preparerelease.sh
2023-05-03 17:21:44 +02:00
touch /home/admin/raspiblitz.info
2021-12-14 23:34:35 +01:00
echo " baseimage= ${ baseimage } " | tee raspiblitz.info
echo " cpu= ${ cpu } " | tee -a raspiblitz.info
echo "displayClass=headless" | tee -a raspiblitz.info
2023-05-03 17:21:44 +02:00
mv raspiblitz.info /home/admin/
chmod 755 /home/admin/raspiblitz.info
chown admin:admin /home/admin/raspiblitz.info
2021-12-14 23:34:35 +01:00
echo -e "\n*** ADDING GROUPS FOR CREDENTIALS STORE ***"
2020-04-28 19:59:52 +02:00
# access to credentials (e.g. macaroon files) in a central location is managed with unix groups and permissions
2023-05-03 17:21:44 +02:00
/usr/sbin/groupadd --force --gid 9700 lndadmin
/usr/sbin/groupadd --force --gid 9701 lndinvoice
/usr/sbin/groupadd --force --gid 9702 lndreadonly
/usr/sbin/groupadd --force --gid 9703 lndinvoices
/usr/sbin/groupadd --force --gid 9704 lndchainnotifier
/usr/sbin/groupadd --force --gid 9705 lndsigner
/usr/sbin/groupadd --force --gid 9706 lndwalletkit
/usr/sbin/groupadd --force --gid 9707 lndrouter
2020-04-28 19:59:52 +02:00
2021-12-14 23:34:35 +01:00
echo -e "\n*** SHELL SCRIPTS & ASSETS ***"
2021-04-03 12:24:50 +02:00
# copy raspiblitz repo from github
2021-12-07 15:00:44 +01:00
cd /home/admin/ || exit 1
2022-01-11 14:39:15 +01:00
sudo -u admin git config --global user.name " ${ github_user } "
2021-04-03 12:24:50 +02:00
sudo -u admin git config --global user.email "johndoe@example.com"
2021-12-14 23:34:35 +01:00
sudo -u admin rm -rf /home/admin/raspiblitz
2022-01-11 14:39:15 +01:00
sudo -u admin git clone -b " ${ branch } " https://github.com/${ github_user } /raspiblitz.git
2021-12-14 23:34:35 +01:00
sudo -u admin cp -r /home/admin/raspiblitz/home.admin/*.* /home/admin
2021-11-30 16:27:20 +01:00
sudo -u admin cp /home/admin/raspiblitz/home.admin/.tmux.conf /home/admin
2021-12-14 23:34:35 +01:00
sudo -u admin cp -r /home/admin/raspiblitz/home.admin/assets /home/admin/
sudo -u admin chmod +x *.sh
2021-03-15 23:16:27 +01:00
sudo -u admin cp -r /home/admin/raspiblitz/home.admin/config.scripts /home/admin/
2021-12-14 23:34:35 +01:00
sudo -u admin chmod +x /home/admin/config.scripts/*.sh
2021-11-30 16:27:20 +01:00
sudo -u admin cp -r /home/admin/raspiblitz/home.admin/setup.scripts /home/admin/
2021-12-14 23:34:35 +01:00
sudo -u admin chmod +x /home/admin/setup.scripts/*.sh
2021-03-15 23:16:27 +01:00
# install newest version of BlitzPy
2021-12-14 23:34:35 +01:00
blitzpy_wheel = $( ls -tR /home/admin/raspiblitz/home.admin/BlitzPy/dist | grep -E "any.whl" | tail -n 1)
blitzpy_version = $( echo " ${ blitzpy_wheel } " | grep -oE "([0-9]\.[0-9]\.[0-9])" )
echo -e " \n*** INSTALLING BlitzPy Version: ${ blitzpy_version } *** "
sudo -H /usr/bin/python -m pip install " /home/admin/raspiblitz/home.admin/BlitzPy/dist/ ${ blitzpy_wheel } " >/dev/null 2>& 1
2021-03-15 23:16:27 +01:00
# make sure lndlibs are patched for compatibility for both Python2 and Python3
2022-01-04 20:08:38 +01:00
file = "/home/admin/config.scripts/lndlibs/lightning_pb2_grpc.py"
2021-12-14 23:34:35 +01:00
! grep -Fxq "from __future__ import absolute_import" " ${ file } " && sed -i -E '1 a from __future__ import absolute_import' " ${ file } "
! grep -Eq "^from . import.*" " ${ file } " && sed -i -E 's/^(import.*_pb2)/from . \1/' " ${ file } "
2021-03-15 23:16:27 +01:00
# add /sbin to path for all
2023-05-03 17:21:44 +02:00
bash -c "echo 'PATH=\$PATH:/sbin' >> /etc/profile"
2021-03-15 23:16:27 +01:00
2021-09-06 16:44:12 +02:00
# replace boot splash image when raspbian
2023-05-03 17:21:44 +02:00
[ -d /usr/share/plymouth ] && [ " ${ baseimage } " = "raspios_arm64" ] && { echo "* replacing boot splash" ; cp /home/admin/raspiblitz/pictures/splash.png /usr/share/plymouth/themes/pix/splash.png; }
2021-03-15 23:16:27 +01:00
2021-12-14 23:34:35 +01:00
echo -e "\n*** RASPIBLITZ EXTRAS ***"
2021-03-15 23:16:27 +01:00
2021-12-14 23:34:35 +01:00
# screen for background processes
# tmux for multiple (detachable/background) sessions when using SSH https://github.com/rootzoll/raspiblitz/issues/990
# fzf install a command-line fuzzy finder (https://github.com/junegunn/fzf)
2022-05-17 19:13:13 +02:00
apt_install tmux screen fzf
2021-12-08 17:04:30 +01:00
2023-05-03 17:21:44 +02:00
bash -c "echo '' >> /home/admin/.bashrc"
bash -c "echo '# https://github.com/rootzoll/raspiblitz/issues/1784' >> /home/admin/.bashrc"
bash -c "echo 'NG_CLI_ANALYTICS=ci' >> /home/admin/.bashrc"
2021-12-08 17:04:30 +01:00
2021-12-09 18:15:25 +01:00
# raspiblitz custom command prompt #2400
if ! grep -Eq "^[[:space:]]*PS1.*â‚¿" /home/admin/.bashrc; then
2023-05-03 17:21:44 +02:00
sed -i '/^unset color_prompt force_color_prompt$/i # raspiblitz custom command prompt https://github.com/rootzoll/raspiblitz/issues/2400' /home/admin/.bashrc
sed -i '/^unset color_prompt force_color_prompt$/i raspiIp=$(hostname -I | cut -d " " -f1)' /home/admin/.bashrc
sed -i '/^unset color_prompt force_color_prompt$/i if [ "$color_prompt" = yes ]; then' /home/admin/.bashrc
sed -i '/^unset color_prompt force_color_prompt$/i \ PS1=\x27${debian_chroot:+($debian_chroot)}\\[\\033[00;33m\\]\\u@$raspiIp:\\[\\033[00;34m\\]\\w\\[\\033[01;35m\\]$(__git_ps1 "(%s)") \\[\\033[01;33m\\]â‚¿\\[\\033[00m\\] \x27' /home/admin/.bashrc
sed -i '/^unset color_prompt force_color_prompt$/i else' /home/admin/.bashrc
sed -i '/^unset color_prompt force_color_prompt$/i \ PS1=\x27${debian_chroot:+($debian_chroot)}\\u@$raspiIp:\\wâ‚¿ \x27' /home/admin/.bashrc
sed -i '/^unset color_prompt force_color_prompt$/i fi' /home/admin/.bashrc
2021-12-09 18:15:25 +01:00
fi
2021-12-14 23:34:35 +01:00
echo -e "\n*** FUZZY FINDER KEY BINDINGS ***"
2021-12-08 17:04:30 +01:00
homeFile = /home/admin/.bashrc
2021-12-14 23:34:35 +01:00
keyBindingsDone = $( grep -c "source /usr/share/doc/fzf/examples/key-bindings.bash" $homeFile )
2021-12-08 17:04:30 +01:00
if [ ${ keyBindingsDone } -eq 0 ] ; then
2023-05-03 17:21:44 +02:00
bash -c "echo 'source /usr/share/doc/fzf/examples/key-bindings.bash' >> /home/admin/.bashrc"
2021-12-08 17:04:30 +01:00
echo " key-bindings added to $homeFile "
else
echo " key-bindings already in $homeFile "
fi
2021-12-14 23:34:35 +01:00
echo -e "\n*** AUTOSTART ADMIN SSH MENUS ***"
2021-12-08 17:04:30 +01:00
homeFile = /home/admin/.bashrc
2021-12-14 23:34:35 +01:00
autostartDone = $( grep -c "automatically start main menu" $homeFile )
2021-12-08 17:04:30 +01:00
if [ ${ autostartDone } -eq 0 ] ; then
# bash autostart for admin
2023-05-03 17:21:44 +02:00
bash -c "echo '# shortcut commands' >> /home/admin/.bashrc"
bash -c "echo 'source /home/admin/_commands.sh' >> /home/admin/.bashrc"
bash -c "echo '# automatically start main menu for admin unless' >> /home/admin/.bashrc"
bash -c "echo '# when running in a tmux session' >> /home/admin/.bashrc"
bash -c "echo 'if [ -z \"\$TMUX\" ]; then' >> /home/admin/.bashrc"
bash -c "echo ' ./00raspiblitz.sh newsshsession' >> /home/admin/.bashrc"
bash -c "echo 'fi' >> /home/admin/.bashrc"
2021-12-08 17:04:30 +01:00
echo " autostart added to $homeFile "
else
echo " autostart already in $homeFile "
fi
2021-12-14 23:34:35 +01:00
echo -e "\n*** SWAP FILE ***"
# based on https://stadicus.github.io/RaspiBolt/raspibolt_20_pi.html#move-swap-file
2021-12-08 17:04:30 +01:00
# but just deactivating and deleting old (will be created alter when user adds HDD)
2023-05-03 17:21:44 +02:00
dphys-swapfile swapoff
dphys-swapfile uninstall
2021-12-08 17:04:30 +01:00
2021-12-14 23:34:35 +01:00
echo -e "\n*** INCREASE OPEN FILE LIMIT ***"
2022-06-28 18:48:07 +02:00
# based on https://raspibolt.org/guide/raspberry-pi/security.html#increase-your-open-files-limit
2023-05-03 17:21:44 +02:00
sed --in-place -i "56s/.*/* soft nofile 256000/" /etc/security/limits.conf
bash -c "echo '* hard nofile 256000' >> /etc/security/limits.conf"
bash -c "echo 'root soft nofile 256000' >> /etc/security/limits.conf"
bash -c "echo 'root hard nofile 256000' >> /etc/security/limits.conf"
bash -c "echo '# End of file' >> /etc/security/limits.conf"
sed --in-place -i "23s/.*/session required pam_limits.so/" /etc/pam.d/common-session
sed --in-place -i "25s/.*/session required pam_limits.so/" /etc/pam.d/common-session-noninteractive
bash -c "echo '# end of pam-auth-update config' >> /etc/pam.d/common-session-noninteractive"
2022-06-28 18:48:07 +02:00
# increase the possible number of running processes from 128
2023-05-03 17:21:44 +02:00
bash -c "echo 'fs.inotify.max_user_instances=4096' >> /etc/sysctl.conf"
2021-12-08 17:04:30 +01:00
# *** fail2ban ***
2021-12-23 14:57:38 +01:00
# based on https://raspibolt.org/security.html#fail2ban
2021-12-08 17:04:30 +01:00
echo "*** HARDENING ***"
2022-05-17 19:13:13 +02:00
apt_install --no-install-recommends python3-systemd fail2ban
2021-12-08 17:04:30 +01:00
2021-12-14 23:34:35 +01:00
# *** CACHE DISK IN RAM & KEYVALUE-STORE***
2021-12-08 17:04:30 +01:00
echo "Activating CACHE RAM DISK ... "
2023-05-03 17:21:44 +02:00
/home/admin/_cache.sh ramdisk on
/home/admin/_cache.sh keyvalue on
2021-12-14 23:34:35 +01:00
# *** Wifi, Bluetooth & other RaspberryPi configs ***
2023-07-08 14:58:00 +02:00
if [ " ${ baseimage } " = "raspios_arm64" ] || [ " ${ architecture } " = "aarch64" ] && [ " ${ baseimage } " = "debian" ] ; then
2021-12-08 17:04:30 +01:00
2022-01-11 14:39:15 +01:00
if [ " ${ wifi_region } " = = "off" ] ; then
2021-12-14 23:34:35 +01:00
echo -e "\n*** DISABLE WIFI ***"
2023-05-03 17:21:44 +02:00
systemctl disable wpa_supplicant.service
ifconfig wlan0 down
2021-12-08 17:04:30 +01:00
fi
2021-12-14 23:34:35 +01:00
echo -e "\n*** DISABLE BLUETOOTH ***"
2021-12-08 17:04:30 +01:00
configFile = "/boot/config.txt"
disableBT = "dtoverlay=disable-bt"
disableBTDone = $( grep -c " $disableBT " $configFile )
2021-12-14 23:34:35 +01:00
if [ " ${ disableBTDone } " -eq 0 ] ; then
2021-12-08 17:04:30 +01:00
# disable bluetooth module
2023-05-03 17:21:44 +02:00
echo "" | tee -a $configFile
echo "# Raspiblitz" | tee -a $configFile
echo 'dtoverlay=pi3-disable-bt' | tee -a $configFile
echo 'dtoverlay=disable-bt' | tee -a $configFile
2021-12-08 17:04:30 +01:00
else
echo " disable BT already in $configFile "
fi
# remove bluetooth services
2023-05-03 17:21:44 +02:00
systemctl disable bluetooth.service
systemctl disable hciuart.service
2021-12-08 17:04:30 +01:00
# remove bluetooth packages
2023-05-03 17:21:44 +02:00
apt remove -y --purge pi-bluetooth bluez bluez-firmware
2021-12-08 17:04:30 +01:00
# disable audio
2021-12-14 23:34:35 +01:00
echo -e "\n*** DISABLE AUDIO (snd_bcm2835) ***"
2023-05-03 17:21:44 +02:00
sed -i "s/^dtparam=audio=on/# dtparam=audio=on/g" /boot/config.txt
2021-12-14 23:34:35 +01:00
2021-12-08 17:04:30 +01:00
# disable DRM VC4 V3D
2021-12-14 23:34:35 +01:00
echo -e "\n*** DISABLE DRM VC4 V3D driver ***"
2021-12-08 17:04:30 +01:00
dtoverlay = vc4-fkms-v3d
2023-05-03 17:21:44 +02:00
sed -i " s/^dtoverlay= ${ dtoverlay } /# dtoverlay= ${ dtoverlay } /g " /boot/config.txt
2021-12-08 17:04:30 +01:00
# I2C fix (make sure dtparam=i2c_arm is not on)
# see: https://github.com/rootzoll/raspiblitz/issues/1058#issuecomment-739517713
2023-05-03 17:21:44 +02:00
sed -i "s/^dtparam=i2c_arm=.*//g" /boot/config.txt
2021-12-08 17:04:30 +01:00
fi
# *** BOOTSTRAP ***
2021-12-14 23:34:35 +01:00
echo -e "\n*** RASPI BOOTSTRAP SERVICE ***"
2023-05-03 17:21:44 +02:00
chmod +x /home/admin/_bootstrap.sh
cp /home/admin/assets/bootstrap.service /etc/systemd/system/bootstrap.service
systemctl enable bootstrap
2021-12-08 17:04:30 +01:00
2021-12-14 23:34:35 +01:00
# *** BACKGROUND TASKS ***
echo -e "\n*** RASPI BACKGROUND SERVICE ***"
2023-05-03 17:21:44 +02:00
chmod +x /home/admin/_background.sh
cp /home/admin/assets/background.service /etc/systemd/system/background.service
systemctl enable background
2021-12-08 17:04:30 +01:00
2021-12-14 23:34:35 +01:00
# *** BACKGROUND SCAN ***
/home/admin/_background.scan.sh install
2021-12-08 17:04:30 +01:00
#######
2021-12-14 23:34:35 +01:00
# TOR #
2021-12-08 17:04:30 +01:00
#######
echo
2021-12-14 23:34:35 +01:00
/home/admin/config.scripts/tor.install.sh install || exit 1
2021-03-15 23:16:27 +01:00
2021-12-07 15:00:44 +01:00
###########
# BITCOIN #
###########
2021-09-14 13:29:51 +02:00
echo
2021-12-07 15:00:44 +01:00
/home/admin/config.scripts/bitcoin.install.sh install || exit 1
2019-05-07 02:42:51 +02:00
2022-12-07 20:26:10 +01:00
#######
# I2P #
#######
echo
/home/admin/config.scripts/blitz.i2pd.sh install || exit 1
2022-05-05 10:59:50 +02:00
# *** BLITZ WEB SERVICE ***
2022-10-05 00:42:47 +02:00
echo "Provisioning BLITZ WEB SERVICE"
2022-05-18 20:09:13 +02:00
/home/admin/config.scripts/blitz.web.sh http-on || exit 1
2022-05-05 10:59:50 +02:00
# *** FATPACK *** (can be activated by parameter - see details at start of script)
2022-01-14 17:36:28 +01:00
if ${ fatpack } ; then
2023-04-09 23:19:22 +02:00
echo "* FATPACK activated"
/home/admin/config.scripts/blitz.fatpack.sh || exit 1
2021-12-17 21:43:19 +01:00
else
2022-05-05 10:59:50 +02:00
echo "* skipping FATPACK"
2021-12-17 21:43:19 +01:00
fi
2021-08-16 19:41:45 +02:00
2022-12-07 20:26:10 +01:00
# check fallback list bitnodes
byteSizeList = $( sudo -u admin stat -c %s /home/admin/fallback.bitnodes.nodes)
if [ ${# byteSizeList } -eq 0 ] || [ ${ byteSizeList } -lt 10240 ] ; then
echo "Using fallback list from repo: bitnodes"
2023-05-03 17:21:44 +02:00
rm /home/admin/fallback.bitnodes.nodes 2>/dev/null
cp /home/admin/assets/fallback.bitnodes.nodes /home/admin/fallback.bitnodes.nodes
2022-12-07 20:26:10 +01:00
fi
2023-05-03 17:21:44 +02:00
chown admin:admin /home/admin/fallback.bitnodes.nodes
2022-12-07 20:26:10 +01:00
# check fallback list bitcoin core
byteSizeList = $( sudo -u admin stat -c %s /home/admin/fallback.bitcoin.nodes)
if [ ${# byteSizeList } -eq 0 ] || [ ${ byteSizeList } -lt 10240 ] ; then
echo "Using fallback list from repo: bitcoin core"
2023-05-03 17:21:44 +02:00
rm /home/admin/fallback.bitcoin.nodes 2>/dev/null
cp /home/admin/assets/fallback.bitcoin.nodes /home/admin/fallback.bitcoin.nodes
2022-12-07 20:26:10 +01:00
fi
2023-05-03 17:21:44 +02:00
chown admin:admin /home/admin/fallback.bitcoin.nodes
2022-12-07 20:26:10 +01:00
2021-12-07 15:00:44 +01:00
echo
2021-04-08 00:02:57 +02:00
echo "*** raspiblitz.info ***"
2023-05-03 17:21:44 +02:00
cat /home/admin/raspiblitz.info
2019-02-04 21:01:33 +01:00
2021-04-08 00:02:57 +02:00
# *** RASPIBLITZ IMAGE READY INFO ***
2021-12-14 23:34:35 +01:00
echo -e "\n**********************************************"
2021-04-08 00:02:57 +02:00
echo "BASIC SD CARD BUILD DONE"
2021-12-14 23:34:35 +01:00
echo -e "**********************************************\n"
2021-04-08 00:02:57 +02:00
echo "Your SD Card Image for RaspiBlitz is ready (might still do display config)."
echo "Take the chance & look thru the output above if you can spot any errors or warnings."
2021-12-14 23:34:35 +01:00
echo -e "\nIMPORTANT IF WANT TO MAKE A RELEASE IMAGE FROM THIS BUILD:"
2021-04-08 00:02:57 +02:00
echo "1. login fresh --> user:admin password:raspiblitz"
2021-12-14 23:34:35 +01:00
echo -e "2. run --> release\n"
2019-02-04 21:01:33 +01:00
2022-12-21 14:50:52 +01:00
# make sure that at least the code is available (also if no internet)
2023-05-03 17:21:44 +02:00
/home/admin/config.scripts/blitz.display.sh prepare-install
2021-04-08 00:02:57 +02:00
# (do last - because might trigger reboot)
2022-01-11 14:39:15 +01:00
if [ " ${ display } " != "headless" ] || [ " ${ baseimage } " = "raspios_arm64" ] ; then
2021-04-08 00:02:57 +02:00
echo "*** ADDITIONAL DISPLAY OPTIONS ***"
2022-01-11 14:39:15 +01:00
echo " - calling: blitz.display.sh set-display ${ display } "
2023-05-03 17:21:44 +02:00
/home/admin/config.scripts/blitz.display.sh set-display ${ display }
/home/admin/config.scripts/blitz.display.sh rotate 1
2021-08-17 19:02:53 +02:00
fi
2021-08-18 23:31:27 +02:00
echo "# BUILD DONE - see above"