diff --git a/.motd b/.motd index cde98af8..7dd5e69d 100644 --- a/.motd +++ b/.motd @@ -1,4 +1,4 @@ -Pi-hole for Android 1.6 [20220908] +Pi-hole for Android 1.7 [20221005] Pi-hole Stats -> padd Install or Update -> p4a-install diff --git a/.poweroff b/.poweroff index e8b9ab26..53871fbb 100644 --- a/.poweroff +++ b/.poweroff @@ -7,3 +7,5 @@ service crond stop service syslog-ng stop bash -c "unchroot am start -a com.android.internal.intent.action.REQUEST_SHUTDOWN" > /dev/null 2>&1 bash -c "unchroot am start -n android/com.android.internal.app.ShutdownActivity" > /dev/null 2>&1 +sleep 3 +read -p "Powering Off..." diff --git a/.reboot b/.reboot index 2252fecd..546c16d5 100644 --- a/.reboot +++ b/.reboot @@ -6,3 +6,5 @@ service xrdp stop service crond stop service syslog-ng stop bash -c "unchroot am start -a android.intent.action.REBOOT" > /dev/null 2>&1 +sleep 3 +read -p "Rebooting..." diff --git a/etc/init.d/ntpd b/etc/init.d/ntpd new file mode 100644 index 00000000..bee03ad6 --- /dev/null +++ b/etc/init.d/ntpd @@ -0,0 +1,154 @@ +#!/bin/bash +# +# ntpd This shell script takes care of starting and stopping +# ntpd (NTPv4 daemon). +# +# chkconfig: - 58 74 +# description: ntpd is the NTPv4 daemon. \ +# The Network Time Protocol (NTP) is used to synchronize the time of \ +# a computer client or server to another server or reference time syntaxhighlight, \ +# such as a radio or satellite receiver or modem. + +# Source function library. +. /etc/init.d/functions + +if [ -f /etc/sysconfig/ntpd ];then + . /etc/sysconfig/ntpd +fi + +ntpconf=/etc/ntp.conf +ntpstep=/etc/ntp/step-tickers + +RETVAL=0 +prog="ntpd" + +sync_hwclock() { + ARC=0 + SRM=0 + UTC=0 + + if [ -f /etc/sysconfig/clock ]; then + . /etc/sysconfig/clock + + # convert old style clock config to new values + if [ "${CLOCKMODE}" = "GMT" ]; then + UTC=true + elif [ "${CLOCKMODE}" = "ARC" ]; then + ARC=true + fi + fi + + CLOCKFLAGS="$CLOCKFLAGS --systohc" + + case "$UTC" in + yes|true) CLOCKFLAGS="$CLOCKFLAGS --utc";; + no|false) CLOCKFLAGS="$CLOCKFLAGS --localtime";; + esac + case "$ARC" in + yes|true) CLOCKFLAGS="$CLOCKFLAGS --arc";; + esac + case "$SRM" in + yes|true) CLOCKFLAGS="$CLOCKFLAGS --srm";; + esac + + action $"Syncing hardware clock to system time" /sbin/hwclock $CLOCKFLAGS +} + +readconf() { + dostep='' + dropstr='' + OPTIND=1 + while getopts ":46aAbc:dD:f:gi:k:l:LnN:p:P:qr:s:t:u:v:V:x" args $OPTIONS; + do + case "$args" in + x) dostep=yes;; + c) ntpconf="$OPTARG";; + u) dropstr="-U $(echo $OPTARG | sed 's/:.*//')";; + esac + done + + [ -x /sbin/ntpd -a -f $ntpconf ] || exit 0 + + tickers='' + if [ -s "$ntpstep" ]; then + tickers=$(sed 's/#.*//' $ntpstep) + echo "$tickers" | grep -qi '[a-z0-9]' && dostep=yes || tickers='' + fi + if [ -n "$dostep" -a -z "$tickers" ]; then + # -x option is used, but step-tickers doesn't exist or contain + # anything useful, use servers from ntp.conf instead + tickers=$(awk '$1=="peer"||$1=="server"{print $2}' $ntpconf | \ + fgrep -v 127.127.1.0) + fi +} + +start() { + # Check that networking is up. + [ "$NETWORKING" = "no" ] && exit 1 + + readconf; + + if [ -n "$dostep" ]; then + echo -n $"$prog: Synchronizing with time server: " + /sbin/ntpdate $dropstr -s -b $NTPDATE_OPTIONS $tickers &>/dev/null + RETVAL=$? + [ $RETVAL -eq 0 ] && success || failure + echo + if [ $RETVAL -eq 0 ]; then + [ "$SYNC_HWCLOCK" = "yes" ] && sync_hwclock + else + OPTIONS="$OPTIONS -g" + fi + else + # -g can replace the grep for time servers + # as it permits ntpd to violate its 1000s limit once. + OPTIONS="$OPTIONS -g" + fi + # Start daemons. + echo -n $"Starting $prog: " + daemon ntpd $OPTIONS + RETVAL=$? + echo + [ $RETVAL -eq 0 ] && touch /var/lock/subsys/ntpd + return $RETVAL +} + +stop() { + echo -n $"Shutting down $prog: " + killproc ntpd + RETVAL=$? + echo + [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/ntpd + return $RETVAL +} + +# See how we were called. +case "$1" in + start) + start + ;; + stop) + stop + ;; + status) + status ntpd + RETVAL=$? + ;; + restart|reload) + stop + start + RETVAL=$? + ;; + condrestart) + if [ -f /var/lock/subsys/ntpd ]; then + stop + start + RETVAL=$? + fi + ;; + *) + echo $"Usage: $0 {start|stop|restart|condrestart|status}" + RETVAL=3 +esac + +exit $RETVAL diff --git a/etc/motd b/etc/motd deleted file mode 100644 index cde98af8..00000000 --- a/etc/motd +++ /dev/null @@ -1,5 +0,0 @@ -Pi-hole for Android 1.6 [20220908] - - Pi-hole Stats -> padd - Install or Update -> p4a-install - diff --git a/etc/rc.local b/etc/rc.local index b7d83ecd..5675c047 100644 --- a/etc/rc.local +++ b/etc/rc.local @@ -1,6 +1,7 @@ #!/bin/bash # Clean-up environment for startup, update PADD, install unbound for new deployment +ntpd -gq curl --silent --output /bin/padd https://raw.githubusercontent.com/pi-hole/PADD/master/padd.sh rm -rf /sbin/service /var/lock/subsys/* /tmp/* /var/run/*.pid /sbin/poweroff /sbin/reboot /bin/pihole /bin/cp /.service /sbin/service ; /bin/cp /.poweroff /sbin/poweroff ; /bin/cp /.reboot /sbin/reboot; /bin/cp /.service /bin/update-rc.d ; ln -s /usr/local/bin/pihole /bin/pihole ; /bin/cp /.systemctl /usr/bin/systemctl ; /bin/cp /.motd /etc/motd @@ -34,13 +35,22 @@ sed -i "/IPV4_ADDRESS/c\IPV4_ADDRESS=$ipaddr/$subnetmask" /etc/pihole/setupVars. sed -i "/PIHOLE_INTERFACE/c\PIHOLE_INTERFACE=$device" /etc/pihole/setupVars.conf # Start Services +yes ' ' | sed 40q +echo '_______________________________________' +echo ' ' +echo ' Pi-hole for Android ' +echo ' ' service syslog-ng start service crond start service dropbear start service xrdp start service lighttpd start service unbound start -service pihole-FTL start + +# Quietly start FTL and get better reporting from pihole status +service pihole-FTL start > /var/log/pihole.log 2>&1 +pihole status +echo '_______________________________________' # This needs to be at the end of rc.local touch /var/lock/subsys/local diff --git a/usr/local/bin/p4a-install b/usr/local/bin/p4a-install index 6e1b4ed9..4ad2c2e0 100644 --- a/usr/local/bin/p4a-install +++ b/usr/local/bin/p4a-install @@ -1,31 +1,12 @@ #!/bin/bash -[[ ! -f /opt/rh/devtoolset-9/root/usr/bin/gcc ]] && yum -y install https://buildlogs.centos.org/c7-devtoolset-9.armhfp/devtoolset-9-binutils/20211015132728/2.32-16.el7.2.armhfp/devtoolset-9-binutils-2.32-16.el7.2.armv7hl.rpm https://buildlogs.centos.org/c7-devtoolset-9.armhfp/devtoolset-9-gcc/20211014113237/9.3.1-2.2.el7.armhfp/devtoolset-9-gcc-9.3.1-2.2.el7.armv7hl.rpm https://buildlogs.centos.org/c7-devtoolset-9.armhfp/devtoolset-9-gcc/20211014113237/9.3.1-2.2.el7.armhfp/devtoolset-9-gcc-c++-9.3.1-2.2.el7.armv7hl.rpm https://buildlogs.centos.org/c7-devtoolset-9.armhfp/devtoolset-9-gcc/20211014113237/9.3.1-2.2.el7.armhfp/devtoolset-9-libstdc++-devel-9.3.1-2.2.el7.armv7hl.rpm https://buildlogs.centos.org/c7-devtoolset-9.armhfp/devtoolset-9/20211013151212/9.1-1.el7.armhfp/devtoolset-9-runtime-9.1-1.el7.armv7hl.rpm scl-utils policycoreutils-python python3-pip python-IPy nettle-devel libidn-devel readline-devel cmake3 +export PIHOLE_SKIP_OS_CHECK=true touch /etc/lighttpd/external.conf -mkdir -p /etc/pihole ; /bin/cp -f /.setupVars /etc/pihole/setupVars.conf -echo v5.16.3 > /etc/pihole/ftlbranch ; export PIHOLE_SKIP_OS_CHECK=true +mkdir -p /etc/pihole +[[ ! -f /etc/pihole/setupVars.conf ]] && /bin/cp -f /.setupVars /etc/pihole/setupVars.conf subnetmask=$(ip route list table main | tail -n1) ; subnetmask=$(cut -d "/" -f2 <<< "$subnetmask") ; subnetmask=$(cut -d " " -f1 <<< "$subnetmask") device=$(ip route list table main | tail -n1 | cut -d' ' -f 3) ipaddr=$(ip route list table main | tail -n1) ; ipaddr=`echo $ipaddr | awk -F' ' ' { print $(NF-0) } '` -clear ; echo Pi-hole for Android // Device: $device // IP: $ipaddr // SubNet: $subnetmask ; echo +printf "\nPi-hole for Android // Device: $device // IP: $ipaddr // SubNet: $subnetmask\n" sed -i "/IPV4_ADDRESS/c\IPV4_ADDRESS=$ipaddr/$subnetmask" /etc/pihole/setupVars.conf sed -i "/PIHOLE_INTERFACE/c\PIHOLE_INTERFACE=$device" /etc/pihole/setupVars.conf -curl -L https://install.pi-hole.net | bash /dev/stdin --unattended -python -c "print('\033[A\033[A\033[A\033[A')" -cd /tmp -rm -rf FTL ; git clone --depth=1 https://github.com/pi-hole/FTL.git -cd FTL - -# Fixups -sed -i 's/cmake/cmake3/g' build.sh -sed -i '/BUS_MCEERR_AR/d' src/signals.c -sed -i '/BUS_MCEERR_AO/d' src/signals.c -sed -i 's/--dirty//g' src/gen_version.cmake - -# Build pihole-FTL with updated CentOS 7 toolchain -echo ; echo "Building pihole-FTL from source. This will take a few minutes..." -scl enable devtoolset-9 ./build.sh >/etc/pihole/install.log 2>&1 - -# Install and Restart pihole-FTL -mkdir -p /var/log/pihole ; chown -R pihole:pihole /var/log/pihole -bash -c "service pihole-FTL stop ; pkill pihole-FTL ; /bin/cp pihole-FTL /usr/bin/pihole-FTL ; service pihole-FTL start ; service lighttpd restart ; pihole-FTL -v > /etc/pihole/ftlbranch" >>/etc/pihole/install.log 2>&1 -echo ; pihole -v ; pihole status ; echo +curl -sSL https://raw.githubusercontent.com/DesktopECHO/pi-hole/master/automated%20install/basic-install.sh | bash /dev/stdin --unattended diff --git a/usr/local/bin/sysprep b/usr/local/bin/sysprep index d70cf1e4..e6d107c3 100644 --- a/usr/local/bin/sysprep +++ b/usr/local/bin/sysprep @@ -12,13 +12,16 @@ rm -rf /root/.bash_history rm -rf /var/log/*.log rm -rf /var/tmp/* rm -rf /var/log/pihole/* +rm -rf /var/log/*.gz rm -rf /var/log/cron +rm -rf /var/log/kern +rm -rf /var/log/systemctl.log rm -rf /var/log/lighttpd/*.log rm -rf /var/log/messages /var/log/secure rm -rf /etc/xrdp/*.pem /etc/xrdp/rsakeys.ini rm -rf /var/cache/yum/armhfp/7/* cd /home/android ; rm -rf .cache .pcsc* .ssh .vnc .rnd .pki .local .Xauthority .xsession* PADD.pid piHoleVersion thinclient_drives /tmp/* /tmp/.* -rpm -e unbound ; rpm -e unbound-libs ; rm -rf /etc/unbound ; rm -rf /var/lib/unbound /var/lib/unbound/root.key.rpmsave +rpm -e unbound ; rpm -e unbound-libs ; rm -rf /etc/unbound ; rm -rf /var/lib/unbound clear echo Turn off this instance and run image backup. sleep 60