Merge pull request #33 from necro-nemesis/master

Bring backup up to speed
backup
necro-nemesis 6 years ago committed by GitHub
commit 3b569c510d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -22,47 +22,78 @@ This project branches from the work of Raspap and SB Admin 2.
- [Prerequisites](#prerequisites)
- [Quick installer](#quick-installer)
- [Test Site](#test-site)
- [Support us](#support-us)
- [Manual installation](#manual-installation)
- [Multilingual support](#multilingual-support)
- [Optional services](#optional-services)
- [How to contribute](#how-to-contribute)
- [License](#license)
## Prerequisites
Start with a clean install of the [latest release of Raspbian](https://www.raspberrypi.org/downloads/raspbian/) (currently Stretch). Raspbian Stretch Lite is recommended.
Start with a clean install of the [latest release of Raspbian](https://www.raspberrypi.org/downloads/raspbian/) (currently Buster and Stretch are verified as working). Lite versions are recommended. If using Raspbian Buster you will need to run the command ```sudo apt-get update --allow-releaseinfo-change``` then elevate to root with ```sudo su``` before running the LokiAP installer script.
For Orange Pi Zero use Armbian Stretch found here: https://dl.armbian.com/orangepizero/
For OrangePi Zero you can use an Armbian Buster "nightly" found here": https://dl.armbian.com/orangepizero/nightly/ or stable Armbian Stretch found here: https://dl.armbian.com/orangepizero/
For Orange Pi R1 use Armbian Stretch found here: https://dl.armbian.com/orangepi-r1/
For Orange Pi R1 you can use Armbian Buster "nightly" found here: https://dl.armbian.com/orangepi-r1/nightly/ or stable Stretch found here: https://dl.armbian.com/orangepi-r1/
1. Update Raspbian/Armbian, including the kernel and firmware, followed by a reboot:
Be aware "nightly" Armbian releases can be unstable but are needed to run Buster. If in doubt use a Stretch release build.
To burn the image to an SD card on your PC you can use Etcher:
https://www.balena.io/etcher/
## Preparing the image
For Raspbian you will need to remove the SD card from the computer, reinsert it, open the boot directory up and create a new textfile file named `ssh` with no .txt file extension i.e. just `ssh` in order to remotely connect. This step is not required for Armbian.
Insert the SD card into the device and power it up.
## Accessing the device
Obtain a copy of Putty and install it on your PC:
https://www.chiark.greenend.org.uk/~sgtatham/putty/latest.html
1. Log into your router from your PC and find the address it assigned to the Pi.
2. Start Putty up and enter this obtained address into Putty with settings:
Host Name Address = the address obtained from router | Port `22` | connection type `SSH` | then `OPEN`
For Raspbian the default login is `root` password `raspberry`
For Armbian the default login is `root` password `1234`
3. Follow any first user password instructions provided once logged in.
4. If you want to get the lastest updates before installing LokiAP:
```
sudo apt-get update
sudo apt-get dist-upgrade
sudo apt-get upgrade
sudo reboot
```
2. Set the WiFi country in raspi-config's / armbian-config's **Localisation Options**: `sudo raspi-config` or 'sudo arbmian-config' for RasperryPi or OrangePi respectively.
5. Set the WiFi country in raspi-config's / armbian-config's **Localisation Options**: `sudo raspi-config` or `sudo arbmian-config` for RasperryPi or OrangePi respectively.
3. If you have an older Raspberry Pi without an onboard WiFi chipset, the [**Edimax Wireless 802.11b/g/n nano USB adapter**](https://www.edimax.com/edimax/merchandise/merchandise_detail/data/edimax/global/wireless_adapters_n150/ew-7811un) is an excellent option it's small, cheap and has good driver support.
6. If you have an older Raspberry Pi without an onboard WiFi chipset, the [**Edimax Wireless 802.11b/g/n nano USB adapter**](https://www.edimax.com/edimax/merchandise/merchandise_detail/data/edimax/global/wireless_adapters_n150/ew-7811un) is an excellent option it's small, cheap and has good driver support.
With the prerequisites done, you can proceed with either the Quick installer or Manual installation steps below.
## Quick installer
Install LokiAP from shell prompt:
```sh
$ wget -q https://git.io/fjeSw -O /tmp/raspap && bash /tmp/raspap
```
The installer will complete the steps in the manual installation (below) for you.
The installer will complete the steps in the manual installation (below) for you. You will be occasionally prompted to answer `y` or `n`. Answering yes to all prompts will in almost all cases be the answer you want so if in doubt respond with `y` that you want the default set up and the AP will work.
After the reboot at the end of the installation the wireless network will be
configured as an access point as follows:
* IP address: 10.3.141.1
* Username: admin
* Password: secret
* Username: `admin`
* Password: `secret`
* DHCP range: 10.3.141.1 to 10.3.141.24
* SSID: `loki-access`
* Password: ChangeMe
* Password: `ChangeMe`
## Test site
To test the connection navigate to Loki's wiki page found at
http://icxqqcpd3sfkjbqifn53h7rmusqa1fyxwqyfrrcgkd37xcikwa7y.loki/wiki/index.php?title=Main_Page
## Support us

@ -14,4 +14,4 @@ nohook lookup-hostname
interface wlan0
static ip_address=10.3.141.1/24
static routers=10.3.141.1
static domain_name_server=1.1.1.1 8.8.8.8
static domain_name_server=1.1.1.1 127.3.2.1

@ -1,5 +1,9 @@
interface=wlan0
dhcp-range=10.3.141.1,10.3.141.24,255.255.255.0,12h
bind-dynamic
domain-needed
bogus-priv
no-resolv
server=/loki/127.3.2.1
server=127.0.0.1
server=1.1.1.1

@ -1,17 +1,40 @@
driver=nl80211
ctrl_interface=/var/run/hostapd
ctrl_interface_group=0
beacon_int=100
auth_algs=1
wpa_key_mgmt=WPA-PSK
beacon_int=100
ssid=loki-access
channel=1
channel=6
hw_mode=g
ieee80211n=1
wme_enabled=1
wpa_passphrase=ChangeMe
interface=wlan0
wpa=1
wpa_pairwise=TKIP
country_code=
wpa=2
wpa_pairwise=CCMP
country_code=US
ignore_broadcast_ssid=0
#driver=nl80211
#ctrl_interface=/var/run/hostapd
#ctrl_interface_group=0
#beacon_int=100
#auth_algs=1
#wpa_key_mgmt=WPA-PSK
#ssid=loki-access
#channel=1
#hw_mode=g
#wpa_passphrase=ChangeMe
#interface=wlan0
#wpa=1
#wpa_pairwise=TKIP
#country_code=
## Rapberry Pi 3 specific to on board WLAN/WiFi
#ieee80211n=1 # 802.11n support (Raspberry Pi 3)
#wmm_enabled=1 # QoS support (Raspberry Pi 3)

@ -0,0 +1,24 @@
#!/usr/sbin/nft -f
flush ruleset
table inet filter {
chain input {
type filter hook input priority 0;
}
chain forward {
type filter hook forward priority 0;
}
chain output {
type filter hook output priority 0;
}
}
table ip nat {
chain postrouting {
type nat hook postrouting priority 0; policy accept;
oifname "lokitun0" ip saddr 10.3.141.0/24 counter masquerade
counter masquerade
}
}

@ -345,6 +345,7 @@ function DisplayLokinetConfig()
{
exec('pidof lokinet | wc -l', $lokinetstatus);
$rulestate = exec("ip rule show default | grep lokinet | awk {'print $5'}", $output);
$lokiversion = exec("dpkg -s lokinet | grep '^Version:'", $output);
if ($lokinetstatus[0] == 0) {
$status = '<div class="alert alert-danger alert-dismissable">Lokinet daemon is not running
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button></div>';
@ -370,7 +371,8 @@ function DisplayLokinetConfig()
<!-- Tab panes -->
<div class="tab-content">
<p><?php echo $status; ?></p>
<div class="tab-pane fade in active" id="basic">
<p><?php echo "Current Lokinet $lokiversion"; ?></p>
<div class="tab-pane fade in active" id="basic">
<button type="button" class="btn btn-info" data-toggle="collapse" data-target="#instruct">Instructions</button>
<div id="instruct" class="collapse">The 3 buttons below must be armed (red) to connect to Lokinet. If there isn't a current lokinet.ini file found on the system the "Generate.ini" button will be green. The .ini file must be generated prior to connecting to Lokinet by pressing the button which will automatically write the required .ini file. Similarly the absense of a valid bootstrap will be indicated by a green "Bootstrap" button. Applying a bootstrap by pressing the apply button without submitting a valid URL in the textbox area will apply the original default bootstrap in place of one being provided. Stopping the daemon also exits Lokinet. To summarize, if necessary generate the .ini and bootstrap Lokinet then you are able to connect to Lokinet by starting the daemon and letting the network establish itself.
</div>

@ -40,11 +40,21 @@ function RPiVersion() {
'a220a0' => 'Compute Module 3',
'a020a0' => 'Compute Module 3',
'a02100' => 'Compute Module 3+',
//Orange Pi Boards
'orpi' => 'Orange Pi',
'orpizero' => 'Orange Pi Zero',
'orpione' => 'Orange Pi One',
'orpir1' => 'Orange Pi R1',
);
$cpuinfo_array = '';
exec('cat /proc/cpuinfo', $cpuinfo_array);
$rev = trim(array_pop(explode(':',array_pop(preg_grep("/^Revision/", $cpuinfo_array)))));
//Armbian Identification
if ( strpos(file_get_contents("/etc/armbian-release"),'orangepi') !== false) {$rev=orpi;}
if ( strpos(file_get_contents("/etc/armbian-release"),'orangepizero') !== false) {$rev=orpizero;}
if ( strpos(file_get_contents("/etc/armbian-release"),'orangepione') !== false) {$rev=orpione;}
if ( strpos(file_get_contents("/etc/armbian-release"),'orangepi-r1') !== false) {$rev=orpir1;}
if (array_key_exists($rev, $revisions)) {
return $revisions[$rev];
} else {

@ -91,6 +91,10 @@ function install_dependencies() {
install_error "No function definition for install_dependencies"
}
function stop_lokinet(){
sudo systemctl stop lokinet.service
}
# Replaces NetworkManager with DHCPD
function check_for_networkmananger() {
# OVERLOAD THIS
@ -186,6 +190,11 @@ function check_for_old_configs() {
sudo cp /etc/rc.local "$raspap_dir/backups/rc.local.`date +%F-%R`"
sudo ln -sf "$raspap_dir/backups/rc.local.`date +%F-%R`" "$raspap_dir/backups/rc.local"
fi
if [ -f /etc/nftables.conf ]; then
sudo cp /etc/nftables.conf "$raspap_dir/backups/nftables.conf.`date +%F-%R`"
sudo ln -sf "$raspap_dir/backups/nftables.conf.`date +%F-%R`" "$raspap_dir/backups/nftables.conf"
fi
}
# Move configuration file to the correct location
@ -203,15 +212,16 @@ function move_config_file() {
function network_tables() {
install_log "Selecting iptables or nftable rules"
if [ $version -lt 10 ]; then
if [ $version -lt 11 ]; then
install_log "Use iptables"
sudo apt-get -y install iptables
tablerouteA='iptables -t nat -A POSTROUTING -s 10.3.141.0\/24 -o lokitun0 -j MASQUERADE #RASPAP'
tablerouteB='iptables -t nat -A POSTROUTING -j MASQUERADE #RASPAP'
else
install_log "Use nftables"
sudo apt-get -y install nftables
tablerouteA='nft add rule ip nat POSTROUTING oifname "lokitun0" ip saddr 10.3.141.0\/24 counter masquerade #RASPAP'
tablerouteB='nft add rule ip nat POSTROUTING counter masquerade #RASPAP'
sudo apt-get -y purge iptables
sudo systemctl enable nftables.service
fi
}
@ -226,6 +236,9 @@ function default_configuration() {
sudo mv $webroot_dir/config/dnsmasq.conf /etc/dnsmasq.conf || install_error "Unable to move dnsmasq configuration file"
sudo mv $webroot_dir/config/dhcpcd.conf /etc/dhcpcd.conf || install_error "Unable to move dhcpcd configuration file"
sudo mv $webroot_dir/config/head /etc/resolvconf/resolv.conf.d/head || install_error "Unable to move resolvconf head file"
sudo mv $webroot_dir/config/nftables.conf /etc/nftables.conf || install_error "unable to move nftables configuration file"
sudo rm /etc/resolv.conf
sudo ln -s /etc/resolvconf/run/resolv.conf /etc/resolv.conf
sudo resolvconf -u || install_error "Unable to update resolv.conf"
@ -244,7 +257,7 @@ function default_configuration() {
'echo 1 > \/proc\/sys\/net\/ipv4\/ip_forward #RASPAP'
"$tablerouteA"
"$tablerouteB"
'sudo \/var\/lib\/lokinet\/.\/lokilaunch.sh start #RASPAP'
#'sudo \/var\/lib\/lokinet\/.\/lokilaunch.sh start #RASPAP'
)
for line in "${lines[@]}"; do
@ -323,7 +336,16 @@ function patch_system_files() {
# Unmask and enable hostapd.service
sudo systemctl unmask hostapd.service
sudo systemctl enable hostapd.service
}
#crontab daily lokinet updates and log
cat > /var/spool/cron/crontabs/root <<-'EOF'
check daily for lokinet updates and update as required
logfile=/var/log/lokinet_cron_update.txt
0 1 * * 1-7 sudo apt-get update && sudo apt-get -y install lokinet >> "$logfile" 2>&1
0 1 * * 1-7 sudo apt-get -y autoremove >> "$logfile" 2>&1
0 1 * * 1-7 date >> "$logfile"
EOF
}
# Optimize configuration of php-cgi.
@ -382,6 +404,7 @@ function install_raspap() {
config_installation
update_system_packages
install_dependencies
stop_lokinet
check_for_networkmananger
optimize_php
enable_php_lighttpd

@ -9,14 +9,15 @@ function update_system_packages() {
function install_dependencies() {
install_log "Installing required packages"
sudo apt-get -y install curl
echo "Install public key used to sign the lokinet binaries."
curl -s https://deb.imaginary.stream/public.gpg | sudo apt-key add -
echo "deb https://deb.imaginary.stream $(lsb_release -sc) main" | sudo tee /etc/apt/sources.list.d/imaginary.stream.list
sudo apt-get update
sudo apt-get install lighttpd $php_package git hostapd dnsmasq vnstat resolvconf lokinet || install_error "Unable to install dependencies"
sudo yes | apt-get install lighttpd $php_package git hostapd dnsmasq vnstat resolvconf lokinet || install_error "Unable to install dependencies"
}
#Remove NetworkManager, install dhcpd, create symlink to resolvconf.
#Remove NetworkManager and install dhcpd if required.
function check_for_networkmananger() {
install_log "Checking for NetworkManager"
@ -25,8 +26,6 @@ function check_for_networkmananger() {
echo "Network Manager found. Replacing with DHCPCD"
sudo apt-get -y purge network-manager
sudo apt-get -y install dhcpcd5
# sudo rm /etc/resolv.conf
# sudo ln -s ../run/resolvconf/resolv.conf /etc/resolv.conf
fi
}

Loading…
Cancel
Save