2018-08-06 01:03:17 +02:00
|
|
|
#!/bin/bash
|
2019-01-27 11:03:07 +01:00
|
|
|
#########################################################################
|
|
|
|
# Build your SD card image based on:
|
2021-03-09 09:37:19 +01:00
|
|
|
# raspios_arm64-2020-08-24
|
2021-04-19 12:29:36 +02:00
|
|
|
# https://downloads.raspberrypi.org/raspios_arm64/images/raspios_arm64-2021-04-09/
|
|
|
|
# SHA256: a30a3650c3ef22a69f6f025760c6b04611a5992961a8c2cd44468f1c429d68bb
|
2019-01-27 11:03:07 +01:00
|
|
|
##########################################################################
|
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
|
|
|
##########################################################################
|
|
|
|
|
2021-09-09 17:40:05 +02:00
|
|
|
defaultBranchVersion="v1.7"
|
|
|
|
|
2021-12-07 15:00:44 +01:00
|
|
|
echo
|
2021-04-09 16:09:57 +02:00
|
|
|
echo "*****************************************"
|
2021-09-09 17:40:05 +02:00
|
|
|
echo "* RASPIBLITZ SD CARD IMAGE SETUP ${defaultBranchVersion}.1 *"
|
2021-04-09 16:09:57 +02:00
|
|
|
echo "*****************************************"
|
2021-03-09 16:23:19 +01:00
|
|
|
echo "For details on optional parameters - see build script source code:"
|
|
|
|
|
2021-08-27 09:59:21 +02:00
|
|
|
# 1st optional parameter: NO-INTERACTION
|
2021-04-09 16:09:57 +02:00
|
|
|
# ----------------------------------------
|
2021-08-27 09:56:47 +02:00
|
|
|
# When 'true' then no questions will be asked on building .. so it can be used in build scripts
|
2021-04-09 16:09:57 +02:00
|
|
|
# for containers or as part of other build scripts (default is false)
|
|
|
|
|
|
|
|
noInteraction="$1"
|
|
|
|
if [ ${#noInteraction} -eq 0 ]; then
|
|
|
|
noInteraction="false"
|
|
|
|
fi
|
|
|
|
if [ "${noInteraction}" != "true" ] && [ "${noInteraction}" != "false" ]; then
|
|
|
|
echo "ERROR: NO-INTERACTION parameter needs to be either 'true' or 'false'"
|
|
|
|
exit 1
|
|
|
|
else
|
|
|
|
echo "1) will use NO-INTERACTION --> '${noInteraction}'"
|
|
|
|
fi
|
|
|
|
|
2021-08-27 09:59:21 +02:00
|
|
|
# 2nd optional parameter: FATPACK
|
2021-03-09 16:23:19 +01:00
|
|
|
# -------------------------------
|
|
|
|
# could be 'true' or 'false' (default)
|
|
|
|
# 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, ...
|
|
|
|
|
2021-04-09 16:09:57 +02:00
|
|
|
fatpack="$2"
|
2021-03-09 16:23:19 +01:00
|
|
|
if [ ${#fatpack} -eq 0 ]; then
|
|
|
|
fatpack="false"
|
|
|
|
fi
|
|
|
|
if [ "${fatpack}" != "true" ] && [ "${fatpack}" != "false" ]; then
|
|
|
|
echo "ERROR: FATPACK parameter needs to be either 'true' or 'false'"
|
|
|
|
exit 1
|
2020-06-21 23:47:26 +02:00
|
|
|
else
|
2021-04-09 16:09:57 +02:00
|
|
|
echo "2) will use FATPACK --> '${fatpack}'"
|
2018-12-10 00:50:50 +01:00
|
|
|
fi
|
2018-12-22 13:57:49 +01:00
|
|
|
|
2021-08-27 09:59:21 +02:00
|
|
|
# 3rd optional parameter: 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
|
|
|
|
# The 'raspiblitz' repo of this user is used to provisioning sd card
|
|
|
|
# with raspiblitz assets/scripts later on.
|
|
|
|
# If this parameter is set also the branch needs to be given (see next parameter).
|
2021-04-09 16:09:57 +02:00
|
|
|
githubUser="$3"
|
2018-12-22 13:57:49 +01:00
|
|
|
if [ ${#githubUser} -eq 0 ]; then
|
|
|
|
githubUser="rootzoll"
|
|
|
|
fi
|
2021-04-09 16:09:57 +02:00
|
|
|
echo "3) will use GITHUB-USERNAME --> '${githubUser}'"
|
2021-03-09 16:23:19 +01:00
|
|
|
|
2021-08-27 09:59:21 +02:00
|
|
|
# 4th optional parameter: GITHUB-BRANCH
|
2021-03-09 16:23:19 +01:00
|
|
|
# -------------------------------------
|
2021-09-09 17:40:05 +02:00
|
|
|
# could be any valid branch of the given GITHUB-USERNAME forked raspiblitz repo - take ${defaultBranchVersion} is default
|
2021-04-09 16:09:57 +02:00
|
|
|
githubBranch="$4"
|
2021-03-09 16:23:19 +01:00
|
|
|
if [ ${#githubBranch} -eq 0 ]; then
|
2021-09-09 17:40:05 +02:00
|
|
|
githubBranch="${defaultBranchVersion}"
|
2020-06-21 23:47:26 +02:00
|
|
|
fi
|
2021-04-09 16:09:57 +02:00
|
|
|
echo "4) will use GITHUB-BRANCH --> '${githubBranch}'"
|
2020-06-21 23:47:26 +02:00
|
|
|
|
2021-08-27 09:59:21 +02:00
|
|
|
# 5th optional parameter: 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)
|
2021-03-09 16:23:19 +01:00
|
|
|
# On 'false' the standard video output is used (HDMI) by default.
|
2021-04-08 00:02:57 +02:00
|
|
|
# https://github.com/rootzoll/raspiblitz/issues/1265#issuecomment-813369284
|
2021-04-09 16:09:57 +02:00
|
|
|
displayClass="$5"
|
2021-09-09 18:24:49 +02:00
|
|
|
if [ ${#displayClass} -eq 0 ]; then
|
|
|
|
displayClass="lcd"
|
|
|
|
fi
|
|
|
|
if [ "${displayClass}" == "false" ]; then
|
2021-04-08 00:02:57 +02:00
|
|
|
displayClass="hdmi"
|
2021-03-09 16:23:19 +01:00
|
|
|
fi
|
2021-04-08 00:02:57 +02:00
|
|
|
if [ "${displayClass}" != "hdmi" ] && [ "${displayClass}" != "lcd" ] && [ "${displayClass}" != "headless" ]; then
|
|
|
|
echo "ERROR: DISPLAY-CLASS parameter needs to be 'lcd', 'hdmi' or 'headless'"
|
2021-03-09 16:23:19 +01:00
|
|
|
exit 1
|
2020-06-21 23:47:26 +02:00
|
|
|
else
|
2021-04-09 16:09:57 +02:00
|
|
|
echo "5) will use DISPLAY-CLASS --> '${displayClass}'"
|
2020-06-21 23:47:26 +02:00
|
|
|
fi
|
|
|
|
|
2021-08-27 09:59:21 +02:00
|
|
|
# 6th optional parameter: 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.
|
2021-04-09 16:09:57 +02:00
|
|
|
tweakBootdrives="$6"
|
2021-03-09 16:23:19 +01:00
|
|
|
if [ ${#tweakBootdrives} -eq 0 ]; then
|
|
|
|
tweakBootdrives="true"
|
|
|
|
fi
|
|
|
|
if [ "${tweakBootdrives}" != "true" ] && [ "${tweakBootdrives}" != "false" ]; then
|
|
|
|
echo "ERROR: TWEAK-BOOTDRIVE parameter needs to be either 'true' or 'false'"
|
|
|
|
exit 1
|
2020-06-21 23:47:26 +02:00
|
|
|
else
|
2021-04-09 16:09:57 +02:00
|
|
|
echo "6) will use TWEAK-BOOTDRIVE --> '${tweakBootdrives}'"
|
2020-06-21 23:47:26 +02:00
|
|
|
fi
|
|
|
|
|
2021-08-27 09:59:21 +02:00
|
|
|
# 7th optional parameter: WIFI
|
2021-03-09 16:23:19 +01:00
|
|
|
# ---------------------------------------
|
|
|
|
# could be 'false' or 'true' (default) or a valid WIFI country code like 'US' (default)
|
|
|
|
# If 'false' WIFI will be deactivated by default
|
|
|
|
# If 'true' WIFI will be activated by with default country code 'US'
|
|
|
|
# If any valid wifi country code Wifi will be activated with that country code by default
|
2021-04-09 16:09:57 +02:00
|
|
|
modeWifi="$7"
|
2021-03-09 16:23:19 +01:00
|
|
|
if [ ${#modeWifi} -eq 0 ] || [ "${modeWifi}" == "true" ]; then
|
|
|
|
modeWifi="US"
|
2020-06-21 23:47:26 +02:00
|
|
|
fi
|
2021-04-09 16:09:57 +02:00
|
|
|
echo "7) will use WIFI --> '${modeWifi}'"
|
2020-06-21 23:47:26 +02:00
|
|
|
|
2021-03-15 23:16:27 +01:00
|
|
|
# AUTO-DETECTION: CPU-ARCHITECTURE
|
|
|
|
# ---------------------------------------
|
|
|
|
cpu="?"
|
2021-12-07 15:00:44 +01:00
|
|
|
if [ "$(uname -m | grep -c 'arm')" -gt 0 ]; then
|
2021-03-15 23:16:27 +01:00
|
|
|
cpu="arm"
|
2021-12-07 15:00:44 +01:00
|
|
|
elif [ "$(uname -m | grep -c 'aarch64')" -gt 0 ]; then
|
2021-03-15 23:16:27 +01:00
|
|
|
cpu="aarch64"
|
2021-12-07 15:00:44 +01:00
|
|
|
elif [ "$(uname -m | grep -c 'x86_64')" -gt 0 ]; then
|
2021-03-15 23:16:27 +01:00
|
|
|
cpu="x86_64"
|
|
|
|
else
|
2018-10-13 22:43:07 +02:00
|
|
|
echo "!!! FAIL !!!"
|
2021-03-15 23:16:27 +01:00
|
|
|
echo "Can only build on ARM, aarch64, x86_64 not on:"
|
2018-10-13 22:43:07 +02:00
|
|
|
uname -m
|
|
|
|
exit 1
|
|
|
|
fi
|
2021-03-15 23:16:27 +01:00
|
|
|
echo "X) will use CPU-ARCHITECTURE --> '${cpu}'"
|
2018-10-13 22:43:07 +02:00
|
|
|
|
2021-03-15 23:16:27 +01:00
|
|
|
# AUTO-DETECTION: OPERATINGSYSTEM
|
|
|
|
# ---------------------------------------
|
2021-12-07 15:00:44 +01:00
|
|
|
# keep in mind that DietPi for Raspberry is also a stripped down Raspbian
|
2021-04-03 12:24:50 +02:00
|
|
|
baseimage="?"
|
2021-12-07 15:00:44 +01:00
|
|
|
if [ $(grep -c 'Raspbian' /etc/os-release 2>/dev/null) -gt 0 ]; then
|
2021-04-03 12:24:50 +02:00
|
|
|
baseimage="raspbian"
|
2021-12-07 15:00:44 +01:00
|
|
|
elif [ $(grep -c 'Debian' /etc/os-release 2>/dev/null) -gt 0 ]; then
|
2021-12-08 17:04:30 +01:00
|
|
|
if [ $(uname -n | grep -c 'rpi') -gt 0 ] && [ "${cpu}" = aarch64 ]; then
|
2021-04-03 12:24:50 +02:00
|
|
|
baseimage="debian_rpi64"
|
2021-12-08 17:04:30 +01:00
|
|
|
elif [ $(uname -n | grep -c 'raspberrypi') -gt 0 ] && [ "${cpu}" = aarch64 ]; then
|
2021-04-03 12:24:50 +02:00
|
|
|
baseimage="raspios_arm64"
|
2021-12-07 15:00:44 +01:00
|
|
|
elif [ "${cpu}" = "arm" ] || [ "${cpu}" = "aarch64" ] ; then
|
2021-04-03 12:24:50 +02:00
|
|
|
baseimage="armbian"
|
2021-03-09 09:37:19 +01:00
|
|
|
else
|
2021-04-03 12:24:50 +02:00
|
|
|
baseimage="debian"
|
2021-03-09 09:37:19 +01:00
|
|
|
fi
|
2021-12-07 15:00:44 +01:00
|
|
|
elif [ $(grep -c 'Ubuntu' /etc/os-release 2>/dev/null) -gt 0 ]; then
|
2021-04-03 12:24:50 +02:00
|
|
|
baseimage="ubuntu"
|
2021-12-07 15:00:44 +01:00
|
|
|
elif [ $(uname -n | grep -c 'DietPi') -gt 0 ]; then
|
2021-04-03 12:24:50 +02:00
|
|
|
baseimage="dietpi"
|
2021-12-07 15:00:44 +01:00
|
|
|
elif [ "${baseimage}" = "?" ]; then
|
2018-10-13 22:43:07 +02:00
|
|
|
cat /etc/os-release 2>/dev/null
|
2021-03-15 23:16:27 +01:00
|
|
|
echo "!!! FAIL: Base Image cannot be detected or is not supported."
|
2018-10-13 22:43:07 +02:00
|
|
|
exit 1
|
2021-03-15 23:16:27 +01:00
|
|
|
fi
|
2021-04-03 12:24:50 +02:00
|
|
|
echo "X) will use OPERATINGSYSTEM ---> '${baseimage}'"
|
2021-03-15 23:16:27 +01:00
|
|
|
|
|
|
|
# USER-CONFIRMATION
|
2021-04-09 16:09:57 +02:00
|
|
|
if [ "${noInteraction}" != "true" ]; then
|
|
|
|
echo -n "Do you agree with all parameters above? (yes/no) "
|
|
|
|
read installRaspiblitzAnswer
|
|
|
|
if [ "$installRaspiblitzAnswer" != "yes" ] ; then
|
|
|
|
exit 1
|
|
|
|
fi
|
2018-10-13 22:43:07 +02:00
|
|
|
fi
|
2021-04-09 16:09:57 +02:00
|
|
|
echo "Building RaspiBlitz ..."
|
2021-12-07 15:00:44 +01:00
|
|
|
echo
|
2021-04-09 16:09:57 +02:00
|
|
|
sleep 3
|
2018-10-13 22:43:07 +02:00
|
|
|
|
2021-03-15 23:16:27 +01:00
|
|
|
# INSTALL TOR
|
|
|
|
echo "*** INSTALL TOR BY DEFAULT ***"
|
2021-12-07 15:00:44 +01:00
|
|
|
echo
|
2021-03-15 23:16:27 +01:00
|
|
|
sudo apt install -y dirmngr
|
|
|
|
echo "*** Adding KEYS deb.torproject.org ***"
|
|
|
|
# fix for v1.6 base image https://github.com/rootzoll/raspiblitz/issues/1906#issuecomment-755299759
|
|
|
|
wget -qO- https://deb.torproject.org/torproject.org/A3C4F0F979CAA22CDBA8F512EE8CBC9E886DDD89.asc | sudo gpg --import
|
|
|
|
sudo gpg --export A3C4F0F979CAA22CDBA8F512EE8CBC9E886DDD89 | sudo apt-key add -
|
|
|
|
torKeyAvailable=$(sudo gpg --list-keys | grep -c "A3C4F0F979CAA22CDBA8F512EE8CBC9E886DDD89")
|
|
|
|
if [ ${torKeyAvailable} -eq 0 ]; then
|
|
|
|
echo "!!! FAIL: Was not able to import deb.torproject.org key"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
echo "- OK key added"
|
|
|
|
|
|
|
|
echo "*** Adding Tor Sources to sources.list ***"
|
2021-03-23 14:06:02 +01:00
|
|
|
torSourceListAvailable=$(sudo grep -c 'https://deb.torproject.org/torproject.org' /etc/apt/sources.list)
|
2021-03-15 23:16:27 +01:00
|
|
|
echo "torSourceListAvailable=${torSourceListAvailable}"
|
|
|
|
if [ ${torSourceListAvailable} -eq 0 ]; then
|
2021-12-07 15:00:44 +01:00
|
|
|
echo "- adding Tor sources ..."
|
|
|
|
if [ "${baseimage}" = "raspbian" ] || [ "${baseimage}" = "raspios_arm64" ] || \
|
|
|
|
[ "${baseimage}" = "armbian" ] || [ "${baseimage}" = "dietpi" ] || [ "${baseimage}" = "debian" ]; then
|
|
|
|
echo "- using https://deb.torproject.org/torproject.org bullseye"
|
|
|
|
echo "deb https://deb.torproject.org/torproject.org bullseye main" | sudo tee -a /etc/apt/sources.list
|
|
|
|
echo "deb-src https://deb.torproject.org/torproject.org bullseye main" | sudo tee -a /etc/apt/sources.list
|
2021-04-03 12:24:50 +02:00
|
|
|
elif [ "${baseimage}" = "ubuntu" ]; then
|
2021-03-15 23:16:27 +01:00
|
|
|
echo "- using https://deb.torproject.org/torproject.org focal"
|
|
|
|
echo "deb https://deb.torproject.org/torproject.org focal main" | sudo tee -a /etc/apt/sources.list
|
|
|
|
echo "deb-src https://deb.torproject.org/torproject.org focal main" | sudo tee -a /etc/apt/sources.list
|
|
|
|
else
|
2021-04-03 12:24:50 +02:00
|
|
|
echo "!!! FAIL: No Tor sources for os: ${baseimage}"
|
2021-03-15 23:16:27 +01:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
echo "- OK sources added"
|
|
|
|
else
|
2021-12-07 15:00:44 +01:00
|
|
|
echo "Tor sources are available"
|
2021-03-15 23:16:27 +01:00
|
|
|
fi
|
|
|
|
|
|
|
|
echo "*** Install & Enable Tor ***"
|
2021-08-19 16:09:04 +02:00
|
|
|
sudo apt update -y
|
2021-03-15 23:16:27 +01:00
|
|
|
sudo apt install tor tor-arm torsocks -y
|
2021-12-07 15:00:44 +01:00
|
|
|
echo
|
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
|
2021-04-03 12:24:50 +02:00
|
|
|
if [ "${baseimage}" = "raspbian" ] || [ "${baseimage}" = "dietpi" ] || \
|
|
|
|
[ "${baseimage}" = "raspios_arm64" ]||[ "${baseimage}" = "debian_rpi64" ]; then
|
2021-12-07 15:00:44 +01:00
|
|
|
echo
|
2019-04-14 12:08:18 +02:00
|
|
|
echo "*** FIXING LOCALES FOR BUILD ***"
|
2019-08-07 23:11:45 +02:00
|
|
|
|
2019-04-14 12:08:18 +02:00
|
|
|
sudo sed -i "s/^# en_US.UTF-8 UTF-8.*/en_US.UTF-8 UTF-8/g" /etc/locale.gen
|
|
|
|
sudo sed -i "s/^# en_US ISO-8859-1.*/en_US ISO-8859-1/g" /etc/locale.gen
|
|
|
|
sudo locale-gen
|
2020-01-20 20:37:30 +01:00
|
|
|
export LANGUAGE=en_US.UTF-8
|
|
|
|
export LANG=en_US.UTF-8
|
2021-04-03 12:24:50 +02:00
|
|
|
if [ "${baseimage}" = "raspbian" ] || [ "${baseimage}" = "dietpi" ]; then
|
2021-03-09 09:37:19 +01:00
|
|
|
export LC_ALL=en_US.UTF-8
|
2019-08-07 23:11:45 +02:00
|
|
|
|
2021-03-09 09:37:19 +01:00
|
|
|
# https://github.com/rootzoll/raspiblitz/issues/684
|
|
|
|
sudo sed -i "s/^ SendEnv LANG LC.*/# SendEnv LANG LC_*/g" /etc/ssh/ssh_config
|
2019-08-07 23:11:45 +02:00
|
|
|
|
2021-08-27 09:59:21 +02:00
|
|
|
# remove unnecessary files
|
2021-03-09 09:37:19 +01:00
|
|
|
sudo rm -rf /home/pi/MagPi
|
|
|
|
# https://www.reddit.com/r/linux/comments/lbu0t1/microsoft_repo_installed_on_all_raspberry_pis/
|
|
|
|
sudo rm -f /etc/apt/sources.list.d/vscode.list
|
|
|
|
sudo rm -f /etc/apt/trusted.gpg.d/microsoft.gpg
|
|
|
|
fi
|
|
|
|
if [ ! -f /etc/apt/sources.list.d/raspi.list ]; then
|
|
|
|
echo "# Add the archive.raspberrypi.org/debian/ to the sources.list"
|
|
|
|
echo "deb http://archive.raspberrypi.org/debian/ buster main" | sudo tee /etc/apt/sources.list.d/raspi.list
|
|
|
|
fi
|
2019-04-14 12:08:18 +02:00
|
|
|
fi
|
2018-12-01 22:33:18 +01:00
|
|
|
|
2021-08-19 16:04:13 +02:00
|
|
|
echo "*** Remove not needed packages ***"
|
2020-08-15 13:52:08 +02:00
|
|
|
sudo apt remove -y --purge libreoffice* oracle-java* chromium-browser nuscratch scratch sonic-pi minecraft-pi plymouth python2 vlc
|
2020-06-23 12:47:55 +02:00
|
|
|
sudo apt clean
|
|
|
|
sudo apt -y autoremove
|
2019-11-27 08:49:11 +01:00
|
|
|
|
2021-12-07 15:00:44 +01:00
|
|
|
echo
|
2021-08-19 18:52:12 +02:00
|
|
|
echo "*** Python DEFAULT libs & dependencies ***"
|
|
|
|
|
2020-06-04 10:54:01 +02:00
|
|
|
if [ -f "/usr/bin/python3.7" ]; then
|
2020-06-21 23:47:26 +02:00
|
|
|
# make sure /usr/bin/python exists (and calls Python3.7 in Buster)
|
2020-06-04 10:54:01 +02:00
|
|
|
sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.7 1
|
|
|
|
echo "python calls python3.7"
|
|
|
|
elif [ -f "/usr/bin/python3.8" ]; then
|
|
|
|
# use python 3.8 if available
|
|
|
|
sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.8 1
|
2020-07-01 12:55:48 +02:00
|
|
|
sudo ln -s /usr/bin/python3.8 /usr/bin/python3.7
|
2020-06-04 10:54:01 +02:00
|
|
|
echo "python calls python3.8"
|
2021-11-30 12:58:06 +01:00
|
|
|
elif [ -f "/usr/bin/python3.9" ]; then
|
|
|
|
# use python 3.9 if available
|
|
|
|
sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.9 1
|
|
|
|
sudo ln -s /usr/bin/python3.9 /usr/bin/python3.7
|
|
|
|
echo "python calls python3.9"
|
2020-06-04 10:54:01 +02:00
|
|
|
else
|
|
|
|
echo "!!! FAIL !!!"
|
|
|
|
echo "There is no tested version of python present"
|
|
|
|
exit 1
|
|
|
|
fi
|
2019-11-27 08:49:11 +01:00
|
|
|
|
2021-08-19 18:52:12 +02:00
|
|
|
# for setup shell scripts
|
|
|
|
sudo apt -y install dialog bc python3-dialog
|
|
|
|
|
|
|
|
# libs (for global python scripts)
|
|
|
|
sudo -H python3 -m pip install --upgrade pip
|
|
|
|
sudo -H python3 -m pip install grpcio==1.38.1
|
|
|
|
sudo -H python3 -m pip install googleapis-common-protos==1.53.0
|
|
|
|
sudo -H python3 -m pip install toml==0.10.1
|
|
|
|
sudo -H python3 -m pip install j2cli==0.3.10
|
|
|
|
sudo -H python3 -m pip install requests[socks]==2.21.0
|
|
|
|
|
2021-12-07 15:00:44 +01:00
|
|
|
echo
|
2021-08-19 16:04:13 +02:00
|
|
|
echo "*** UPDATE Debian***"
|
2020-06-23 12:47:55 +02:00
|
|
|
sudo apt update -y
|
|
|
|
sudo apt upgrade -f -y
|
2018-10-13 22:43:07 +02:00
|
|
|
|
2021-12-07 15:00:44 +01:00
|
|
|
echo
|
2021-04-03 12:24:50 +02:00
|
|
|
echo "*** 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
|
|
|
|
if [ "$(compgen -u | grep -c dietpi)" -gt 0 ];then
|
|
|
|
echo "# Renaming dietpi user to pi"
|
2019-01-28 20:37:31 +01:00
|
|
|
sudo usermod -l pi dietpi
|
2021-03-09 09:37:19 +01:00
|
|
|
elif [ "$(compgen -u | grep -c pi)" -eq 0 ];then
|
|
|
|
echo "# Adding the user pi"
|
|
|
|
sudo adduser --disabled-password --gecos "" pi
|
|
|
|
sudo adduser pi sudo
|
2018-10-13 22:43:07 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
# special prepare when Raspbian
|
2021-04-03 12:24:50 +02:00
|
|
|
if [ "${baseimage}" = "raspbian" ]||[ "${baseimage}" = "raspios_arm64" ]||\
|
|
|
|
[ "${baseimage}" = "debian_rpi64" ]; then
|
2021-08-19 16:04:13 +02:00
|
|
|
|
2021-12-07 15:00:44 +01:00
|
|
|
echo
|
2021-08-19 16:04:13 +02:00
|
|
|
echo "*** PREPARE RASPBIAN ***"
|
2021-03-09 09:37:19 +01:00
|
|
|
sudo apt install -y raspi-config
|
2018-10-13 22:43:07 +02:00
|
|
|
# do memory split (16MB)
|
|
|
|
sudo raspi-config nonint do_memory_split 16
|
|
|
|
# set to wait until network is available on boot (0 seems to yes)
|
|
|
|
sudo raspi-config nonint do_boot_wait 0
|
2018-10-19 15:35:38 +02:00
|
|
|
# set WIFI country so boot does not block
|
2021-03-09 16:23:19 +01:00
|
|
|
if [ "${modeWifi}" != "false" ]; then
|
|
|
|
# this will undo the softblock of rfkill on RaspiOS
|
|
|
|
sudo raspi-config nonint do_wifi_country $modeWifi
|
2020-06-21 23:47:26 +02:00
|
|
|
fi
|
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
|
2021-12-07 15:00:44 +01:00
|
|
|
echo | sudo tee -a $configFile
|
2021-03-23 14:03:03 +01:00
|
|
|
echo "# Raspiblitz" | sudo tee -a $configFile
|
2020-06-22 18:55:30 +02:00
|
|
|
echo "$max_usb_current" | sudo tee -a $configFile
|
|
|
|
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
|
2021-03-15 23:16:27 +01:00
|
|
|
# use command to check last fsck check: sudo tune2fs -l /dev/mmcblk0p2
|
2021-03-09 16:23:19 +01:00
|
|
|
if [ "${tweakBootdrives}" == "true" ]; then
|
2021-03-15 23:16:27 +01:00
|
|
|
echo "* running tune2fs"
|
|
|
|
sudo tune2fs -c 1 /dev/mmcblk0p2
|
2021-03-09 16:23:19 +01:00
|
|
|
else
|
|
|
|
echo "* skipping tweakBootdrives"
|
|
|
|
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
|
2021-03-09 09:37:19 +01:00
|
|
|
sudo sed -i "s/^/$fsOption1 /g" "$kernelOptionsFile"
|
|
|
|
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
|
2021-03-09 09:37:19 +01:00
|
|
|
sudo sed -i "s/^/$fsOption2 /g" "$kernelOptionsFile"
|
|
|
|
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"
|
2019-05-19 16:25:47 +02:00
|
|
|
sudo systemctl set-default multi-user.target
|
|
|
|
fi
|
|
|
|
|
2021-12-07 15:00:44 +01:00
|
|
|
echo
|
2018-10-13 22:43:07 +02:00
|
|
|
echo "*** 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
|
2018-08-06 01:03:17 +02:00
|
|
|
echo "root:raspiblitz" | sudo chpasswd
|
|
|
|
echo "pi:raspiblitz" | sudo chpasswd
|
|
|
|
|
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)
|
|
|
|
if [ "${baseimage}" = "raspbian" ]||[ "${baseimage}" = "raspios_arm64" ]||\
|
|
|
|
[ "${baseimage}" = "debian_rpi64" ]||[ "${baseimage}" = "armbian" ]||\
|
|
|
|
[ "${baseimage}" = "ubuntu" ]; then
|
|
|
|
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
|
|
|
|
sudo bash -c 'echo "# automatic start the LCD info loop" >> /home/pi/.bashrc'
|
|
|
|
sudo bash -c 'echo "SCRIPT=/home/admin/00infoLCD.sh" >> /home/pi/.bashrc'
|
|
|
|
sudo bash -c 'echo "# replace shell with script => logout when exiting script" >> /home/pi/.bashrc'
|
|
|
|
sudo bash -c 'echo "exec \$SCRIPT" >> /home/pi/.bashrc'
|
|
|
|
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
|
|
|
|
elif [ "${baseimage}" = "dietpi" ]; then
|
|
|
|
homeFile=/home/dietpi/.bashrc
|
|
|
|
autostartDone=$(grep -c "automatic start the LCD" $homeFile)
|
|
|
|
if [ ${autostartDone} -eq 0 ]; then
|
|
|
|
# bash autostart for dietpi
|
|
|
|
sudo bash -c 'echo "# automatic start the LCD info loop" >> /home/dietpi/.bashrc'
|
|
|
|
sudo bash -c 'echo "SCRIPT=/home/admin/00infoLCD.sh" >> /home/dietpi/.bashrc'
|
|
|
|
sudo bash -c 'echo "# replace shell with script => logout when exiting script" >> /home/dietpi/.bashrc'
|
|
|
|
sudo bash -c 'echo "exec \$SCRIPT" >> /home/dietpi/.bashrc'
|
|
|
|
echo "autostart LCD added to $homeFile"
|
|
|
|
else
|
|
|
|
echo "autostart LCD already in $homeFile"
|
2021-04-08 00:02:57 +02:00
|
|
|
fi
|
|
|
|
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
|
|
|
|
|
2019-03-13 17:00:44 +01:00
|
|
|
# change log rotates
|
|
|
|
# see https://github.com/rootzoll/raspiblitz/issues/394#issuecomment-471535483
|
2019-03-25 23:17:14 +01:00
|
|
|
echo "/var/log/syslog" >> ./rsyslog
|
|
|
|
echo "{" >> ./rsyslog
|
|
|
|
echo " rotate 7" >> ./rsyslog
|
|
|
|
echo " daily" >> ./rsyslog
|
|
|
|
echo " missingok" >> ./rsyslog
|
|
|
|
echo " notifempty" >> ./rsyslog
|
|
|
|
echo " delaycompress" >> ./rsyslog
|
|
|
|
echo " compress" >> ./rsyslog
|
|
|
|
echo " postrotate" >> ./rsyslog
|
|
|
|
echo " invoke-rc.d rsyslog rotate > /dev/null" >> ./rsyslog
|
|
|
|
echo " endscript" >> ./rsyslog
|
|
|
|
echo "}" >> ./rsyslog
|
2021-12-07 15:00:44 +01:00
|
|
|
echo >> ./rsyslog
|
2019-03-25 23:17:14 +01:00
|
|
|
echo "/var/log/mail.info" >> ./rsyslog
|
|
|
|
echo "/var/log/mail.warn" >> ./rsyslog
|
|
|
|
echo "/var/log/mail.err" >> ./rsyslog
|
|
|
|
echo "/var/log/mail.log" >> ./rsyslog
|
|
|
|
echo "/var/log/daemon.log" >> ./rsyslog
|
|
|
|
echo "{" >> ./rsyslog
|
|
|
|
echo " rotate 4" >> ./rsyslog
|
|
|
|
echo " size=100M" >> ./rsyslog
|
|
|
|
echo " missingok" >> ./rsyslog
|
|
|
|
echo " notifempty" >> ./rsyslog
|
|
|
|
echo " compress" >> ./rsyslog
|
|
|
|
echo " delaycompress" >> ./rsyslog
|
|
|
|
echo " sharedscripts" >> ./rsyslog
|
|
|
|
echo " postrotate" >> ./rsyslog
|
|
|
|
echo " invoke-rc.d rsyslog rotate > /dev/null" >> ./rsyslog
|
|
|
|
echo " endscript" >> ./rsyslog
|
|
|
|
echo "}" >> ./rsyslog
|
2021-12-07 15:00:44 +01:00
|
|
|
echo >> ./rsyslog
|
2019-03-25 23:17:14 +01:00
|
|
|
echo "/var/log/kern.log" >> ./rsyslog
|
|
|
|
echo "/var/log/auth.log" >> ./rsyslog
|
2019-03-13 17:00:44 +01:00
|
|
|
echo "{" >> ./rsyslog
|
|
|
|
echo " rotate 4" >> ./rsyslog
|
|
|
|
echo " size=100M" >> ./rsyslog
|
|
|
|
echo " missingok" >> ./rsyslog
|
|
|
|
echo " notifempty" >> ./rsyslog
|
|
|
|
echo " compress" >> ./rsyslog
|
|
|
|
echo " delaycompress" >> ./rsyslog
|
|
|
|
echo " sharedscripts" >> ./rsyslog
|
|
|
|
echo " postrotate" >> ./rsyslog
|
|
|
|
echo " invoke-rc.d rsyslog rotate > /dev/null" >> ./rsyslog
|
|
|
|
echo " endscript" >> ./rsyslog
|
|
|
|
echo "}" >> ./rsyslog
|
2021-12-07 15:00:44 +01:00
|
|
|
echo >> ./rsyslog
|
2019-03-25 23:17:14 +01:00
|
|
|
echo "/var/log/user.log" >> ./rsyslog
|
|
|
|
echo "/var/log/lpr.log" >> ./rsyslog
|
|
|
|
echo "/var/log/cron.log" >> ./rsyslog
|
|
|
|
echo "/var/log/debug" >> ./rsyslog
|
|
|
|
echo "/var/log/messages" >> ./rsyslog
|
|
|
|
echo "{" >> ./rsyslog
|
|
|
|
echo " rotate 4" >> ./rsyslog
|
|
|
|
echo " weekly" >> ./rsyslog
|
|
|
|
echo " missingok" >> ./rsyslog
|
|
|
|
echo " notifempty" >> ./rsyslog
|
|
|
|
echo " compress" >> ./rsyslog
|
|
|
|
echo " delaycompress" >> ./rsyslog
|
|
|
|
echo " sharedscripts" >> ./rsyslog
|
|
|
|
echo " postrotate" >> ./rsyslog
|
|
|
|
echo " invoke-rc.d rsyslog rotate > /dev/null" >> ./rsyslog
|
|
|
|
echo " endscript" >> ./rsyslog
|
|
|
|
echo "}" >> ./rsyslog
|
2019-03-13 17:00:44 +01:00
|
|
|
sudo mv ./rsyslog /etc/logrotate.d/rsyslog
|
|
|
|
sudo chown root:root /etc/logrotate.d/rsyslog
|
|
|
|
sudo service rsyslog restart
|
|
|
|
|
2021-12-07 15:00:44 +01:00
|
|
|
echo
|
2018-08-06 11:46:22 +02:00
|
|
|
echo "*** SOFTWARE UPDATE ***"
|
2021-11-11 15:53:16 +01:00
|
|
|
# based on https://raspibolt.github.io/raspibolt/raspibolt_20_pi.html#software-update
|
2018-08-06 01:03:17 +02:00
|
|
|
|
|
|
|
# installs like on RaspiBolt
|
2020-06-23 12:47:55 +02:00
|
|
|
sudo apt install -y htop git curl bash-completion vim jq dphys-swapfile bsdmainutils
|
2018-08-06 01:03:17 +02:00
|
|
|
|
2019-01-15 15:54:20 +01:00
|
|
|
# installs bandwidth monitoring for future statistics
|
2020-06-23 12:47:55 +02:00
|
|
|
sudo apt install -y vnstat
|
2019-01-15 15:54:20 +01:00
|
|
|
|
2020-10-18 18:18:11 +02:00
|
|
|
# prepare for format data drive
|
|
|
|
sudo apt install -y parted dosfstools
|
|
|
|
|
2019-03-25 23:17:14 +01:00
|
|
|
# prepare for BTRFS data drive raid
|
2021-03-09 16:24:40 +01:00
|
|
|
sudo apt install -y btrfs-progs
|
2019-03-25 23:17:14 +01:00
|
|
|
|
2020-06-03 19:05:21 +02:00
|
|
|
# network tools
|
2020-06-23 12:47:55 +02:00
|
|
|
sudo apt install -y autossh telnet
|
2019-03-25 23:17:14 +01:00
|
|
|
|
2019-03-14 13:03:11 +01:00
|
|
|
# prepare for display graphics mode
|
|
|
|
# see https://github.com/rootzoll/raspiblitz/pull/334
|
2020-06-23 12:47:55 +02:00
|
|
|
sudo apt install -y fbi
|
2019-03-14 12:39:16 +01:00
|
|
|
|
2019-04-10 01:56:48 +02:00
|
|
|
# prepare for powertest
|
2020-06-23 12:47:55 +02:00
|
|
|
sudo apt install -y sysbench
|
2019-04-10 01:56:48 +02:00
|
|
|
|
2019-04-14 12:08:18 +02:00
|
|
|
# check for dependencies on DietPi, Ubuntu, Armbian
|
2020-06-23 12:47:55 +02:00
|
|
|
sudo apt install -y build-essential
|
2020-05-24 10:32:58 +02:00
|
|
|
|
|
|
|
# add armbian-config
|
2021-04-03 12:24:50 +02:00
|
|
|
if [ "${baseimage}" = "armbian" ]; then
|
2020-04-27 11:01:14 +02:00
|
|
|
# add armbian config
|
2020-06-23 12:47:55 +02:00
|
|
|
sudo apt install armbian-config -y
|
2020-04-27 11:01:14 +02:00
|
|
|
fi
|
|
|
|
|
2020-06-04 10:54:01 +02:00
|
|
|
# dependencies for python
|
2020-06-23 12:47:55 +02:00
|
|
|
sudo apt install -y python3-venv python3-dev python3-wheel python3-jinja2 python3-pip
|
2020-06-04 10:54:01 +02:00
|
|
|
|
|
|
|
# make sure /usr/bin/pip exists (and calls pip3 in Debian Buster)
|
|
|
|
sudo update-alternatives --install /usr/bin/pip pip /usr/bin/pip3 1
|
2020-05-24 10:32:58 +02:00
|
|
|
|
2019-04-14 12:08:18 +02:00
|
|
|
# rsync is needed to copy from HDD
|
2020-06-23 12:47:55 +02:00
|
|
|
sudo apt install -y rsync
|
2019-04-14 12:08:18 +02:00
|
|
|
# install ifconfig
|
2020-06-23 12:47:55 +02:00
|
|
|
sudo apt install -y net-tools
|
2019-04-14 12:08:18 +02:00
|
|
|
#to display hex codes
|
2020-06-23 12:47:55 +02:00
|
|
|
sudo apt install -y xxd
|
2019-04-14 12:08:18 +02:00
|
|
|
# setuptools needed for Nyx
|
|
|
|
sudo pip install setuptools
|
|
|
|
# netcat for 00infoBlitz.sh
|
2020-06-23 12:47:55 +02:00
|
|
|
sudo apt install -y netcat
|
2019-04-14 12:08:18 +02:00
|
|
|
# install OpenSSH client + server
|
2020-06-23 12:47:55 +02:00
|
|
|
sudo apt install -y openssh-client
|
|
|
|
sudo apt install -y openssh-sftp-server
|
2021-03-15 23:16:27 +01:00
|
|
|
sudo apt install -y sshpass
|
2019-04-14 12:08:18 +02:00
|
|
|
# install killall, fuser
|
2020-06-23 12:47:55 +02:00
|
|
|
sudo apt install -y psmisc
|
2021-03-15 23:16:27 +01:00
|
|
|
# install firewall
|
|
|
|
sudo apt install -y ufw
|
2021-03-22 22:10:54 +01:00
|
|
|
# make sure sqlite3 is available
|
|
|
|
sudo apt install -y sqlite3
|
2021-03-15 23:16:27 +01:00
|
|
|
|
2020-06-23 12:47:55 +02:00
|
|
|
sudo apt clean
|
|
|
|
sudo apt -y autoremove
|
2019-04-14 12:08:18 +02:00
|
|
|
|
2021-12-07 15:00:44 +01:00
|
|
|
echo
|
2018-08-06 11:46:22 +02:00
|
|
|
echo "*** ADDING MAIN USER admin ***"
|
2021-11-11 15:53:16 +01:00
|
|
|
# based on https://raspibolt.github.io/raspibolt/raspibolt_20_pi.html#add-users
|
2018-08-06 01:03:17 +02:00
|
|
|
# using the default password 'raspiblitz'
|
|
|
|
|
|
|
|
sudo adduser --disabled-password --gecos "" admin
|
|
|
|
echo "admin:raspiblitz" | sudo chpasswd
|
|
|
|
sudo adduser admin sudo
|
|
|
|
sudo chsh admin -s /bin/bash
|
|
|
|
|
|
|
|
# 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
|
2018-08-06 01:03:17 +02:00
|
|
|
|
2021-04-03 12:24:50 +02:00
|
|
|
# WRITE BASIC raspiblitz.info to sdcard
|
2021-09-04 22:55:50 +02:00
|
|
|
# if further info gets added .. make sure to keep that on: blitz.preparerelease.sh
|
2021-04-03 12:24:50 +02:00
|
|
|
echo "baseimage=${baseimage}" > /home/admin/raspiblitz.info
|
|
|
|
echo "cpu=${cpu}" >> /home/admin/raspiblitz.info
|
2021-04-09 16:09:57 +02:00
|
|
|
echo "displayClass=headless" >> /home/admin/raspiblitz.info
|
2021-04-03 12:24:50 +02:00
|
|
|
sudo mv ./raspiblitz.info /home/admin/raspiblitz.info
|
2021-04-08 00:02:57 +02:00
|
|
|
sudo chmod 755 /home/admin/raspiblitz.info
|
2021-04-03 12:24:50 +02:00
|
|
|
|
2021-12-07 15:00:44 +01:00
|
|
|
echo
|
2018-08-06 11:46:22 +02:00
|
|
|
echo "*** ADDING SERVICE USER bitcoin"
|
2021-11-11 15:53:16 +01:00
|
|
|
# based on https://raspibolt.github.io/raspibolt/raspibolt_20_pi.html#add-users
|
2018-08-06 01:03:17 +02:00
|
|
|
|
|
|
|
# create user and set default password for user
|
|
|
|
sudo adduser --disabled-password --gecos "" bitcoin
|
|
|
|
echo "bitcoin:raspiblitz" | sudo chpasswd
|
2021-12-07 15:00:44 +01:00
|
|
|
# make home directory readable
|
|
|
|
sudo chmod 755 /home/bitcoin
|
2018-08-06 01:03:17 +02:00
|
|
|
|
2021-12-07 15:00:44 +01:00
|
|
|
echo
|
2020-04-28 19:59:52 +02:00
|
|
|
echo "*** ADDING GROUPS FOR CREDENTIALS STORE ***"
|
|
|
|
# access to credentials (e.g. macaroon files) in a central location is managed with unix groups and permissions
|
|
|
|
sudo /usr/sbin/groupadd --force --gid 9700 lndadmin
|
|
|
|
sudo /usr/sbin/groupadd --force --gid 9701 lndinvoice
|
|
|
|
sudo /usr/sbin/groupadd --force --gid 9702 lndreadonly
|
2020-08-24 11:46:04 +02:00
|
|
|
sudo /usr/sbin/groupadd --force --gid 9703 lndinvoices
|
|
|
|
sudo /usr/sbin/groupadd --force --gid 9704 lndchainnotifier
|
|
|
|
sudo /usr/sbin/groupadd --force --gid 9705 lndsigner
|
|
|
|
sudo /usr/sbin/groupadd --force --gid 9706 lndwalletkit
|
|
|
|
sudo /usr/sbin/groupadd --force --gid 9707 lndrouter
|
2020-04-28 19:59:52 +02:00
|
|
|
|
2021-12-07 15:00:44 +01:00
|
|
|
echo
|
2021-09-06 16:44:12 +02:00
|
|
|
echo "*** SHELL SCRIPTS & ASSETS ***"
|
2021-03-15 23:16:27 +01:00
|
|
|
|
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
|
2021-04-03 12:24:50 +02:00
|
|
|
sudo -u admin git config --global user.name "${githubUser}"
|
|
|
|
sudo -u admin git config --global user.email "johndoe@example.com"
|
2021-11-30 16:27:20 +01:00
|
|
|
sudo rm -rf /home/admin/raspiblitz
|
2021-03-15 23:16:27 +01:00
|
|
|
sudo -u admin git clone -b ${githubBranch} https://github.com/${githubUser}/raspiblitz.git
|
|
|
|
sudo -u admin cp -r /home/admin/raspiblitz/home.admin/assets /home/admin/
|
2021-11-30 16:27:20 +01:00
|
|
|
sudo -u admin cp /home/admin/raspiblitz/home.admin/.tmux.conf /home/admin
|
|
|
|
sudo -u admin cp /home/admin/raspiblitz/home.admin/*.* /home/admin
|
|
|
|
sudo -u admin chmod 755 *.sh
|
2021-03-15 23:16:27 +01:00
|
|
|
sudo -u admin cp -r /home/admin/raspiblitz/home.admin/config.scripts /home/admin/
|
2021-11-30 16:27:20 +01:00
|
|
|
sudo -u admin chmod 755 /home/admin/config.scripts/*.sh
|
|
|
|
sudo -u admin cp -r /home/admin/raspiblitz/home.admin/setup.scripts /home/admin/
|
|
|
|
sudo -u admin chmod 755 /home/admin/setup.scripts/*.sh
|
2021-03-15 23:16:27 +01:00
|
|
|
|
|
|
|
# install newest version of BlitzPy
|
2021-09-09 15:55:36 +02:00
|
|
|
blitzpy_wheel=$(ls -tR /home/admin/raspiblitz/home.admin/BlitzPy/dist | grep -E "*any.whl" | tail -n 1)
|
2021-03-15 23:16:27 +01:00
|
|
|
blitzpy_version=$(echo ${blitzpy_wheel} | grep -oE "([0-9]\.[0-9]\.[0-9])")
|
2021-12-07 15:00:44 +01:00
|
|
|
echo
|
2021-03-15 23:16:27 +01:00
|
|
|
echo "*** 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
|
|
|
|
|
|
|
|
# make sure lndlibs are patched for compatibility for both Python2 and Python3
|
|
|
|
if ! grep -Fxq "from __future__ import absolute_import" /home/admin/config.scripts/lndlibs/rpc_pb2_grpc.py; then
|
|
|
|
sed -i -E '1 a from __future__ import absolute_import' /home/admin/config.scripts/lndlibs/rpc_pb2_grpc.py
|
|
|
|
fi
|
|
|
|
if ! grep -Eq "^from . import.*" /home/admin/config.scripts/lndlibs/rpc_pb2_grpc.py; then
|
|
|
|
sed -i -E 's/^(import.*_pb2)/from . \1/' /home/admin/config.scripts/lndlibs/rpc_pb2_grpc.py
|
|
|
|
fi
|
|
|
|
|
|
|
|
# add /sbin to path for all
|
|
|
|
sudo bash -c "echo 'PATH=\$PATH:/sbin' >> /etc/profile"
|
|
|
|
|
2021-09-06 16:44:12 +02:00
|
|
|
# replace boot splash image when raspbian
|
|
|
|
if [ "${baseimage}" == "raspbian" ]; then
|
|
|
|
echo "* replacing boot splash"
|
|
|
|
sudo cp /home/admin/raspiblitz/pictures/splash.png /usr/share/plymouth/themes/pix/splash.png
|
|
|
|
fi
|
|
|
|
|
2021-12-07 15:00:44 +01:00
|
|
|
echo
|
2021-03-15 23:16:27 +01:00
|
|
|
echo "*** RASPIBLITZ EXTRAS ***"
|
|
|
|
|
|
|
|
# for background processes
|
|
|
|
sudo apt -y install screen
|
|
|
|
|
|
|
|
# for multiple (detachable/background) sessions when using SSH
|
|
|
|
# https://github.com/rootzoll/raspiblitz/issues/990
|
|
|
|
sudo apt -y install tmux
|
|
|
|
|
|
|
|
# optimization for torrent download
|
|
|
|
sudo bash -c "echo 'net.core.rmem_max = 4194304' >> /etc/sysctl.conf"
|
2021-12-08 17:04:30 +01:00
|
|
|
sudo bash -c "echo 'net.core.wmem_max = 1048576' >> /etc/sysctl.conf"
|
|
|
|
|
|
|
|
# install a command-line fuzzy finder (https://github.com/junegunn/fzf)
|
|
|
|
sudo apt -y install fzf
|
|
|
|
|
|
|
|
sudo bash -c "echo '' >> /home/admin/.bashrc"
|
|
|
|
sudo bash -c "echo '# https://github.com/rootzoll/raspiblitz/issues/1784' >> /home/admin/.bashrc"
|
|
|
|
sudo bash -c "echo 'NG_CLI_ANALYTICS=ci' >> /home/admin/.bashrc"
|
|
|
|
|
|
|
|
homeFile=/home/admin/.bashrc
|
|
|
|
keyBindings="source /usr/share/doc/fzf/examples/key-bindings.bash"
|
|
|
|
keyBindingsDone=$(grep -c "$keyBindings" $homeFile)
|
|
|
|
|
|
|
|
if [ ${keyBindingsDone} -eq 0 ]; then
|
|
|
|
sudo bash -c "echo 'source /usr/share/doc/fzf/examples/key-bindings.bash' >> /home/admin/.bashrc"
|
|
|
|
echo "key-bindings added to $homeFile"
|
|
|
|
else
|
|
|
|
echo "key-bindings already in $homeFile"
|
|
|
|
fi
|
|
|
|
|
|
|
|
homeFile=/home/admin/.bashrc
|
|
|
|
autostart="automatically start main menu"
|
|
|
|
autostartDone=$(grep -c "$autostart" $homeFile)
|
|
|
|
|
|
|
|
if [ ${autostartDone} -eq 0 ]; then
|
|
|
|
# bash autostart for admin
|
|
|
|
sudo bash -c "echo '# shortcut commands' >> /home/admin/.bashrc"
|
|
|
|
sudo bash -c "echo 'source /home/admin/_commands.sh' >> /home/admin/.bashrc"
|
|
|
|
sudo bash -c "echo '# automatically start main menu for admin unless' >> /home/admin/.bashrc"
|
|
|
|
sudo bash -c "echo '# when running in a tmux session' >> /home/admin/.bashrc"
|
|
|
|
sudo bash -c "echo 'if [ -z \"\$TMUX\" ]; then' >> /home/admin/.bashrc"
|
|
|
|
sudo bash -c "echo ' ./00raspiblitz.sh' >> /home/admin/.bashrc"
|
|
|
|
sudo bash -c "echo 'fi' >> /home/admin/.bashrc"
|
|
|
|
echo "autostart added to $homeFile"
|
|
|
|
else
|
|
|
|
echo "autostart already in $homeFile"
|
|
|
|
fi
|
|
|
|
|
|
|
|
sudo bash -c "echo '' >> /home/admin/.bashrc"
|
|
|
|
sudo bash -c "echo '# Raspiblitz' >> /home/admin/.bashrc"
|
|
|
|
|
|
|
|
echo
|
|
|
|
echo "*** SWAP FILE ***"
|
|
|
|
# based on https://raspibolt.github.io/raspibolt/raspibolt_20_pi.html#move-swap-file
|
|
|
|
# but just deactivating and deleting old (will be created alter when user adds HDD)
|
|
|
|
|
|
|
|
sudo dphys-swapfile swapoff
|
|
|
|
sudo dphys-swapfile uninstall
|
|
|
|
|
|
|
|
echo
|
|
|
|
echo "*** INCREASE OPEN FILE LIMIT ***"
|
|
|
|
# based on https://raspibolt.github.io/raspibolt/raspibolt_21_security.html#increase-your-open-files-limit
|
|
|
|
|
|
|
|
sudo sed --in-place -i "56s/.*/* soft nofile 128000/" /etc/security/limits.conf
|
|
|
|
sudo bash -c "echo '* hard nofile 128000' >> /etc/security/limits.conf"
|
|
|
|
sudo bash -c "echo 'root soft nofile 128000' >> /etc/security/limits.conf"
|
|
|
|
sudo bash -c "echo 'root hard nofile 128000' >> /etc/security/limits.conf"
|
|
|
|
sudo bash -c "echo '# End of file' >> /etc/security/limits.conf"
|
|
|
|
|
|
|
|
sudo sed --in-place -i "23s/.*/session required pam_limits.so/" /etc/pam.d/common-session
|
|
|
|
|
|
|
|
sudo sed --in-place -i "25s/.*/session required pam_limits.so/" /etc/pam.d/common-session-noninteractive
|
|
|
|
sudo bash -c "echo '# end of pam-auth-update config' >> /etc/pam.d/common-session-noninteractive"
|
|
|
|
|
|
|
|
|
|
|
|
# *** fail2ban ***
|
|
|
|
# based on https://raspibolt.github.io/raspibolt/raspibolt_21_security.html#fail2ban
|
|
|
|
echo "*** HARDENING ***"
|
|
|
|
sudo apt install -y --no-install-recommends python3-systemd fail2ban
|
|
|
|
|
|
|
|
# *** CACHE DISK IN RAM ***
|
|
|
|
echo "Activating CACHE RAM DISK ... "
|
|
|
|
sudo /home/admin/config.scripts/blitz.cache.sh on
|
|
|
|
|
|
|
|
# *** Wifi, Bluetooth & other configs ***
|
|
|
|
if [ "${baseimage}" = "raspbian" ]||[ "${baseimage}" = "raspios_arm64" ]||\
|
|
|
|
[ "${baseimage}" = "debian_rpi64" ]; then
|
|
|
|
|
|
|
|
if [ "${modeWifi}" == "false" ]; then
|
|
|
|
echo
|
|
|
|
echo "*** DISABLE WIFI ***"
|
|
|
|
sudo systemctl disable wpa_supplicant.service
|
|
|
|
sudo ifconfig wlan0 down
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo
|
|
|
|
echo "*** DISABLE BLUETOOTH ***"
|
|
|
|
|
|
|
|
configFile="/boot/config.txt"
|
|
|
|
disableBT="dtoverlay=disable-bt"
|
|
|
|
disableBTDone=$(grep -c "$disableBT" $configFile)
|
|
|
|
|
|
|
|
if [ ${disableBTDone} -eq 0 ]; then
|
|
|
|
# disable bluetooth module
|
|
|
|
echo >> $configFile
|
|
|
|
echo "# Raspiblitz" >> $configFile
|
|
|
|
echo 'dtoverlay=pi3-disable-bt' | sudo tee -a $configFile
|
|
|
|
echo 'dtoverlay=disable-bt' | sudo tee -a $configFile
|
|
|
|
else
|
|
|
|
echo "disable BT already in $configFile"
|
|
|
|
fi
|
|
|
|
|
|
|
|
# remove bluetooth services
|
|
|
|
sudo systemctl disable bluetooth.service
|
|
|
|
sudo systemctl disable hciuart.service
|
|
|
|
|
|
|
|
# remove bluetooth packages
|
|
|
|
sudo apt remove -y --purge pi-bluetooth bluez bluez-firmware
|
|
|
|
echo
|
|
|
|
|
|
|
|
# disable audio
|
|
|
|
echo "*** DISABLE AUDIO (snd_bcm2835) ***"
|
|
|
|
sudo sed -i "s/^dtparam=audio=on/# dtparam=audio=on/g" /boot/config.txt
|
|
|
|
echo
|
|
|
|
|
|
|
|
# disable DRM VC4 V3D
|
|
|
|
echo "*** DISABLE DRM VC4 V3D driver ***"
|
|
|
|
dtoverlay=vc4-fkms-v3d
|
|
|
|
sudo sed -i "s/^dtoverlay=vc4-fkms-v3d/# dtoverlay=vc4-fkms-v3d/g" /boot/config.txt
|
|
|
|
echo
|
|
|
|
|
|
|
|
# I2C fix (make sure dtparam=i2c_arm is not on)
|
|
|
|
# see: https://github.com/rootzoll/raspiblitz/issues/1058#issuecomment-739517713
|
|
|
|
sudo sed -i "s/^dtparam=i2c_arm=.*//g" /boot/config.txt
|
|
|
|
fi
|
|
|
|
|
|
|
|
# *** FATPACK *** (can be activated by parameter - see details at start of script)
|
|
|
|
if [ "${fatpack}" == "true" ]; then
|
|
|
|
echo "*** FATPACK ***"
|
|
|
|
echo "* Adding nodeJS Framework ..."
|
|
|
|
sudo /home/admin/config.scripts/bonus.nodejs.sh on
|
|
|
|
if [ "$?" != "0" ]; then
|
|
|
|
echo "FATPACK FAILED"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
echo "* Optional Packages (may be needed for extended features)"
|
|
|
|
sudo apt-get install -y qrencode
|
|
|
|
sudo apt-get install -y btrfs-tools
|
|
|
|
sudo apt-get install -y secure-delete
|
|
|
|
sudo apt-get install -y fbi
|
|
|
|
sudo apt-get install -y ssmtp
|
|
|
|
sudo apt-get install -y unclutter xterm python3-pyqt5
|
|
|
|
sudo apt-get install -y xfonts-terminus
|
|
|
|
sudo apt-get install -y nginx apache2-utils
|
|
|
|
sudo apt-get install -y nginx
|
|
|
|
sudo apt-get install -y python3-jinja2
|
|
|
|
sudo apt-get install -y socat
|
|
|
|
sudo apt-get install -y libatlas-base-dev
|
|
|
|
sudo apt-get install -y mariadb-server mariadb-client
|
|
|
|
sudo apt-get install -y hexyl
|
|
|
|
sudo apt-get install -y autossh
|
|
|
|
|
|
|
|
# *** UPDATE FALLBACK NODE LIST (only as part of fatpack) *** see https://github.com/rootzoll/raspiblitz/issues/1888
|
|
|
|
echo "*** FALLBACK NODE LIST ***"
|
|
|
|
sudo -u admin curl -H "Accept: application/json; indent=4" https://bitnodes.io/api/v1/snapshots/latest/ -o /home/admin/fallback.nodes
|
|
|
|
byteSizeList=$(sudo -u admin stat -c %s /home/admin/fallback.nodes)
|
|
|
|
if [ ${#byteSizeList} -eq 0 ] || [ ${byteSizeList} -lt 10240 ]; then
|
|
|
|
echo "WARN: Failed downloading fresh FALLBACK NODE LIST --> https://bitnodes.io/api/v1/snapshots/latest/"
|
|
|
|
sudo rm /home/admin/fallback.nodes 2>/dev/null
|
|
|
|
sudo cp /home/admin/assets/fallback.nodes /home/admin/fallback.nodes
|
|
|
|
fi
|
|
|
|
sudo chown admin:admin /home/admin/fallback.nodes
|
|
|
|
|
|
|
|
else
|
|
|
|
echo "* skipping FATPACK"
|
|
|
|
fi
|
|
|
|
|
|
|
|
# *** BOOTSTRAP ***
|
|
|
|
echo
|
|
|
|
echo "*** RASPI BOOTSTRAP SERVICE ***"
|
|
|
|
sudo chmod +x /home/admin/_bootstrap.sh
|
|
|
|
sudo cp /home/admin/assets/bootstrap.service /etc/systemd/system/bootstrap.service
|
|
|
|
sudo systemctl enable bootstrap
|
|
|
|
|
|
|
|
# *** BACKGROUND ***
|
|
|
|
echo
|
|
|
|
echo "*** RASPI BACKGROUND SERVICE ***"
|
|
|
|
sudo chmod +x /home/admin/_background.sh
|
|
|
|
sudo cp /home/admin/assets/background.service /etc/systemd/system/background.service
|
|
|
|
sudo systemctl enable background
|
|
|
|
|
|
|
|
###########
|
|
|
|
# BITCOIN #
|
|
|
|
###########
|
|
|
|
echo
|
|
|
|
/home/admin/config.scripts/bitcoin.install.sh install || exit 1
|
|
|
|
|
|
|
|
#######
|
|
|
|
# LND #
|
|
|
|
#######
|
|
|
|
echo
|
|
|
|
/home/admin/config.scripts/lnd.install.sh install || exit 1
|
|
|
|
|
|
|
|
###############
|
|
|
|
# C-LIGHTNING #
|
|
|
|
###############
|
|
|
|
echo
|
|
|
|
/home/admin/config.scripts/cl.install.sh install || exit 1
|
|
|
|
|
|
|
|
echo
|
|
|
|
echo "*** raspiblitz.info ***"
|
|
|
|
sudo cat /home/admin/raspiblitz.info
|
|
|
|
|
|
|
|
# *** RASPIBLITZ IMAGE READY INFO ***
|
|
|
|
echo
|
|
|
|
echo "**********************************************"
|
|
|
|
echo "BASIC SD CARD BUILD DONE"
|
|
|
|
echo "**********************************************"
|
|
|
|
echo
|
|
|
|
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."
|
|
|
|
echo
|
|
|
|
echo "IMPORTANT IF WANT TO MAKE A RELEASE IMAGE FROM THIS BUILD:"
|
|
|
|
echo "1. login fresh --> user:admin password:raspiblitz"
|
|
|
|
echo "2. run --> release"
|
|
|
|
echo
|
|
|
|
|
|
|
|
# (do last - because might trigger reboot)
|
|
|
|
if [ "${displayClass}" != "headless" ] || [ "${baseimage}" = "raspbian" ] || [ "${baseimage}" = "raspios_arm64" ]; then
|
|
|
|
echo "*** ADDITIONAL DISPLAY OPTIONS ***"
|
|
|
|
echo "- calling: blitz.display.sh set-display ${displayClass}"
|
|
|
|
sudo /home/admin/config.scripts/blitz.display.sh set-display ${displayClass}
|
|
|
|
sudo /home/admin/config.scripts/blitz.display.sh rotate 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "# BUILD DONE - see above"
|
|
|
|
|
|
|
|
# optimization for torrent download
|
|
|
|
sudo bash -c "echo 'net.core.rmem_max = 4194304' >> /etc/sysctl.conf"
|
2021-03-15 23:16:27 +01:00
|
|
|
sudo bash -c "echo 'net.core.wmem_max = 1048576' >> /etc/sysctl.conf"
|
|
|
|
|
|
|
|
# install a command-line fuzzy finder (https://github.com/junegunn/fzf)
|
|
|
|
sudo apt -y install fzf
|
|
|
|
|
|
|
|
sudo bash -c "echo '' >> /home/admin/.bashrc"
|
|
|
|
sudo bash -c "echo '# https://github.com/rootzoll/raspiblitz/issues/1784' >> /home/admin/.bashrc"
|
|
|
|
sudo bash -c "echo 'NG_CLI_ANALYTICS=ci' >> /home/admin/.bashrc"
|
|
|
|
|
|
|
|
homeFile=/home/admin/.bashrc
|
|
|
|
keyBindings="source /usr/share/doc/fzf/examples/key-bindings.bash"
|
2021-03-23 14:06:02 +01:00
|
|
|
keyBindingsDone=$(grep -c "$keyBindings" $homeFile)
|
2021-03-15 23:16:27 +01:00
|
|
|
|
|
|
|
if [ ${keyBindingsDone} -eq 0 ]; then
|
|
|
|
sudo bash -c "echo 'source /usr/share/doc/fzf/examples/key-bindings.bash' >> /home/admin/.bashrc"
|
|
|
|
echo "key-bindings added to $homeFile"
|
|
|
|
else
|
|
|
|
echo "key-bindings already in $homeFile"
|
|
|
|
fi
|
|
|
|
|
2021-04-08 22:17:34 +02:00
|
|
|
homeFile=/home/admin/.bashrc
|
|
|
|
autostart="automatically start main menu"
|
|
|
|
autostartDone=$(grep -c "$autostart" $homeFile)
|
|
|
|
|
|
|
|
if [ ${autostartDone} -eq 0 ]; then
|
|
|
|
# bash autostart for admin
|
|
|
|
sudo bash -c "echo '# shortcut commands' >> /home/admin/.bashrc"
|
|
|
|
sudo bash -c "echo 'source /home/admin/_commands.sh' >> /home/admin/.bashrc"
|
|
|
|
sudo bash -c "echo '# automatically start main menu for admin unless' >> /home/admin/.bashrc"
|
|
|
|
sudo bash -c "echo '# when running in a tmux session' >> /home/admin/.bashrc"
|
|
|
|
sudo bash -c "echo 'if [ -z \"\$TMUX\" ]; then' >> /home/admin/.bashrc"
|
|
|
|
sudo bash -c "echo ' ./00raspiblitz.sh' >> /home/admin/.bashrc"
|
|
|
|
sudo bash -c "echo 'fi' >> /home/admin/.bashrc"
|
|
|
|
echo "autostart added to $homeFile"
|
|
|
|
else
|
|
|
|
echo "autostart already in $homeFile"
|
|
|
|
fi
|
|
|
|
|
|
|
|
sudo bash -c "echo '' >> /home/admin/.bashrc"
|
|
|
|
sudo bash -c "echo '# Raspiblitz' >> /home/admin/.bashrc"
|
|
|
|
|
2021-12-07 15:00:44 +01:00
|
|
|
echo
|
2018-08-06 11:46:22 +02:00
|
|
|
echo "*** SWAP FILE ***"
|
2021-11-11 15:53:16 +01:00
|
|
|
# based on https://raspibolt.github.io/raspibolt/raspibolt_20_pi.html#move-swap-file
|
2018-08-06 01:03:17 +02:00
|
|
|
# but just deactivating and deleting old (will be created alter when user adds HDD)
|
|
|
|
|
|
|
|
sudo dphys-swapfile swapoff
|
|
|
|
sudo dphys-swapfile uninstall
|
|
|
|
|
2021-12-07 15:00:44 +01:00
|
|
|
echo
|
2018-08-06 11:46:22 +02:00
|
|
|
echo "*** INCREASE OPEN FILE LIMIT ***"
|
2021-11-11 15:53:16 +01:00
|
|
|
# based on https://raspibolt.github.io/raspibolt/raspibolt_21_security.html#increase-your-open-files-limit
|
2018-08-06 01:03:17 +02:00
|
|
|
|
|
|
|
sudo sed --in-place -i "56s/.*/* soft nofile 128000/" /etc/security/limits.conf
|
|
|
|
sudo bash -c "echo '* hard nofile 128000' >> /etc/security/limits.conf"
|
|
|
|
sudo bash -c "echo 'root soft nofile 128000' >> /etc/security/limits.conf"
|
|
|
|
sudo bash -c "echo 'root hard nofile 128000' >> /etc/security/limits.conf"
|
|
|
|
sudo bash -c "echo '# End of file' >> /etc/security/limits.conf"
|
|
|
|
|
|
|
|
sudo sed --in-place -i "23s/.*/session required pam_limits.so/" /etc/pam.d/common-session
|
|
|
|
|
|
|
|
sudo sed --in-place -i "25s/.*/session required pam_limits.so/" /etc/pam.d/common-session-noninteractive
|
|
|
|
sudo bash -c "echo '# end of pam-auth-update config' >> /etc/pam.d/common-session-noninteractive"
|
|
|
|
|
2021-03-15 23:16:27 +01:00
|
|
|
|
|
|
|
# *** fail2ban ***
|
2021-11-11 15:53:16 +01:00
|
|
|
# based on https://raspibolt.github.io/raspibolt/raspibolt_21_security.html#fail2ban
|
2021-03-15 23:16:27 +01:00
|
|
|
echo "*** HARDENING ***"
|
|
|
|
sudo apt install -y --no-install-recommends python3-systemd fail2ban
|
|
|
|
|
|
|
|
# *** CACHE DISK IN RAM ***
|
|
|
|
echo "Activating CACHE RAM DISK ... "
|
|
|
|
sudo /home/admin/config.scripts/blitz.cache.sh on
|
|
|
|
|
2021-04-08 00:02:57 +02:00
|
|
|
# *** Wifi, Bluetooth & other configs ***
|
2021-04-03 12:24:50 +02:00
|
|
|
if [ "${baseimage}" = "raspbian" ]||[ "${baseimage}" = "raspios_arm64" ]||\
|
|
|
|
[ "${baseimage}" = "debian_rpi64" ]; then
|
2021-03-15 23:16:27 +01:00
|
|
|
|
|
|
|
if [ "${modeWifi}" == "false" ]; then
|
2021-12-07 15:00:44 +01:00
|
|
|
echo
|
2021-03-15 23:16:27 +01:00
|
|
|
echo "*** DISABLE WIFI ***"
|
|
|
|
sudo systemctl disable wpa_supplicant.service
|
|
|
|
sudo ifconfig wlan0 down
|
|
|
|
fi
|
|
|
|
|
2021-12-07 15:00:44 +01:00
|
|
|
echo
|
2021-03-15 23:16:27 +01:00
|
|
|
echo "*** DISABLE BLUETOOTH ***"
|
|
|
|
|
|
|
|
configFile="/boot/config.txt"
|
|
|
|
disableBT="dtoverlay=disable-bt"
|
2021-03-23 14:06:02 +01:00
|
|
|
disableBTDone=$(grep -c "$disableBT" $configFile)
|
2021-03-15 23:16:27 +01:00
|
|
|
|
|
|
|
if [ ${disableBTDone} -eq 0 ]; then
|
|
|
|
# disable bluetooth module
|
2021-12-07 15:00:44 +01:00
|
|
|
echo >> $configFile
|
|
|
|
echo "# Raspiblitz" >> $configFile
|
2021-03-15 23:16:27 +01:00
|
|
|
echo 'dtoverlay=pi3-disable-bt' | sudo tee -a $configFile
|
|
|
|
echo 'dtoverlay=disable-bt' | sudo tee -a $configFile
|
|
|
|
else
|
|
|
|
echo "disable BT already in $configFile"
|
|
|
|
fi
|
|
|
|
|
|
|
|
# remove bluetooth services
|
|
|
|
sudo systemctl disable bluetooth.service
|
|
|
|
sudo systemctl disable hciuart.service
|
|
|
|
|
|
|
|
# remove bluetooth packages
|
|
|
|
sudo apt remove -y --purge pi-bluetooth bluez bluez-firmware
|
|
|
|
echo
|
2021-04-08 00:02:57 +02:00
|
|
|
|
|
|
|
# disable audio
|
2021-03-15 23:16:27 +01:00
|
|
|
echo "*** DISABLE AUDIO (snd_bcm2835) ***"
|
|
|
|
sudo sed -i "s/^dtparam=audio=on/# dtparam=audio=on/g" /boot/config.txt
|
|
|
|
echo
|
|
|
|
|
2021-04-08 00:02:57 +02:00
|
|
|
# disable DRM VC4 V3D
|
2021-03-15 23:16:27 +01:00
|
|
|
echo "*** DISABLE DRM VC4 V3D driver ***"
|
|
|
|
dtoverlay=vc4-fkms-v3d
|
|
|
|
sudo sed -i "s/^dtoverlay=vc4-fkms-v3d/# dtoverlay=vc4-fkms-v3d/g" /boot/config.txt
|
2021-04-08 00:02:57 +02:00
|
|
|
echo
|
2021-03-15 23:16:27 +01:00
|
|
|
|
2021-04-08 00:02:57 +02:00
|
|
|
# I2C fix (make sure dtparam=i2c_arm is not on)
|
|
|
|
# see: https://github.com/rootzoll/raspiblitz/issues/1058#issuecomment-739517713
|
|
|
|
sudo sed -i "s/^dtparam=i2c_arm=.*//g" /boot/config.txt
|
2021-03-15 23:16:27 +01:00
|
|
|
fi
|
|
|
|
|
|
|
|
# *** FATPACK *** (can be activated by parameter - see details at start of script)
|
|
|
|
if [ "${fatpack}" == "true" ]; then
|
|
|
|
echo "*** FATPACK ***"
|
|
|
|
echo "* Adding nodeJS Framework ..."
|
|
|
|
sudo /home/admin/config.scripts/bonus.nodejs.sh on
|
|
|
|
if [ "$?" != "0" ]; then
|
|
|
|
echo "FATPACK FAILED"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
echo "* Optional Packages (may be needed for extended features)"
|
|
|
|
sudo apt-get install -y qrencode
|
|
|
|
sudo apt-get install -y btrfs-tools
|
|
|
|
sudo apt-get install -y secure-delete
|
|
|
|
sudo apt-get install -y fbi
|
|
|
|
sudo apt-get install -y ssmtp
|
|
|
|
sudo apt-get install -y unclutter xterm python3-pyqt5
|
|
|
|
sudo apt-get install -y xfonts-terminus
|
|
|
|
sudo apt-get install -y nginx apache2-utils
|
|
|
|
sudo apt-get install -y nginx
|
|
|
|
sudo apt-get install -y python3-jinja2
|
|
|
|
sudo apt-get install -y socat
|
|
|
|
sudo apt-get install -y libatlas-base-dev
|
|
|
|
sudo apt-get install -y mariadb-server mariadb-client
|
|
|
|
sudo apt-get install -y hexyl
|
|
|
|
sudo apt-get install -y autossh
|
|
|
|
|
2021-04-03 12:24:50 +02:00
|
|
|
# *** UPDATE FALLBACK NODE LIST (only as part of fatpack) *** see https://github.com/rootzoll/raspiblitz/issues/1888
|
|
|
|
echo "*** FALLBACK NODE LIST ***"
|
|
|
|
sudo -u admin curl -H "Accept: application/json; indent=4" https://bitnodes.io/api/v1/snapshots/latest/ -o /home/admin/fallback.nodes
|
|
|
|
byteSizeList=$(sudo -u admin stat -c %s /home/admin/fallback.nodes)
|
|
|
|
if [ ${#byteSizeList} -eq 0 ] || [ ${byteSizeList} -lt 10240 ]; then
|
|
|
|
echo "WARN: Failed downloading fresh FALLBACK NODE LIST --> https://bitnodes.io/api/v1/snapshots/latest/"
|
|
|
|
sudo rm /home/admin/fallback.nodes 2>/dev/null
|
|
|
|
sudo cp /home/admin/assets/fallback.nodes /home/admin/fallback.nodes
|
|
|
|
fi
|
|
|
|
sudo chown admin:admin /home/admin/fallback.nodes
|
|
|
|
|
2021-03-15 23:16:27 +01:00
|
|
|
else
|
|
|
|
echo "* skipping FATPACK"
|
|
|
|
fi
|
|
|
|
|
|
|
|
# *** BOOTSTRAP ***
|
2021-12-07 15:00:44 +01:00
|
|
|
echo
|
2021-03-15 23:16:27 +01:00
|
|
|
echo "*** RASPI BOOTSTRAP SERVICE ***"
|
|
|
|
sudo chmod +x /home/admin/_bootstrap.sh
|
|
|
|
sudo cp /home/admin/assets/bootstrap.service /etc/systemd/system/bootstrap.service
|
|
|
|
sudo systemctl enable bootstrap
|
|
|
|
|
|
|
|
# *** BACKGROUND ***
|
2021-12-07 15:00:44 +01:00
|
|
|
echo
|
2021-03-15 23:16:27 +01:00
|
|
|
echo "*** RASPI BACKGROUND SERVICE ***"
|
|
|
|
sudo chmod +x /home/admin/_background.sh
|
|
|
|
sudo cp /home/admin/assets/background.service /etc/systemd/system/background.service
|
|
|
|
sudo systemctl enable background
|
|
|
|
|
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
|
|
|
|
2021-12-07 15:00:44 +01:00
|
|
|
#######
|
|
|
|
# LND #
|
|
|
|
#######
|
2021-09-14 13:29:51 +02:00
|
|
|
echo
|
2021-12-07 15:00:44 +01:00
|
|
|
/home/admin/config.scripts/lnd.install.sh install || exit 1
|
2021-08-16 19:41:45 +02:00
|
|
|
|
2021-12-07 15:00:44 +01:00
|
|
|
###############
|
|
|
|
# C-LIGHTNING #
|
|
|
|
###############
|
|
|
|
echo
|
|
|
|
/home/admin/config.scripts/cl.install.sh install || exit 1
|
2021-08-16 19:41:45 +02:00
|
|
|
|
2021-12-07 15:00:44 +01:00
|
|
|
echo
|
2021-04-08 00:02:57 +02:00
|
|
|
echo "*** raspiblitz.info ***"
|
|
|
|
sudo 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-07 15:00:44 +01:00
|
|
|
echo
|
2019-12-10 14:27:51 +01:00
|
|
|
echo "**********************************************"
|
2021-04-08 00:02:57 +02:00
|
|
|
echo "BASIC SD CARD BUILD DONE"
|
2019-12-10 14:27:51 +01:00
|
|
|
echo "**********************************************"
|
2021-12-07 15:00:44 +01:00
|
|
|
echo
|
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-07 15:00:44 +01:00
|
|
|
echo
|
2019-12-10 14:27:51 +01:00
|
|
|
echo "IMPORTANT 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-06-24 19:50:43 +02:00
|
|
|
echo "2. run --> release"
|
2021-12-07 15:00:44 +01:00
|
|
|
echo
|
2019-02-04 21:01:33 +01:00
|
|
|
|
2021-04-08 00:02:57 +02:00
|
|
|
# (do last - because might trigger reboot)
|
2021-04-09 16:09:57 +02:00
|
|
|
if [ "${displayClass}" != "headless" ] || [ "${baseimage}" = "raspbian" ] || [ "${baseimage}" = "raspios_arm64" ]; then
|
2021-04-08 00:02:57 +02:00
|
|
|
echo "*** ADDITIONAL DISPLAY OPTIONS ***"
|
|
|
|
echo "- calling: blitz.display.sh set-display ${displayClass}"
|
2021-04-09 16:09:57 +02:00
|
|
|
sudo /home/admin/config.scripts/blitz.display.sh set-display ${displayClass}
|
2021-09-05 12:45:03 +02:00
|
|
|
sudo /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"
|