Raspberry Pi 1e installation

--------
Before 1e boot:

Add "ssh" file In The Boot Partition

"ssh" is empty

--------

Find ip-adres in router and log in via ssh (user: pi, password: raspberry)

Add user and make sure it has the same UID as your other machines (for convenience):

in "/etc/passwd" you cab find the UID of users

Add user:
adduser user_name

Change UID with command:
usermod -u 1001 user_name

Add new user to all the groups 'pi' is also in:

File "/etc/group"
Change all entries. For example: adm:x:4:pi becomes adm_x:username,pi")

Add new user to sudo:
usermod -aG sudo user_name

REBOOT SYSTEEM!

Login as new user and test (don't forget to test sudo!

Remove pi-user:
sudo deluser -remove-home pi
sudo rm -vf /etc/sudoers.d/010_pi-nopasswd

----

SSH loggin without password:
On local-machine (if not already done, check with "ls ~/.ssh/id_*"):
    ssh-keygen -t rsa -b 4096
    
Copy the keu:
    ssh-copy-id remote_username@server_ip_address

Log in on remote, now without passworrd

Disable login with password on remote: (optional; don't loose the key!)
open file "/etc/ssh/sshd_config"

Change:
    PasswordAuthentication no
    ChallengeResponseAuthentication no
    UsePAM no
    
Restart ssh deamon:
sudo /etc/init.d/ssh reload

----

Change login schreen by editing the text file "/etc/motd".

Change the "sshd_config" to (if you now get two motd's, change it back to no)
    PrintMotd yes
    
----
    Change hostname:

sudo nano /etc/hostname
sudo nano /etc/hosts


---
LOCALE settings

sudo raspi-config
Than Localisation options / change locale (en_US.UTF-8 UTF-8)
and also time-zone

-----

Update system:
sudo apt-get update
sudo apt-get upgrade

---

Apache webserver and php

sudo apt-get install apache2 php
sudo chown www-data:www-data /var/www/html/
sudo usermod -aG www-data marcel
sudo chmod g+w /var/www/html/
install index.html in /var/www/html

---

Add firewall:

sudo apt install ufw
sudo ufw allow ssh
sudo ufw allow http
sudo ufw allow https
sudo ufw enable
sudo ufw status
------

Enable I2C RTC

sudo rapi-config
    enable i2c
sudo reboot

sudo apt-get install i2c-tools

sudo i2cdetect -y 1
    #68 is RTC

sudo nano /boot/config.txt
    dtoverlay=i2c-rtc,ds1307
    
sudo reboot
sudo i2cdetect -y 1
You should see a wall of text appear, if UU appears instead of 68 then we have successfully loaded in the Kernel driver for our RTC circuit.

Disable fake hardware clock:
sudo apt-get -y remove fake-hwclock
sudo update-rc.d -f fake-hwclock remove
sudo systemctl disable fake-hwclock


sudo nano /lib/udev/hwclock-set
    Find

    if [ -e /run/systemd/system ] ; then
        exit 0
    fi

    Replace With

    #if [ -e /run/systemd/system ] ; then
    #    exit 0
    #fi


Also comment out the two lines
    /sbin/hwclock --rtc=$dev --systz --badyear
and
    /sbin/hwclock --rtc=$dev --systz

Read RTC:
sudo hwclock -r

Set RTC from system time:
sudo hwclock -w

----

Direwolf:
sudo apt-get install git
sudo apt-get install cmake
sudo apt-get install libasound2-dev
sudo apt-get install libudev-dev
cd ~
cd direwolf
mkdir build && cd build
cmake -DUNITTEST=1 ..
make -j4
make test
sudo make install

make install-conf

edit direwolf.conf:
    ADEVICE plughw:1,0
    CHANNEL 0
    MYCALL MYCALL-0
    MODEM 1200
    PTT GPIO 18
    DCD GPIO 17
    TXDELAY 40
    TXTAIL 5
    AGWPORT 8000
    KISSPORT 8001
    <REST: leave at default>

Add user to gpio-group:
sudo usermod -aG gpio marcel

----
AX25 support

sudo apt-get install libax25 ax25-apps ax25-tools
sudo nano /etc/ax25/axports
add:
   ax0     PE1RXF-0        1200    255     2       144.800 MHz (1200 bps)
   ax1     PE1RXF-1        9600    255     2       External radio    
   
---
APRX software

sudo apt-get install aprx
sudo systemctl enable aprx

----

gnuplot:

sudo apt install gnuplot

-----

kissattach and kissutil can only be executed as root. But we don't want to enter a password when starting the pe1rxf-scripts as the aprs-server has to work autonomous. We also don't want to run all the scripts as root, because that's a safety risk. The solution is to add the following lines to the sudoers-file:

sudo visudo
    marcel ALL = (root) NOPASSWD: /usr/sbin/kissattach
    marcel ALL = (root) NOPASSWD: /usr/sbin/kissparms

---

Install software from PE1RXF (meezenest.nl/mees):

Start ax.25 interfaces (direwolf and kiss) in crontab of user marcel.
Delay of 60 sec, otherwise direwolf will not start. Probably no sound card module loaded at time crontab is executed:

crontab -l

Add:
    # Start APRS server at boot time
    @reboot sleep 60 && /home/marcel/ham/start_aprs_server.sh

A default crontab is included in the ham/aprs_utils directory. Two more processes are in there for the custom telemetry.

The web-interface uses php to do some tasks. Make sure that at least the following files and directories can be accessed by user www-data:
    ham/aprs_utils/aprs_files_to_transmit/ (rwx)
    ham/aprs_utils/aprs_log/ (rwx)
    ham/aprs_utils/send_message.sh (rx)
    
Make a symbolic link from ham/web-interface/ to /var/log/www/html/ and place all web-files in this folder.

MAKE IMAGE OF SD_KAART!
Use the script 'pishrink.sh' to compress the image.
At 1st boot, the image is automatically expanded (or not if you have choosen to to it manually. Than do that with sudo raspi-config.
