Compare commits

..

7 Commits

Author SHA1 Message Date
113591c7a9 startsync 2022-07-04 16:39:06 +02:00
d1c9548128 lscolors 2022-07-04 16:38:10 +02:00
220db6ec7e add missing function 2022-07-04 16:35:26 +02:00
a790ca3fc8 add gateway script 2022-07-04 16:32:08 +02:00
a43f4aea0a ddg script 2022-07-04 16:31:50 +02:00
8b23fc6990 big vpn rework 2022-07-04 16:31:39 +02:00
ba7347ade1 working version of emails 2022-03-12 02:21:54 +01:00
6 changed files with 109 additions and 8 deletions

10
ddg Executable file
View File

@ -0,0 +1,10 @@
#!/bin/sh
function join_by { local IFS="$1"; shift; echo "$*"; }
if [ "$#" -eq 0 ] ; then
echo "WARNING! All your communication will bypass VPN and firewall!"
su no-fw -c 'lynx http://detectportal.firefox.com'
else
lynx "https://duckduckgo.com/?q=$(join_by '+' $@ )&t=ffab"
fi

4
emails
View File

@ -1,5 +1,5 @@
#!/bin/sh
# We setup xauthority file to display stuff
xauthority="$(cat ~/.Xauthority)"
exec sudo -u emails sh -c "echo \"$xauthority\" > ~/.Xauthority && . ~/.bashrc && exec aerc"
auth="$(xauth extract - "$DISPLAY" | base64)"
exec sudo -u emails sh -c "echo -n '$auth' | base64 -d > ~/.Xauthority && . ~/.bashrc && cd ~/attachements && exec aerc"

36
gw.sh Executable file
View File

@ -0,0 +1,36 @@
#!/bin/bash
. driglibash-base
if [ "$#" -ne 2 ] ; then
yell "Missing 2 parameters"
die "Usage: $0 <local_iface> <net_iface>"
fi
root_or_die
local_iface="$1"
net_iface="$2"
run sysctl net.ipv4.ip_forward=1
clean "sysctl net.ipv4.ip_forward=1"
run nmcli device set "$local_iface" managed no
clean "nmcli device set "$local_iface" managed yes"
run ip a add 192.168.238.254/24 dev "$local_iface"
clean "ip a del 192.168.238.254/24 dev $local_iface"
# For dhcp offers
run iptables -A OUTPUT -d 255.255.255.255/32 -j ACCEPT
run iptables -A OUTPUT -d 192.168.238.0/24 -j ACCEPT
run iptables -A INPUT -s 192.168.238.0/24 -j ACCEPT
run iptables -A INPUT -s 255.255.255.255 -j ACCEPT
run iptables -A INPUT -i "$local_iface" -j ACCEPT
run iptables -t nat -A POSTROUTING -o "$net_iface" -j MASQUERADE
run iptables -A FORWARD -i $net_iface -o $local_iface -m state --state RELATED,ESTABLISHED -j ACCEPT
run iptables -A FORWARD -i $local_iface -o $net_iface -j ACCEPT
run dnsmasq --dhcp-range=192.168.238.100,192.168.238.199,10m -d --server=9.9.9.9
clean

25
lscolors Executable file
View File

@ -0,0 +1,25 @@
local fgc bgc vals seq0
printf "Color escapes are %s\n" '\e[${value};...;${value}m'
printf "Values 30..37 are \e[33mforeground colors\e[m\n"
printf "Values 40..47 are \e[43mbackground colors\e[m\n"
printf "Value 1 gives a \e[1mbold-faced look\e[m\n\n"
# foreground colors
for fgc in {30..37}; do
# background colors
for bgc in {40..47}; do
fgc=${fgc#37} # white
bgc=${bgc#40} # black
vals="${fgc:+$fgc;}${bgc}"
vals=${vals%%;}
seq0="${vals:+\e[${vals}m}"
printf " %-9s" "${seq0:-(default)}"
printf " ${seq0}TEXT\e[m"
printf " \e[${vals:+${vals+$vals;}}1mBOLD\e[m"
done
echo; echo
done

12
startsync Executable file
View File

@ -0,0 +1,12 @@
nextcloud &
feedreader &
#jami-gnome &
offlineimap
vdirsyncer sync
birthday_reminder
while true ; do
offlineimap -q
#mpop -a
#notmuch new
sleep 30
done

View File

@ -1,9 +1,27 @@
#!/bin/sh
if [ -n "$(nmcli connection show rezine_vpn37_udp | grep activated)" ] ; then
nmcli connection down rezine_vpn37_udp
else
nmcli connection up rezine_vpn37_udp
function say () {
notify-send 'VPN UDP' "$1"
}
action="$1"
if [ -z "$1" ] ; then
if [ -n "$(nmcli connection show rezine_vpn37_udp | grep activated)" ] ; then
action=start
else
action=stop
fi
fi
nmcli connection show rezine_vpn37_udp | grep 'VPN connected' &>/dev/null
[ "$?" -eq 0 ] && notify-send 'VPN UDP connecté' || notify-send 'VPN UDP stoppé'
if [ "$action" = "start" ] ; then
nmcli connection up rezine_vpn37_udp
sleep 1
nmcli connection show rezine_vpn37_udp | grep 'VPN connected' &>/dev/null
[ "$?" -eq 0 ] && say 'Connecté :)' || say 'Non connecté :('
elif [ "$action" = "stop" ] ; then
nmcli connection down rezine_vpn37_udp
sleep 1
nmcli connection show rezine_vpn37_udp | grep 'VPN connected' &>/dev/null
[ "$?" -eq 0 ] && say 'Toujours connecté :(' || say 'stoppé :)'
else
say 'Bad script usage. Action not known'
fi