diff --git a/android_contacts2vcf.sh b/android_contacts2vcf.sh index 361f5b4..26fcdf0 100755 --- a/android_contacts2vcf.sh +++ b/android_contacts2vcf.sh @@ -57,18 +57,30 @@ function contact_split { local card_guid declare -a card_lines + uid_found=false while read line; do + if [[ "$line" =~ ^END:VCARD ]]; then + if ! $uid_found ; then + card_lines=("${card_lines[@]}" "UID:$(uid)") + fi + fi # Append each line to the end of this array. card_lines=("${card_lines[@]}" "$line") # Get the contact's GUID, this becomes the file name. - if [[ "$line" =~ ^N: ]]; then + if [[ "$line" =~ ^FN: ]]; then card_guid=$(echo -n "$line" | cut -d ':' -f 2) fi + # Remember if we found an uid + if [[ "$line" =~ ^UID: ]]; then + uid_found=true + fi + # This is the end of the card, so output it. if [[ "$line" =~ ^END:VCARD ]]; then - printf "%s\n" "${card_lines[@]}" > "$dest/$(echo -n "$card_guid" | sed 's/;/_/g' | tr 'A-Z' 'a-z' | tr -d '\r').vcf" + uid_found=false + printf "%s\n" "${card_lines[@]}" > "$dest/$(echo -n "$card_guid" | sed 's/;/_/g' | tr 'A-Z' 'a-z' | tr -d '\r ').vcf" unset -v card_lines fi done @@ -419,15 +431,17 @@ IFS=$ORIG_IFS } -##### Main ##### - -tmp="$(mktemp -d)" - -echo "Get db from phone" -adb pull /data/data/com.android.providers.contacts/databases/contacts2.db "$tmp" - -echo "Convert it to multiple vcard files" -dump-contacts2db "$tmp/contacts2.db" | contact_split "${1:-$HOME/.contacts/vcards}" - -echo "Clean" -rm -r "$tmp" +# MAIN FUNCTION +phone_to_vcf () { + # Copy contacts from phone via adb and convert them to vcf + tmp="$(mktemp -d)" + + echo "Get db from phone" + adb pull /data/data/com.android.providers.contacts/databases/contacts2.db "$tmp" + + echo "Convert it to multiple vcard files" + dump-contacts2db "$tmp/contacts2.db" | contact_split "${1:-$HOME/.contacts/vcards}" + + echo "Clean" + rm -r "$tmp" +} diff --git a/dbm_daily_vim b/dbm_daily_vim index b5a070c..aaf9c98 100755 --- a/dbm_daily_vim +++ b/dbm_daily_vim @@ -5,21 +5,34 @@ tmp="$(mktemp)" final="$(mktemp)" sed \ - -e 's/adj/\n**Aujourd’hui**\n/' \ - -e 's/^hier/\n**Hier**\n/' \ - -e 's/^diffic.*/\n**Difficultés**\n/i' \ + -e 's/ / /g' \ + -e 's/^adj */\n\n**Cet après-midi**/' \ + -e 's/^aprem */\n\n**Cet après-midi**/' \ + -e 's/^matin */\n\n**Ce matin**/' \ + -e 's/^hier */\n\n**Hier après-midi**/' \ + -e 's/\( \|^\)maj\( \|$\)/mise à jour/' \ + -e 's/^diffic.*/\n\n**Difficultés**\n/i' \ -e 's/^ *information.*/# Points divers/i' \ -e 's/^point.* diver.*/# Points divers/i' \ - -e 's/^\([^-*#@:][^*#@:]\+\) \+:/- \U\1 :/' \ + -e 's/^point.* g.n.raux.*/# Points divers/i' \ + -e 's/^info.* g.n.ra.*/# Points divers/i' \ + -e 's/^difficult.s.*/# Difficultés/i' \ + -e 's/^message.* g.n.raux.*/# Points divers/i' \ + -e 's/^tickets$/dbm : tickets/g' \ + -e 's/^\([^-*#: ]\+\)$/# @\U\1/' \ + -e 's/^\([^-*#@: ][^*#@:]\+[^: ]\) *: */- \U\1 : /' \ + -e 's/^\([^-*#@:]\+\)$/- \1/' \ + -e 's/ \+/ /g' \ + -e 's/dde/demande/g' \ + -e 's/pb/problème/g' \ "$f" > "$tmp" - -sed -i -e 's/^\([^-*#\s]\)/# @\U\1/' "$tmp" +#sed -i -e 's/^\([^-*#\s ]\)/# @\U\1/' "$tmp" echo " **Daily Stand-Up Meeting du $(date '+%d %h %Y')** -- Où : BBB/standup -- Participants : $(grep -o '@.*' "$tmp" | tr '\n' ',' | sed 's/,$/\n/') -- Quand : $(date '+%Y/%m/%d') 9:45 +- Où : https://bbb.dbm.tech/rooms/05n-3ax-qwg-9n8/join +- Participants : $(grep -o '@.*' "$tmp" | tr '\n' ',' | sed 's/,$/\n/') +- Quand : $(date '+%Y/%m/%d') 12h05 - Durée : 00:15 '(+0mn) - Scribe : Adrian - Relecteur : diff --git a/gw.sh b/gw.sh index 2dd9821..cd66851 100755 --- a/gw.sh +++ b/gw.sh @@ -10,27 +10,28 @@ root_or_die local_iface="$1" net_iface="$2" +net="192.168.99" run sysctl net.ipv4.ip_forward=1 -clean "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" +run ip a add $net.254/24 dev "$local_iface" +clean "ip a del $net.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 OUTPUT -d $net.0/24 -j ACCEPT +run iptables -A INPUT -s $net.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 --listen-address 192.168.238.254 --interface "$local_iface" -p0 +run dnsmasq --dhcp-range=$net.100,$net.199,10m -d --server=9.9.9.9 --listen-address $net.254 --interface "$local_iface" -p0 clean diff --git a/radicale_server.sh b/radicale_server.sh index 0239dda..8380e8b 100755 --- a/radicale_server.sh +++ b/radicale_server.sh @@ -3,26 +3,40 @@ set -euo pipefail echo "vars" -htpasswd="$(mktemp)" -venv=~/.cache/radicale-venv +user="emails" +venv="/home/$user/.cache/radicale-venv" +htpasswd="$venv/htpasswd" #locale_ip_addr="$(ip -o -4 a show dev usb0 | grep -Po 'inet[[:space:]]+\K192.168.42.[0-9]{1,3}')" -locale_ip_addr="192.168.42.58" +locale_ip_addr="192.168.42.205" port=5232 +echo ip +sudo ip a add "$locale_ip_addr/32" dev usb0 || true + + + +sudo -u "$user" bash </dev/null & #jami-gnome &>/dev/null & -nicotine &>/dev/null & -qbittorrent &>/dev/null & +#nicotine &>/dev/null & +#qbittorrent &>/dev/null & #vdirsyncer sync -sudo -u emails syncmails + +if [ "$(host -t a wg.rezine.org 9.9.9.9 2>/dev/null | grep -o ' has address .*')" != "$(host -t a wg.rezine.org 2>/dev/null | grep -o ' has address .*')" ] ; then + echo "-------------------------" + echo "" + echo "wg.rezine.org seems to have changed, you mail need to update your /etc/dnsmasq.conf" + notify-send "Consistency check" "wg.rezine.org seems to have changed, you mail need to update your /etc/dnsmasq.conf" + echo "" + echo "-------------------------" + sleep 3 +fi + + +sudo -u emails bash <" | grep -vP "[\x00-\x1F\x7F-\xFF]\S*@" | grep -vP "@\S*[\x00-\x1F\x7F-\xFF]" | sort -u > ~/.mails/collected_addresses.txt +fi +syncmails +EOF diff --git a/syncmails b/syncmails index 027f163..8e5f0a9 100755 --- a/syncmails +++ b/syncmails @@ -1,7 +1,17 @@ #!/bin/bash -offlineimap +set -u + +cd ~/offlineimap3 +if [ ! -d venv ] ; then + virtualenv venv +fi + +. venv/bin/activate + +python offlineimap.py + while true ; do sleep 30 - offlineimap -q + python offlineimap.py -q done diff --git a/term b/term index 9772e24..ad06838 100755 --- a/term +++ b/term @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh pid="$(xdotool getactivewindow getwindowpid)" [ -n "$pid" ] && cd "$(readlink -f "/proc/$(pgrep -P "$pid")/cwd")" &>/dev/null || cd "$HOME" exec st "${SHELL:-bash}"