Merge pull request #34 from necro-nemesis/master

Bring staging up
staging
necro-nemesis 5 years ago committed by GitHub
commit 1347f25fbc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1,8 +1,8 @@
![](https://i.imgur.com/mXuacOH.jpg)
# `$ Lokiap-webgui` [![Release 1.6b](https://img.shields.io/badge/Release-1.6b-green.svg)](https://github.com/necro-nemesis/raspap-webgui/releases)
# `$ Lokiap-webgui` [![Release 1.7](https://img.shields.io/badge/Release-1.7-green.svg)](https://github.com/necro-nemesis/raspap-webgui/releases)
LokiAP interfaces witht Lokinet daemon to facilitate connections to the the Lokinet global privacy network. LokiAP provides a simple, responsive web interface to control wifi, hostapd and related services necessary to access Lokinet on the Raspberry Pi.
LokiAP interfaces witht Lokinet daemon to facilitate connections to the the Lokinet global privacy network. LokiAP provides a simple, responsive web interface to control wifi, hostapd, Lokinet daemon and related services necessary to access Lokinet on the Raspberry Pi or Orange Pi.
### WHAT IS LOKI?
@ -16,49 +16,84 @@ Loki
This project branches from the work of Raspap and SB Admin 2.
![](https://i.imgur.com/ZmBxM3R.jpg)
![](https://i.imgur.com/qdXbAGn.png)
## Contents
- [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.
1. Update Raspbian, including the kernel and firmware, followed by a reboot:
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 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/
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 **Localisation Options**: `sudo raspi-config`
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 your RaspberryPi's shell prompt:
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
@ -68,105 +103,6 @@ Loki Donation Address:
```sh
LA8VDcoJgiv2bSiVqyaT6hJ67LXbnQGpf9Uk3zh9ikUKPJUWeYbgsd9gxQ5ptM2hQNSsCaRETQ3GM9FLDe7BGqcm4ve69bh
```
## Manual installation
These steps apply to the latest release of Raspbian (currently [Stretch](https://www.raspberrypi.org/downloads/raspbian/)). Notes for previously released versions are provided, where applicable. Start off by installing git, lighttpd, php7, hostapd and dnsmasq.
```sh
$ sudo apt-get install git lighttpd php7.0-cgi hostapd dnsmasq vnstat
```
**Note:** for Raspbian Jessie and Wheezy, replace `php7.0-cgi` with `php5-cgi`. After that, enable PHP for lighttpd and restart it for the settings to take effect.
```sh
sudo lighttpd-enable-mod fastcgi-php
sudo service lighttpd restart
```
Now comes the fun part. For security reasons, the `www-data` user which lighttpd runs under is not allowed to start or stop daemons, or run commands like ifdown and ifup, all of which we want our page to do.
So what I have done is added the `www-data` user to the sudoers file, but with restrictions on what commands the user can run. Add the following to the end of `/etc/sudoers`, substituting your wireless interface for `wlan0` if needed:
```sh
www-data ALL=(ALL) NOPASSWD:/var/lib/lokinet/lokilaunch.sh*
www-data ALL=(ALL) NOPASSWD:/sbin/ifdown wlan0
www-data ALL=(ALL) NOPASSWD:/sbin/ifup wlan0
www-data ALL=(ALL) NOPASSWD:/bin/cat /etc/wpa_supplicant/wpa_supplicant.conf
www-data ALL=(ALL) NOPASSWD:/bin/cp /tmp/wifidata /etc/wpa_supplicant/wpa_supplicant.conf
www-data ALL=(ALL) NOPASSWD:/sbin/wpa_cli -i wlan0 scan_results
www-data ALL=(ALL) NOPASSWD:/sbin/wpa_cli -i wlan0 scan
www-data ALL=(ALL) NOPASSWD:/sbin/wpa_cli -i wlan0 reconfigure
www-data ALL=(ALL) NOPASSWD:/bin/cp /tmp/hostapddata /etc/hostapd/hostapd.conf
www-data ALL=(ALL) NOPASSWD:/etc/init.d/hostapd start
www-data ALL=(ALL) NOPASSWD:/etc/init.d/hostapd stop
www-data ALL=(ALL) NOPASSWD:/etc/init.d/dnsmasq start
www-data ALL=(ALL) NOPASSWD:/etc/init.d/dnsmasq stop
www-data ALL=(ALL) NOPASSWD:/bin/cp /tmp/dhcpddata /etc/dnsmasq.conf
www-data ALL=(ALL) NOPASSWD:/sbin/shutdown -h now
www-data ALL=(ALL) NOPASSWD:/sbin/reboot
www-data ALL=(ALL) NOPASSWD:/sbin/ip link set wlan0 down
www-data ALL=(ALL) NOPASSWD:/sbin/ip link set wlan0 up
www-data ALL=(ALL) NOPASSWD:/sbin/ip -s a f label wlan0
www-data ALL=(ALL) NOPASSWD:/bin/cp /etc/raspap/networking/dhcpcd.conf /etc/dhcpcd.conf
www-data ALL=(ALL) NOPASSWD:/etc/raspap/hostapd/enablelog.sh
www-data ALL=(ALL) NOPASSWD:/etc/raspap/hostapd/disablelog.sh
```
Once those modifications are done, git clone the files to `/var/www/html`.
**Note:** for older versions of Raspbian (before Jessie, May 2016) use
`/var/www` instead.
```sh
sudo rm -rf /var/www/html
sudo git clone https://github.com/necro-nemesis/Lokiap-webgui /var/www/html
```
Set the files ownership to `www-data` user.
```sh
sudo chown -R www-data:www-data /var/www/html
```
Move the RaspAP configuration file to the correct location
```sh
sudo mkdir /etc/raspap
sudo mv /var/www/html/raspap.php /etc/raspap/
sudo chown -R www-data:www-data /etc/raspap
```
Move the HostAPD logging scripts to the correct location
```sh
sudo mkdir /etc/raspap/hostapd
sudo mv /var/www/html/installers/*log.sh /etc/raspap/hostapd
```
Reboot and it should be up and running!
```sh
sudo reboot
```
The default username is 'admin' and the default password is 'secret'.
## Multilingual support
LokiAP uses [GNU Gettext](https://www.gnu.org/software/gettext/) to manage multilingual messages. In order to use LokiAP with one of our supported translations, you must configure a corresponding language package on your RPi. To list languages currently installed on your system, use `locale -a` at the shell prompt. To generate new locales, run `sudo dpkg-reconfigure locales` and select any other desired locales. Details are provided on our [wiki](https://github.com/billz/raspap-webgui/wiki/Translations#raspap-in-your-language).
The following translations are currently maintained by the project:
- Deutsch
- Français
- Italiano
- Português
- Svenska
- Nederlands
- 简体中文 (Chinese Simplified)
- Čeština
- Русский
- Español
- Finnish
- Sinhala
If your language is not in the list above, why not [contribute a translation](https://github.com/billz/raspap-webgui/wiki/Translations#contributing-a-translation)? Contributors will receive credit as the original translators.
## Optional services
OpenVPN and TOR are two additional services that run perfectly well on the RPi, and are a nice way to extend the usefulness of your WiFi router. I've started on interfaces to administer these services. Not everyone will need them, so for the moment they are disabled by default. You can enable them by changing these options in `/var/www/html/includes/config.php`:
```sh
// Optional services, set to true to enable.
define('RASPI_OPENVPN_ENABLED', false );
define('RASPI_TORPROXY_ENABLED', false );
```
Please note that these are only UI's for now. If there's enough interest I'll complete the funtionality for these optional admin screens.
## How to contribute
1. File an issue in the repository, using the bug tracker, describing the

@ -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)

@ -28,11 +28,13 @@ case "$1" in
;;
bootstrap)
echo -n "Lokinet daemon shutdown for bootstrapping\n"
systemctl stop lokinet
echo -n "FETCHING BOOTSTRAP <---- "
usr/bin/lokinet-bootstrap "$2"
echo -n "BOOTSTRAPPED WTIH ---> $2\n\n"
systemctl start lokinet
pidof lokinet >/dev/null && echo "Daemon shutdown failure\n" || echo "Daemon is stopped\n"
echo -n "Fetching bootstrap <---- "
lokinet-bootstrap "$2"
echo -n "Bootstrapped with ---> $2\n\n"
systemclt start lokinet
;;
*)

@ -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
}
}

@ -6,11 +6,11 @@ html * {
font-family: Arial, Andale Mono, monospace;
font-size: 10pt;
color: #33ff00;
background-color: #152010;
background-color: #252525;
}
#wrapper,#page-wrapper,.panel-body,.nav>li>a,.navbar-default {
background-color: #152010;
background-color: #252525;
}
.page-header {
@ -22,7 +22,7 @@ html * {
.page-header .logo {
margin-right: 1px;
background-color: #152010;
background-color: #252525;
}

@ -1,6 +1,6 @@
<?php
define('RASPI_VERSION', '1.6b');
define('RASPI_VERSION', '1.7');
define('RASPI_CONFIG', '/etc/raspap');
define('RASPI_CONFIG_NETWORKING',RASPI_CONFIG.'/networking');
define('RASPI_ADMIN_DETAILS', RASPI_CONFIG.'/raspap.auth');

@ -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,9 +371,10 @@ 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 active (green) to connect to Lokinet. If there isn't a current lokinet.ini file found on the system the "Generate.ini" button will be red. 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 red "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 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>
<form role="form" action="?page=save_hostapd_conf" method="POST">
<div class="row">
@ -380,24 +382,25 @@ function DisplayLokinetConfig()
<h5>Enter a valid bootstrap url below and apply to overwrite the current bootstrap:</h5>
<label for="usr">Bootstrap url:</label>
<input type="url" class="form-control" placeholder="https://seed.lokinet.org/bootstrap.signed" id="lokinetbootstrap" name="lokinetbootstrap">
<li></li>
<?php
if ($lokinetstatus[0] == 0) {
echo '<input type="submit" class="btn btn-danger" name="StartDaemon" value="Start Daemon" />' , PHP_EOL;
echo '<input type="submit" class="btn btn-success" name="StartDaemon" value="Start Daemon" />' , PHP_EOL;
} else {
echo '<input type="submit" class="btn btn-success" name="StopDaemon" value="Stop Daemon" />' , PHP_EOL;
echo '<input type="submit" class="btn btn-danger" name="StopDaemon" value="Stop Daemon" />' , PHP_EOL;
}
$filename = '/var/lib/lokinet/lokinet.ini';
if (file_exists($filename)) {
echo '<input type="submit" class="btn btn-success" name="ReGenerateLokinet" value="Regenerate .ini" />' , PHP_EOL;
echo '<input type="submit" class="btn btn-danger" name="ReGenerateLokinet" value="Regenerate .ini" />' , PHP_EOL;
} else {
echo '<input type="submit" class="btn btn-danger" name="GenerateLokinet" value="Generate .ini" />' , PHP_EOL;
echo '<input type="submit" class="btn btn-success" name="GenerateLokinet" value="Generate .ini" />' , PHP_EOL;
}
?>
<input type="submit" class="btn btn-success" name="ApplyLokinetSettings" value="Re-Bootstrap" />
<input type="submit" class="btn btn-danger" name="ApplyLokinetSettings" value="Re-Bootstrap" />
<h5><?php echo _("Your development support is greatly appreciated | Loki Address:"); ?></h5>
<h5><pre><?php echo _("LA8VDcoJgiv2bSiVqyaT6hJ67LXbnQGpf9Uk3zh9ikUKPJUWeYbgsd9gxQ5ptM2hQNSsCaRETQ3GM9FLDe7BGqcm4ve69bh"); ?></pre></h5>
</div>
@ -604,30 +607,11 @@ function SaveTORAndVPNConfig()
//START
} elseif (isset($_POST['StartDaemon'])) {
/*?>
<div class="alert alert-success">
Launching Lokinet.
</div>
<?php
$output = */
shell_exec('sudo /var/lib/lokinet/lokilaunch.sh start');
/* echo "<pre><strong>$output</strong></pre>";
*/
exec('sudo /var/lib/lokinet/lokilaunch.sh start');
//STOP
} elseif (isset($_POST['StopDaemon'])) {
?>
<div class="alert alert-danger">
Exiting Lokinet.
</div>
<?php
?>
<div class="alert alert-danger">
Stopping Lokinet background daemon process.
</div>
<?php
$output = shell_exec('sudo /var/lib/lokinet/lokilaunch.sh stop');
echo "<pre><strong>$output</strong></pre>";
exec('sudo /var/lib/lokinet/lokilaunch.sh stop');
//GENERATE LOKINET.INI
} elseif (isset($_POST['GenerateLokinet'])) {
@ -664,5 +648,7 @@ function SaveTORAndVPNConfig()
$output = shell_exec('sudo /var/lib/lokinet/lokilaunch.sh bootstrap '.$bootstrap.'');
echo "<pre><strong>$output</strong></pre>";
}
DisplayLokinetConfig();
}
?>

@ -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 {

@ -12,7 +12,7 @@
*
* @author TechnicalTumbleweed (Loki->Discord/Telegram)
* @license GNU General Public License, version 3 (GPL-3.0)
* @version 1.6b
* @version 1.7
* @link https://github.com/necro-nemesis/Lokiap-webgui
*/

@ -8,25 +8,25 @@ version=`sed 's/\..*//' /etc/debian_version`
if [ $version -eq 10 ]; then
version_msg="Raspbian 10.0 (Buster)"
sudo apt update --allow-releaseinfo-change
php_package="php7.1-cgi"
php_package="php7.3-cgi"
elif [ $version -eq 9 ]; then
version_msg="Raspbian 9.0 (Stretch)"
php_package="php7.0-cgi"
elif [ $version -eq 8 ]; then
version_msg="Raspbian 8.0 (Jessie)"
php_package="php5-cgi"
php_package="php5.6-cgi"
else
version_msg="Raspbian earlier than 8.0 (Wheezy)"
webroot_dir="/var/www"
php_package="php5-cgi"
php_package="php5.6-cgi"
fi
phpcgiconf=""
if [ "$php_package" = "php7.1-cgi" ]; then
phpcgiconf="/etc/php/7.1/cgi/php.ini"
if [ "$php_package" = "php7.3-cgi" ]; then
phpcgiconf="/etc/php/7.3/cgi/php.ini"
elif [ "$php_package" = "php7.0-cgi" ]; then
phpcgiconf="/etc/php/7.0/cgi/php.ini"
elif [ "$php_package" = "php5-cgi" ]; then
elif [ "$php_package" = "php5.6-cgi" ]; then
phpcgiconf="/etc/php5/cgi/php.ini"
fi
@ -91,6 +91,17 @@ 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
install_error "No function definition for install_dependencies"
}
# Enables PHP for lighttpd and restarts service for settings to take effect
function enable_php_lighttpd() {
install_log "Enabling PHP for lighttpd"
@ -139,7 +150,7 @@ function download_latest_files() {
fi
install_log "Cloning latest files from github"
git clone --depth 1 https://github.com/necro-nemesis/raspap-webgui /tmp/raspap-webgui || install_error "Unable to download files from github"
git clone --depth 1 https://github.com/necro-nemesis/Lokiap-webgui /tmp/raspap-webgui || install_error "Unable to download files from github"
sudo mv /tmp/raspap-webgui $webroot_dir || install_error "Unable to move raspap-webgui to web root"
}
@ -179,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
@ -192,6 +208,23 @@ function move_config_file() {
sudo chown -R $raspap_user:$raspap_user "$raspap_dir" || install_error "Unable to change file ownership for '$raspap_dir'"
}
# select iptables or nftables
function network_tables() {
install_log "Selecting iptables or nftable rules"
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
sudo apt-get -y purge iptables
sudo systemctl enable nftables.service
fi
}
# Set up default configuration
function default_configuration() {
install_log "Setting up hostapd"
@ -203,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"
@ -216,23 +252,12 @@ function default_configuration() {
# Generate required lines for Rasp AP to place into rc.local file.
# #RASPAP is for removal
# select iptables or nftables
function networktables() {
if [ ! -f /usr/sbin/iptables-nft ]; then
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
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'
}
lines=(
'echo 1 > \/proc\/sys\/net\/ipv4\/ip_forward #RASPAP')
$tablerouteA
$tablerouteB
'sudo \/var\/lib\/lokinet\/.\/lokilaunch.sh start #RASPAP'
'echo 1 > \/proc\/sys\/net\/ipv4\/ip_forward #RASPAP'
"$tablerouteA"
"$tablerouteB"
#'sudo \/var\/lib\/lokinet\/.\/lokilaunch.sh start #RASPAP'
)
for line in "${lines[@]}"; do
@ -311,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.
@ -359,6 +393,9 @@ function install_complete() {
echo "Installation reboot aborted."
exit 0
fi
install_log "Shutting Down"
echo -n "Allow a minute for reinitialization then connect wifi to SSID loki-access and use default password 'ChangeMe'"
sleep 8
sudo shutdown -r now || install_error "Unable to execute shutdown"
}
@ -367,6 +404,8 @@ function install_raspap() {
config_installation
update_system_packages
install_dependencies
stop_lokinet
check_for_networkmananger
optimize_php
enable_php_lighttpd
create_raspap_directories
@ -375,6 +414,7 @@ function install_raspap() {
change_file_ownership
create_logging_scripts
move_config_file
network_tables
default_configuration
patch_system_files
install_complete

@ -9,11 +9,25 @@ 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 and install dhcpd if required.
function check_for_networkmananger() {
install_log "Checking for NetworkManager"
echo "Checking for Network Manager"
if [ -f /lib/systemd/system/network-manager.service ]; then
echo "Network Manager found. Replacing with DHCPCD"
sudo apt-get -y purge network-manager
sudo apt-get -y install dhcpcd5
fi
}
install_raspap

Loading…
Cancel
Save