first Pivivlion config and scripts

This commit is contained in:
Vedran 2016-11-25 19:02:28 +01:00
parent e046535f8c
commit 1599a2b753
61 changed files with 7014 additions and 0 deletions

138
home/pi/.bashrc Normal file
View file

@ -0,0 +1,138 @@
# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples
# If not running interactively, don't do anything
case $- in
*i*) ;;
*) return;;
esac
# don't put duplicate lines or lines starting with space in the history.
# See bash(1) for more options
HISTCONTROL=ignoreboth
# append to the history file, don't overwrite it
shopt -s histappend
# for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
HISTSIZE=1000
HISTFILESIZE=2000
# check the window size after each command and, if necessary,
# update the values of LINES and COLUMNS.
shopt -s checkwinsize
# If set, the pattern "**" used in a pathname expansion context will
# match all files and zero or more directories and subdirectories.
#shopt -s globstar
# make less more friendly for non-text input files, see lesspipe(1)
#[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"
# set variable identifying the chroot you work in (used in the prompt below)
if [ -z "${debian_chroot:-}" ] && [ -r /etc/debian_chroot ]; then
debian_chroot=$(cat /etc/debian_chroot)
fi
# set a fancy prompt (non-color, unless we know we "want" color)
case "$TERM" in
xterm-color) color_prompt=yes;;
esac
# uncomment for a colored prompt, if the terminal has the capability; turned
# off by default to not distract the user: the focus in a terminal window
# should be on the output of commands, not on the prompt
force_color_prompt=yes
if [ -n "$force_color_prompt" ]; then
if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
# We have color support; assume it's compliant with Ecma-48
# (ISO/IEC-6429). (Lack of such support is extremely rare, and such
# a case would tend to support setf rather than setaf.)
color_prompt=yes
else
color_prompt=
fi
fi
if [ "$color_prompt" = yes ]; then
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w \$\[\033[00m\] '
else
PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
fi
unset color_prompt force_color_prompt
# If this is an xterm set the title to user@host:dir
case "$TERM" in
xterm*|rxvt*)
PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"
;;
*)
;;
esac
# enable color support of ls and also add handy aliases
if [ -x /usr/bin/dircolors ]; then
test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
alias ls='ls --color=auto'
#alias dir='dir --color=auto'
#alias vdir='vdir --color=auto'
alias grep='grep --color=auto'
alias fgrep='fgrep --color=auto'
alias egrep='egrep --color=auto'
fi
# colored GCC warnings and errors
#export GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01'
# some more ls aliases
#alias ll='ls -l'
#alias la='ls -A'
#alias l='ls -CF'
# Alias definitions.
# You may want to put all your additions into a separate file like
# ~/.bash_aliases, instead of adding them here directly.
# See /usr/share/doc/bash-doc/examples in the bash-doc package.
if [ -f ~/.bash_aliases ]; then
. ~/.bash_aliases
fi
# enable programmable completion features (you don't need to enable
# this, if it's already enabled in /etc/bash.bashrc and /etc/profile
# sources /etc/bash.bashrc).
if ! shopt -oq posix; then
if [ -f /usr/share/bash-completion/bash_completion ]; then
. /usr/share/bash-completion/bash_completion
elif [ -f /etc/bash_completion ]; then
. /etc/bash_completion
fi
fi
# info on login
let upSeconds="$(/usr/bin/cut -d. -f1 /proc/uptime)"
let secs=$((${upSeconds}%60))
let mins=$((${upSeconds}/60%60))
let hours=$((${upSeconds}/3600%24))
let days=$((${upSeconds}/86400))
UPTIME=`printf "%d days, %02dh%02dm%02ds" "$days" "$hours" "$mins" "$secs"`
# get the load averages
read one five fifteen rest < /proc/loadavg
echo "
@@@@@@@@@@@@@@@@@@@ `date +"%A, %e %B %Y, %r"`
@@@@@@, &@& *@@@@@@ `uname -srnmo`
@@@@@@@. .@@@@@@@ Uptime.............: ${UPTIME}
@@@@ .@@@. @@@@ Memory.............: `cat /proc/meminfo | grep MemFree | awk {'print $2'}`kB (Free) / `cat /proc/meminfo | grep MemTotal | awk {'print $2'}`kB (Total)
@ &@@@@.@@@@# @ Load Averages......: ${one}, ${five}, ${fifteen} (1, 5, 15 min)
@ @ . #@@@# . @ @ Running Processes..: `ps ax | wc -l | tr -d " "`
@ @@@, # ,@@@ @ Manual / more info.: pivilion.net
@@, @ ,@@ Onion Address......: `cat /home/pi/pivilion/torname`
@@@@@#@@@@@@@#@@@@@ Run "pivilion" for inital setup! / Running in `cat /home/pi/pivilion/mode` mode
"
export LC_ALL=C

View file

@ -0,0 +1,42 @@
# A sample configuration for dhcpcd.
# See dhcpcd.conf(5) for details.
# Allow users of this group to interact with dhcpcd via the control socket.
#controlgroup wheel
# Inform the DHCP server of our hostname for DDNS.
hostname
# Use the hardware address of the interface for the Client ID.
clientid
# or
# Use the same DUID + IAID as set in DHCPv6 for DHCPv4 ClientID as per RFC4361.
#duid
# Persist interface configuration when dhcpcd exits.
persistent
# Rapid commit support.
# Safe to enable by default because it requires the equivalent option set
# on the server to actually work.
option rapid_commit
# A list of options to request from the DHCP server.
option domain_name_servers, domain_name, domain_search, host_name
option classless_static_routes
# Most distributions have NTP support.
option ntp_servers
# Respect the network MTU.
# Some interface drivers reset when changing the MTU so disabled by default.
#option interface_mtu
# A ServerID is required by RFC2131.
require dhcp_server_identifier
# Generate Stable Private IPv6 Addresses instead of hardware based ones
slaac private
# A hook script is provided to lookup the hostname if not set by the DHCP
# server, but it should not be run by default.
nohook lookup-hostname
denyinterfaces wlan0

View file

@ -0,0 +1,41 @@
# A sample configuration for dhcpcd.
# See dhcpcd.conf(5) for details.
# Allow users of this group to interact with dhcpcd via the control socket.
#controlgroup wheel
# Inform the DHCP server of our hostname for DDNS.
hostname
# Use the hardware address of the interface for the Client ID.
clientid
# or
# Use the same DUID + IAID as set in DHCPv6 for DHCPv4 ClientID as per RFC4361.
#duid
# Persist interface configuration when dhcpcd exits.
persistent
# Rapid commit support.
# Safe to enable by default because it requires the equivalent option set
# on the server to actually work.
option rapid_commit
# A list of options to request from the DHCP server.
option domain_name_servers, domain_name, domain_search, host_name
option classless_static_routes
# Most distributions have NTP support.
option ntp_servers
# Respect the network MTU.
# Some interface drivers reset when changing the MTU so disabled by default.
#option interface_mtu
# A ServerID is required by RFC2131.
require dhcp_server_identifier
# Generate Stable Private IPv6 Addresses instead of hardware based ones
slaac private
# A hook script is provided to lookup the hostname if not set by the DHCP
# server, but it should not be run by default.
nohook lookup-hostname

View file

@ -0,0 +1,35 @@
# interfaces(5) file used by ifup(8) and ifdown(8)
# Please note that this file is written to be used with dhcpcd
# For static IP, consult /etc/dhcpcd.conf and 'man dhcpcd.conf'
# Include files from /etc/network/interfaces.d:
source-directory /etc/network/interfaces.d
auto lo
iface lo inet loopback
iface eth0 inet manual
#avoid stupid Rasbian static IP config via dhcpcd.conf (WTF???)
#auto eth0
#iface eth0 inet static
#address 192.168.1.5
#netmask 255.255.255.0
#gateway 192.168.1.1
allow-hotplug wlan0
iface wlan0 inet static
address 10.1.0.1
netmask 255.255.255.0
network 10.1.0.1
broadcast 10.1.0.255
#allow-hotplug wlan0
#iface wlan0 inet manual
# wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
#allow-hotplug wlan1
#iface wlan1 inet manual
# wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

View file

@ -0,0 +1,35 @@
# interfaces(5) file used by ifup(8) and ifdown(8)
# Please note that this file is written to be used with dhcpcd
# For static IP, consult /etc/dhcpcd.conf and 'man dhcpcd.conf'
# Include files from /etc/network/interfaces.d:
source-directory /etc/network/interfaces.d
auto lo
iface lo inet loopback
iface eth0 inet manual
#avoid stupid Rasbian static IP config via dhcpcd.conf (WTF???)
#auto eth0
#iface eth0 inet static
#address 192.168.1.5
#netmask 255.255.255.0
#gateway 192.168.1.1
#allow-hotplug wlan0
#iface wlan0 inet static
# address 10.1.0.1
# netmask 255.255.255.0
# network 10.1.0.1
# broadcast 10.1.0.255
allow-hotplug wlan0
iface wlan0 inet manual
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
allow-hotplug wlan1
iface wlan1 inet manual
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

View file

@ -0,0 +1,24 @@
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
# Print the IP address
_IP=$(hostname -I) || true
if [ "$_IP" ]; then
printf "My IP address is %s\n" "$_IP"
fi
# Display onion domain in MOTD
cat /var/lib/tor/hidden_service/hostname > /home/pi/torname
hostapd -d /etc/hostapd/hostapd.conf
exit 0

View file

@ -0,0 +1,23 @@
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
# Print the IP address
_IP=$(hostname -I) || true
if [ "$_IP" ]; then
printf "My IP address is %s\n" "$_IP"
fi
# Display onion domain in MOTD
cat /var/lib/tor/hidden_service/hostname > /home/pi/torname
exit 0

View file

@ -0,0 +1,14 @@
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
network={
ssid="Inquiry Inc."
psk="FormatC.artorg"
key_mgmt=WPA-PSK
}
network={
ssid="APP-BusWiFi"
psk="APP12345"
key_mgmt=WPA-PSK
}

View file

@ -0,0 +1,25 @@
network={
ssid="Tomato24"
#psk="hajklab2016"
psk=2982ad06a340d993a0baed4daa2928b0ceeb939bf9a1d3cd311cc81b21aa9dcc
}
network={
ssid="Inquiry Inc."
#psk="FormatCart.org"
psk=33a8a7029b94df469ef4dd67fd8474b02892f15b77dd68dfb106ea197063d181
}
network={
ssid="Inquiry Inc."
#psk="FormatC.artorg"
psk=4d6e49cef5d4ff65b89fd5100c38fa90a7c28d87298d7b32a70a033c2204b202
}
network={
ssid="GLUO"
#psk="1234567890123"
psk=eb1a302ce03c3496a931683549e7040048f9b4b74ab0853611ded4e2ace5ac49
}
network={
ssid="VODO1"
#psk="12345678"
psk=c7bad77ca2fdbf4df64823ca2453b7a9c7fd633ab7050e225f22a7082803c7d1
}

1
home/pi/mode Normal file
View file

@ -0,0 +1 @@

13
home/pi/scripts/hotspot Normal file
View file

@ -0,0 +1,13 @@
#!/bin/bash
cat /home/pi/pivilion/config/dhcpcd.deny.wlan0 > /etc/dhcpcd.conf
sudo bash -c 'cat /home/pi/pivilion/config/interfaces.hotspot > /etc/network/interfaces'
sudo update-rc.d dnsmasq enable
sudo bash -c 'cat /home/pi/pivilion/config/rc.local.hotspot > /etc/rc.local'
echo "Your Rpi will reboot in hotspot mode"!
echo "hotspot" > /home/pi/pivilion/mode

14
home/pi/scripts/onion Normal file
View file

@ -0,0 +1,14 @@
#!/bin/bash
cat /home/pi/pivilion/config/dhcpcd.orig > /etc/dhcpcd.conf
sudo bash -c 'cat /home/pi/pivilion/config/interfaces.onion > /etc/network/interfaces'
sudo update-rc.d dnsmasq disable
sudo bash -c 'cat /home/pi/pivilion/config/rc.local.onion > /etc/rc.local'
echo "The next time you reboot, your Pi will start in onion mode"!
echo "Your onion domain is `cat /home/pi/pivilion/torname`"
echo "Access info at `cat /home/pi/pivilion/torname`/info"
echo "onion" > /home/pi/pivilion/mode

11
home/pi/scripts/pikey Normal file
View file

@ -0,0 +1,11 @@
#!/bin/bash
echo "Enter SSID"
read name
echo "Enter password"
read password
wpa_passphrase "$name" "$password" >> /home/pi/pivilion/config/wpa_supplicant.conf
sudo bash -c "cp /home/pi/pivilion/config/wpa_supplicant.conf /etc/wpa_supplicant/wpa_supplicant.conf"
echo "Configured Wifi networks"
sudo bash -c "cat /etc/wpa_supplicant/wpa_supplicant.conf"
echo "If this is correct set your Pi to restart in onion mode by running the onion command!"

33
home/pi/scripts/pivilion Normal file
View file

@ -0,0 +1,33 @@
#!/bin/bash
pause(){
read -n1 -rsp $'\nPress any key to continue or Ctrl+C to exit...\n\n'
}
echo -e "\nWelcome to pivilion!"
let upSeconds="$(/usr/bin/cut -d. -f1 /proc/uptime)"
let secs=$((${upSeconds}%60))
let mins=$((${upSeconds}/60%60))
let hours=$((${upSeconds}/3600%24))
let days=$((${upSeconds}/86400))
UPTIME=`printf "%d days, %02dh%02dm%02ds" "$days" "$hours" "$mins" "$secs"`
# get the load averages
read one five fifteen rest < /proc/loadavg
echo "
@@@@@@@@@@@@@@@@@@@ `date +"%A, %e %B %Y, %r"`
@@@@@@, &@& *@@@@@@ `uname -srnmo`
@@@@@@@. .@@@@@@@ Uptime.............: ${UPTIME}
@@@@ .@@@. @@@@ Memory.............: `cat /proc/meminfo | grep MemFree | awk {'print $2'}`kB (Free) / `cat /proc/meminfo | grep MemTotal | awk {'print $2'}`kB (Total)
@ &@@@@.@@@@# @ Load Averages......: ${one}, ${five}, ${fifteen} (1, 5, 15 min)
@ @ . #@@@# . @ @ Running Processes..: `ps ax | wc -l | tr -d " "`
@ @@@, # ,@@@ @ Manual / more info.: pivilion.net
@@, @ ,@@ Onion Address......: `cat /home/pi/pivilion/torname`
@@@@@#@@@@@@@#@@@@@ Running in `cat /home/pi/pivilion/mode` mode"
pause
echo -e "There are four commands for you to use: \n \n 1) \"pivilion\" will display this message. \n \n 2) \"onion\" will set your Pi to start in onion mode on next reboot. \n \n 3) \"hotspot\" will set your Pi to start in hotspot mode on next reboot. This is the default mode. \n Please remember to set the mode properly before each reboot or you might have to access your Pi via ethernet cable or screen. \n \n 4) \"pikey\" is used to setup a Wifi network and password to be used in onion mode. \n \n A more thorough explanation is available at pivilion.net.\n"
echo -e "The following is a usage scenario."
pause
echo "I'm to lazy to write that ATM. =P"
pause
exit 0

0
home/pi/torname Normal file
View file