Merge pull request #26 from necro-nemesis/staging

Staging
pull/27/head
necro-nemesis 5 years ago committed by GitHub
commit 6980b5fb30
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -83,7 +83,7 @@ Now comes the fun part. For security reasons, the `www-data` user which lighttpd
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:/home/pi/loki-network/lokilaunch.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

@ -4,12 +4,14 @@ case "$1" in
start)
echo -n "Starting LOKINET daemon\n"
lokinet > /dev/null 2>&1 &
systemctl start lokinet
#lokinet > /dev/null 2>&1 &
;;
stop)
echo -n "daemon stop command sent\n"
pkill lokinet
systemctl stop lokinet
#pkill lokinet
;;
gen)

@ -1,2 +0,0 @@
#!/usr/bin/env bash
# this will be overriden by on-up.sh

@ -1,2 +0,0 @@
#!/usr/bin/env bash
notify-send "$@ Our Loki Address $LOKINET_ADDR is ready on address $IF_ADDR on $IF_NAME"

@ -1,20 +0,0 @@
#!/usr/bin/env bash
set -x
gateway_route=$(ip route | grep ^default | grep via | head -n1)
gateway_addr=$(echo "$gateway_route" | cut -d' ' -f3 )
for addr in $STRICT_CONNECT_ADDRS ; do
sudo ip route add $(echo $addr | cut -d':' -f 1) via $gateway_addr
done
sudo ip route del $gateway_route
sudo ip route add default dev lokitun0
cat <<EOF > /root/.lokinet/on-down.sh
#!/usr/bin/env bash
set -x
for addr in \$STRICT_CONNECT_ADDRS ; do
sudo ip route del \$(echo \$addr | cut -d':' -f 1) via $gateway_addr
done
sudo ip route del default dev lokitun0
sudo ip route add $gateway_route
EOF
chmod +x /root/.lokinet/on-down.sh

@ -352,13 +352,6 @@ function DisplayLokinetConfig()
$status = '<div class="alert alert-success alert-dismissable">Lokinet daemon is running
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button></div>';
}
/* if ($rulestate != "lokinet") {
$status = '<div class="alert alert-danger alert-dismissable">Not Connected to Lokinet
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button></div>';
} else {
$status = '<div class="alert alert-success alert-dismissable">Successfully Connected to Lokinet
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button></div>';
} */
?>
<div class="row">
@ -389,11 +382,6 @@ function DisplayLokinetConfig()
<input type="url" class="form-control" placeholder="https://seed.lokinet.org/bootstrap.signed" id="lokinetbootstrap" name="lokinetbootstrap">
<?php
/* if ($rulestate != "lokinet") {
echo '<input type="submit" class="btn btn-danger" name="UseLokinet" value="Use Lokinet" />' , PHP_EOL;
} else {
echo '<input type="submit" class="btn btn-success" name="ExitLokinet" value="Exit Lokinet" />' , PHP_EOL;
} */
if ($lokinetstatus[0] == 0) {
echo '<input type="submit" class="btn btn-danger" name="StartDaemon" value="Start Daemon" />' , PHP_EOL;
} else {
@ -614,67 +602,28 @@ function SaveTORAndVPNConfig()
Launching Lokinet.
</div>
<?php
/* $output = shell_exec('sudo /etc/init.d/dnsmasq stop');
echo "<pre><strong>$output</strong></pre>";
*/
$output = shell_exec('sudo /home/pi/loki-network/lokilaunch.sh start');
echo "<pre><strong>$output</strong></pre>";
/* $output = shell_exec('sudo /etc/init.d/dnsmasq start');
$output = shell_exec('sudo /var/lib/lokinet/lokilaunch.sh start');
echo "<pre><strong>$output</strong></pre>";
*/
} elseif (isset($_POST['StopDaemon'])) {
} elseif (isset($_POST['StopDaemon'])) {
?>
<div class="alert alert-danger">
Exiting Lokinet.
</div>
<?php
/* $output = shell_exec('sudo /home/pi/loki-network/lokilaunch.sh disconnect');
echo "<pre><strong>$output</strong></pre>"; */
?>
<div class="alert alert-danger">
Stopping Lokinet background daemon process.
</div>
<?php
$output = shell_exec('sudo /home/pi/loki-network/lokilaunch.sh stop');
echo "<pre><strong>$output</strong></pre>";
/*
} elseif (isset($_POST['UseLokinet'])) {
?>
<div class="alert alert-success">
Connecting to Lokinet.
</div>
<?php
exec('pidof lokinet | wc -l', $lokinetstatus);
$output = shell_exec('sudo /etc/init.d/dnsmasq stop');
echo "<pre><strong>$output</strong></pre>";
if ($lokinetstatus[0] == 0){
$output = shell_exec('sudo /home/pi/loki-network/lokilaunch.sh start');
$output = shell_exec('sudo /var/lib/lokinet/lokilaunch.sh stop');
echo "<pre><strong>$output</strong></pre>";
$output = shell_exec('sudo /home/pi/loki-network/lokilaunch.sh connect');
echo "<pre><strong>$output</strong></pre>";
$output = shell_exec('sudo /etc/init.d/dnsmasq start');
# sleep(5);
# $output = shell_exec('sudo dnsmasq --interface=wlan0 --bind-interfaces --dhcp-range=10.3.141.0,10.3.141.24,12h --conf-file=/etc/resolv.conf');
echo "<pre><strong>$output</strong></pre>";
}
} elseif (isset($_POST['ExitLokinet'])) {
?>
<div class="alert alert-danger">
Exiting Lokinet.
</div>
<?php
$output = shell_exec('sudo /home/pi/loki-network/lokilaunch.sh disconnect');
echo "<pre><strong>$output</strong></pre>";
*/
} elseif (isset($_POST['GenerateLokinet'])) {
?>
<div class="alert alert-success">
Generating Lokinet Configuration
</div>
<?php
$output = shell_exec('sudo /home/pi/loki-network/lokilaunch.sh gen');
$output = shell_exec('sudo /var/lib/lokinet/lokilaunch.sh gen');
echo "<pre><strong>$output</strong></pre>";
} elseif (isset($_POST['ReGenerateLokinet'])) {
?>
@ -682,7 +631,7 @@ function SaveTORAndVPNConfig()
Regenerating Lokinet Configuration
</div>
<?php
$output = shell_exec('sudo /home/pi/loki-network/lokilaunch.sh gen');
$output = shell_exec('sudo /var/lib/lokinet/lokilaunch.sh gen');
echo "<pre><strong>$output</strong></pre>";
} elseif (isset($_POST['ApplyLokinetSettings'])) {
?>
@ -690,15 +639,12 @@ function SaveTORAndVPNConfig()
Exiting Lokinet.
</div>
<?php
/* $output = shell_exec('sudo /home/pi/loki-network/lokilaunch.sh disconnect');
echo "<pre><strong>$output</strong></pre>";
*/
?>
<div class="alert alert-danger">
Stopping Lokinet background daemon process.
</div>
<?php
$output = shell_exec('sudo /home/pi/loki-network/lokilaunch.sh stop');
$output = shell_exec('sudo /var/lib/lokinet/lokilaunch.sh stop');
echo "<pre><strong>$output</strong></pre>";
$bootstrap = $_POST['lokinetbootstrap'];
?>

@ -207,23 +207,11 @@ function default_configuration() {
# LokiPAP Batch file relocation and permissions in user loki-network directory
sudo mv $webroot_dir/config/lokilaunch.sh $HOME/loki-network/ || install error "Unable to move lokilaunch.sh, install Lokinet first"
# Forces all traffic through Lokinet (drop scripts into root's .lokinet folder)
sudo mv $webroot_dir/config/on-up.sh /root/.lokinet/on-up.sh || install error "Unable to move on-up.sh, install Lokinet first"
sudo mv $webroot_dir/config/on-down.sh /root/.lokinet/on-down.sh || install error "Unable to move on-down.sh, install Lokinet first"
sudo mv $webroot_dir/config/on-ready.sh /root/.lokinet/on-ready.sh || install error "Unable to move on-ready.sh, install Lokinet first"
sudo mv $webroot_dir/config/lokilaunch.sh /var/lib/lokinet/ || install error "Unable to move lokilaunch.sh, install Lokinet first"
#changes persmission on lokilaunch.sh
sudo chmod 755 $HOME/loki-network/lokilaunch.sh
# Forces all traffic through Lokinet (change permissions)
sudo chmod 755 /root/.lokinet/on-up.sh
sudo chmod 755 /root/.lokinet/on-down.sh
sudo chmod 755 /root/.lokinet/on-ready.sh
sudo chmod 755 /var/lib/lokinet/lokilaunch.sh
# Generate required lines for Rasp AP to place into rc.local file.
# #RASPAP is for removal script
@ -231,7 +219,7 @@ function default_configuration() {
'echo 1 > \/proc\/sys\/net\/ipv4\/ip_forward #RASPAP'
'iptables -t nat -A POSTROUTING -s 10.3.141.0\/24 -o lokitun0 -j MASQUERADE #RASPAP'
'iptables -t nat -A POSTROUTING -j MASQUERADE #RASPAP'
'sudo \/home\/pi\/loki-network\/.\/lokilaunch.sh start #RASPAP'
'sudo \/var\/lib\/lokinet\/.\/lokilaunch.sh start #RASPAP'
)
@ -259,7 +247,7 @@ function patch_system_files() {
sudo ln -s /usr/share/dhcpcd/hooks/10-wpa_supplicant /etc/dhcp/dhclient-enter-hooks.d/
# Set commands array
cmds=(
"/home/pi/loki-network/lokilaunch.sh*"
#added for forced Lokinet
"/sbin/ip"
#
@ -287,6 +275,8 @@ function patch_system_files() {
"/bin/cp /etc/raspap/networking/dhcpcd.conf /etc/dhcpcd.conf"
"/etc/raspap/hostapd/enablelog.sh"
"/etc/raspap/hostapd/disablelog.sh"
"/var/lib/lokinet/lokilaunch.sh*"
)
# Check if sudoers needs patching

@ -1,4 +1,4 @@
UPDATE_URL="https://raw.githubusercontent.com/necro-nemesis/Lokiap-webgui/master/"
UPDATE_URL="https://raw.githubusercontent.com/necro-nemesis/Lokiap-webgui/staging/"
wget -q ${UPDATE_URL}/installers/common.sh -O /tmp/raspapcommon.sh
source /tmp/raspapcommon.sh && rm -f /tmp/raspapcommon.sh
@ -9,7 +9,11 @@ function update_system_packages() {
function install_dependencies() {
install_log "Installing required packages"
sudo apt-get install lighttpd $php_package git hostapd dnsmasq vnstat resolvconf || install_error "Unable to install dependencies"
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"
}
install_raspap

Loading…
Cancel
Save