From d953d99cc134f749b656aa8ca3d24b5eb61f286e Mon Sep 17 00:00:00 2001 From: Hassan Afify Date: Sun, 17 Nov 2019 23:26:05 +0000 Subject: [PATCH] [OpenBSD] new and update scripts new file: .gnupg/gpg-agent.conf new file: .gnupg/gpg.conf new file: .scripts/openbsd_connect_wifi.sh modified: .bashrc modified: .vimrc modified: .config/dunst/dunstrc modified: .config/mutt/themes/gruvbox.muttrc modified: .config/vifm/colors/dark.vifm modified: .config/vifm/vifmrc modified: .gitconfig modified: .gitignore modified: .scripts/create_mnt_dirs.sh modified: .scripts/deploy_theme_icons.sh modified: .scripts/gpg.sh modified: .scripts/mount_drives.sh modified: .scripts/notify_disks.sh modified: .scripts/notify_network.sh modified: .scripts/openbsd_install.sh modified: .scripts/openbsd_ports.sh modified: .scripts/pass_manager.sh --- .bashrc | 13 ++++--- .config/dunst/dunstrc | 4 +-- .config/mutt/themes/gruvbox.muttrc | 2 +- .config/vifm/colors/dark.vifm | 23 +++++++------ .config/vifm/vifmrc | 2 +- .gitconfig | 2 +- .gitignore | 15 ++++++--- .gnupg/gpg-agent.conf | 7 ++++ .gnupg/gpg.conf | 1 + .scripts/create_mnt_dirs.sh | 6 ++-- .scripts/deploy_theme_icons.sh | 50 ++++++++++++++++----------- .scripts/gpg.sh | 11 +++++- .scripts/mount_drives.sh | 2 ++ .scripts/notify_disks.sh | 8 +++-- .scripts/notify_network.sh | 63 +++++++++++++++++++++++----------- .scripts/openbsd_connect_wifi.sh | 7 ++++ .scripts/openbsd_install.sh | 69 +++++++++++++++++++++++++++++++------- .scripts/openbsd_ports.sh | 10 +++--- .scripts/pass_manager.sh | 60 ++++++++++++++++++++------------- .vimrc | 2 ++ 20 files changed, 246 insertions(+), 111 deletions(-) create mode 100644 .gnupg/gpg-agent.conf create mode 100644 .gnupg/gpg.conf rewrite .scripts/deploy_theme_icons.sh (89%) rewrite .scripts/notify_network.sh (81%) create mode 100644 .scripts/openbsd_connect_wifi.sh diff --git a/.bashrc b/.bashrc index 4ebdb66..c8f4902 100644 --- a/.bashrc +++ b/.bashrc @@ -14,16 +14,13 @@ export GPG_TTY=$(tty) stty -ixon # Disable ctrl-s and ctrl-q. #------ ALIAS ----------------------------------------------------------------- -alias ll='ls -lahg' alias k='clear' alias mv='mv -i' alias cp='cp -ir' alias rm='rm -i' -alias df='df -h' alias du='du -cs' -alias ka='killall' -alias sed='sed -E' -alias grep='grep -E' +# alias sed='sed -E' +# alias grep='grep -E' alias mkdir='mkdir -p' alias mk="makepkg -sri" alias f="~/.scripts/find.sh" @@ -32,11 +29,17 @@ alias fr="~/.scripts/find_replace_word.sh" alias xc='xclip -sel clip <' if [[ "$OSTYPE" == "openbsd"* ]]; then + alias ll='colorls -lahG' alias lsb="dmesg | egrep '^(cd|wd|sd|fd). at '" alias ka="pkill" + alias wifiq='bash .scripts/openbsd_connect_wifi.sh' + alias wifin='doas vim /etc/hostname.athn0' + alias startn='doas sh /etc/netstart' fi if [[ "$OSTYPE" == "linux-gnu" ]]; then + alias df='df -h' + alias ka='killall' alias ll='ls -lahG --color=auto --group-directories-first' alias pm="sudo pacman" alias pmu="sudo pacman -Syyu" diff --git a/.config/dunst/dunstrc b/.config/dunst/dunstrc index 62ef290..bb257fa 100644 --- a/.config/dunst/dunstrc +++ b/.config/dunst/dunstrc @@ -23,7 +23,7 @@ plain_text = no # %I iconname (without its path) # %p progress value if set ([ 0%] to [100%]) or nothing # Markup is allowed -alignment = center +# alignment = center # format = "%s\n%b\n" format = "%s\n%b\n%p" @@ -200,7 +200,7 @@ frame_color = "#55505c" #background = "#191311" #background = "#000000" #background = "#2B313C" -foreground = "#17bebb" +foreground = "#777777" background = "#111111" timeout = 2 diff --git a/.config/mutt/themes/gruvbox.muttrc b/.config/mutt/themes/gruvbox.muttrc index c7c6c02..705efb2 100644 --- a/.config/mutt/themes/gruvbox.muttrc +++ b/.config/mutt/themes/gruvbox.muttrc @@ -68,7 +68,7 @@ color header color142 color0 "^Subject:" color header color108 color0 "^X-Spam-Status:" color header color108 color0 "^Received:" -color body color142 color0 "[a-z]{3,256}://[-a-zA-Z0-9@:%._\\+~#=/?&,]+" +# color body color142 color0 "[a-z]{3,256}://[-a-zA-Z0-9@:%._\\+~#=/?&,]+" #color body color142 color0 "[a-zA-Z]([-a-zA-Z0-9_]+\\.){2,256}[-a-zA-Z0-9_]{2,256}" color body color208 color0 "[-a-z_0-9.%$]+@[-a-z_0-9.]+\\.[-a-z][-a-z]+" color body color208 color0 "mailto:[-a-z_0-9.]+@[-a-z_0-9.]+" diff --git a/.config/vifm/colors/dark.vifm b/.config/vifm/colors/dark.vifm index 7e772ec..aae1d2c 100644 --- a/.config/vifm/colors/dark.vifm +++ b/.config/vifm/colors/dark.vifm @@ -2,26 +2,29 @@ highlight clear -highlight Win ctermfg=93 ctermbg=0 cterm=none -highlight Directory ctermfg=13 ctermbg=0 cterm=bold +highlight Win ctermfg=243 ctermbg=0 cterm=none +highlight Directory ctermfg=blue ctermbg=0 cterm=bold highlight Executable ctermfg=166 ctermbg=0 cterm=bold -highlight Link ctermfg=yellow ctermbg=234 cterm=bold +highlight Link ctermfg=yellow ctermbg=233 cterm=bold highlight Socket ctermfg=125 ctermbg=0 cterm=bold highlight Device ctermfg=red ctermbg=0 cterm=bold highlight Fifo ctermfg=cyan ctermbg=0 cterm=bold -highlight Selected ctermfg=255 ctermbg=237 cterm=bold -highlight TopLine ctermfg=0 ctermbg=235 cterm=bold -highlight TopLineSel ctermfg=0 ctermbg=0 cterm=bold -highlight StatusLine ctermfg=0 ctermbg=235 cterm=bold -highlight CmdLine ctermfg=white ctermbg=234 cterm=none -highlight ErrorMsg ctermfg=red ctermbg=234 cterm=none -highlight Border ctermfg=0 ctermbg=235 cterm=none +highlight Selected ctermfg=255 ctermbg=233 cterm=bold +highlight TopLine ctermfg=0 ctermbg=233 cterm=bold +highlight TopLineSel ctermfg=0 ctermbg=233 cterm=bold +highlight StatusLine ctermfg=0 ctermbg=233 cterm=bold +highlight CmdLine ctermfg=243 ctermbg=0 cterm=none +highlight ErrorMsg ctermfg=red ctermbg=233 cterm=none +highlight Border ctermfg=0 ctermbg=233 cterm=none highlight CurrLine ctermfg=default ctermbg=233 cterm=bold highlight SuggestBox ctermfg=default ctermbg=0 cterm=bold highlight BrokenLink ctermfg=red ctermbg=0 cterm=reverse highlight WildMenu ctermfg=white ctermbg=0 cterm=underline,reverse highlight JobLine ctermfg=black ctermbg=white cterm=bold,reverse +" OtherWin +" TabLine +" if $USER == 'root' highlight Border ctermbg=red endif diff --git a/.config/vifm/vifmrc b/.config/vifm/vifmrc index f05fa66..727a406 100644 --- a/.config/vifm/vifmrc +++ b/.config/vifm/vifmrc @@ -1,6 +1,6 @@ " vim: filetype=vim -source ~/.config/vifm/icons +" source ~/.config/vifm/icons " set vicmd=elvis\ -G\ termcap " set vicmd=vile " set fastrun diff --git a/.gitconfig b/.gitconfig index d0a9315..b13d562 100644 --- a/.gitconfig +++ b/.gitconfig @@ -45,7 +45,7 @@ extendedRegexp = true [gpg] - program = gpg + program = gpg2 [hub] protocol = https diff --git a/.gitignore b/.gitignore index 1b44f1b..64cd940 100644 --- a/.gitignore +++ b/.gitignore @@ -14,14 +14,21 @@ .config/libreoffice .config/vis -# .cache -.gnupg/ +.cache +.gnupg/S* +.gnupg/random_seed +*.asc +*.gpg +*.kbx +*.key +*.rev +.password-store/ +.ssh .local/ .nv/ -.ssh/ -.password-store/ .mozilla/ .pki/ +.serverauth.* # .surf/cache/ .surf/script.js diff --git a/.gnupg/gpg-agent.conf b/.gnupg/gpg-agent.conf new file mode 100644 index 0000000..901e7a4 --- /dev/null +++ b/.gnupg/gpg-agent.conf @@ -0,0 +1,7 @@ +allow-loopback-pinentry +pinentry-program /usr/local/bin/pinentry-gtk-2 +# pinentry-program /usr/bin/pinentry-curses +# pinentry-program /usr/bin/pinentry +# pinentry-program /usr/local/bin/dmenu + + diff --git a/.gnupg/gpg.conf b/.gnupg/gpg.conf new file mode 100644 index 0000000..cf8bacd --- /dev/null +++ b/.gnupg/gpg.conf @@ -0,0 +1 @@ +default-key CED2D2F771262467 diff --git a/.scripts/create_mnt_dirs.sh b/.scripts/create_mnt_dirs.sh index f5b1075..9916fd7 100644 --- a/.scripts/create_mnt_dirs.sh +++ b/.scripts/create_mnt_dirs.sh @@ -1,11 +1,11 @@ #!/usr/bin/env sh -user=hassan +user=$(whoami) ostype=$(uname) case $ostype in - "Linux") auth=sudo ;; - "OpenBSD") auth=doas ;; + Linux) auth=sudo ;; + OpenBSD) auth=doas ;; esac cd /mnt/ diff --git a/.scripts/deploy_theme_icons.sh b/.scripts/deploy_theme_icons.sh dissimilarity index 89% index ce690c4..bc0a8c2 100644 --- a/.scripts/deploy_theme_icons.sh +++ b/.scripts/deploy_theme_icons.sh @@ -1,20 +1,30 @@ -#!/usr/bin/env bash - -confdir='/mnt/data/resources' - -sudo cp -R $confdir/Mojave-dark /usr/share/themes/ -sudo cp -R $confdir/la-capitaine-icon-theme /usr/share/icons/ - -# chech if files exists - -# echo "gtk-icon-theme-name = Mojave-dark -# gtk-theme-name = la-capitaine-icon-theme -# gtk-font-name = xos4 Terminus 12" > '~/.gtkrc-2.0' -# -# mkdir '.config/gtk-3.0' -# -# echo "[Settings] -# gtk-application-prefer-dark-theme = true -# gtk-theme-name = Mojave-dark -# gtk-icon-theme-name = la-capitaine-icon-theme -# gtk-font-name = Monospace 11" > '~/.config/gtk-3.0/settings.ini' +#!/usr/bin/env bash + +confdir='/mnt/data/resources' +dist="$HOME/.local/share" + +if [[ ! -d "$dist/themes" ]]; then + mkdir -p $dist/themes + cp -R $confdir/Mojave-dark $dist/themes/ +fi + +if [[ ! -d "$dist/icons" ]]; then + mkdir -p $dist/icons + cp -R $confdir/la-capitaine-icon-theme $dist/icons/ +fi + + +if [[ ! -f "$HOME/.gtkrc-2.0" ]]; then + echo "gtk-icon-theme-name = Mojave-dark + gtk-theme-name = la-capitaine-icon-theme + #gtk-font-name = Terminus 12" > '~/.gtkrc-2.0' +fi + +if [[ ! -f "$HOME/.config/gtk-3.0/settings.ini" ]]; then + mkdir -p '.config/gtk-3.0' + echo "[Settings] + gtk-application-prefer-dark-theme = true + gtk-theme-name = Mojave-dark + gtk-icon-theme-name = la-capitaine-icon-theme + #gtk-font-name = Monospace 11" > '~/.config/gtk-3.0/settings.ini' +fi diff --git a/.scripts/gpg.sh b/.scripts/gpg.sh index e814585..b4ac654 100644 --- a/.scripts/gpg.sh +++ b/.scripts/gpg.sh @@ -23,7 +23,7 @@ delete_key(){ } print_keys_id(){ - gpg --list-secret-keys --keyid-format LONG |\ + gpg2 --list-secret-keys --keyid-format LONG |\ sed -En 's/sec.*\/([A-Z0-9]{16}).*/\1/p' } @@ -86,6 +86,14 @@ vertify_file(){ gpg -vert } +restart_agent(){ + gpg-connect-agent reloadagent /bye +} + +edit_key(){ + gpg2 --edit-key EFC9AF1961B8B62B +} + case $1 in ids) print_keys_id ;; gen) create_new_key ;; @@ -99,4 +107,5 @@ case $1 in decrypt) decrypt_file $2 $3 ;; sign) sign_file $2 $3 ;; vertify) vertify_file $2 $3 ;; + restart) restart_agent ;; esac diff --git a/.scripts/mount_drives.sh b/.scripts/mount_drives.sh index 6250837..11418a5 100755 --- a/.scripts/mount_drives.sh +++ b/.scripts/mount_drives.sh @@ -20,6 +20,8 @@ if [[ $(uname) == "OpenBSD" ]]; then # tr '\n' '|' | grep -o '[cwsf]d[0-9]|' |\ # tr -d '\n' | sed -E 's/\|$//g' +# simple-mtpfs --device 1 /mnt/mtp -o uid=1000 -o gid=1000 -o allow_other + unmounted_description=$( for disk in $unmounted; do dmesg | grep "^$disk" | uniq |\ diff --git a/.scripts/notify_disks.sh b/.scripts/notify_disks.sh index af509ec..be185a2 100755 --- a/.scripts/notify_disks.sh +++ b/.scripts/notify_disks.sh @@ -1,6 +1,10 @@ #!/usr/bin/env bash -mounted_disks=$(lsblk --noheadings --raw -o NAME,SIZE,MOUNTPOINT | awk '$1~/[[:digit:]]/ && $3~/\/mnt/' | awk '{print $3}') +case $(uname) in + Linux) mounted=$(lsblk --noheadings --raw -o NAME,SIZE,MOUNTPOINT |\ + awk '$1~/[[:digit:]]/ && $3~/\/mnt/' | awk '{print $3}') + df_command=$(df -h --output=target,size,pcent,avail / $mounted_disks);; + OpenBSD) df_command=$(df -h | awk '{print $6"\t"$3"\t"$4"\t" $5}' | uniq) ;; +esac -df_command=$(df -h --output=target,size,pcent,avail / $mounted_disks) notify-send "Disks Usage" "$df_command" diff --git a/.scripts/notify_network.sh b/.scripts/notify_network.sh dissimilarity index 81% index 68f913c..1af9b25 100755 --- a/.scripts/notify_network.sh +++ b/.scripts/notify_network.sh @@ -1,20 +1,43 @@ -#!/usr/bin/env bash - -wifi_interface=$(ip route | awk '/^default.*wlp/ {print $5}') -eth_interface=$(ip route | awk '/^default.*enp/ {print $5}') - -if [ $wifi_interface ];then - wifi_ssid=$(iw dev $wifi_interface link | grep SSID | cut -d " " -f 2-) - wifi_strength=$(grep "^\s*w" /proc/net/wireless | awk '{print int($3 * 100 / 70) "%"}') - wifi_ip=$(hostname -i | awk '{ print $1 }') - wifi_result="Wifi\t($wifi_interface)\n$wifi_ssid\t$wifi_strength\n$wifi_ip\n\n" -fi - -if [ $eth_interface ];then - eth_ip=$(ifconfig $eth_interface | awk '/inet / {print $2}') - eth_result="Ethernet\t($eth_interface)\n$eth_ip" -fi - -# public_ip=$(curl https://ipecho.net/plain) - -notify-send "Network details" "$wifi_result$eth_result" +#!/usr/bin/env bash + + +if [[ "$(uname)" == "Linux" ]]; then + wifi_interface=$(ip route | awk '/^default.*wlp/ {print $5}') + eth_interface=$(ip route | awk '/^default.*enp/ {print $5}') + + if [ $wifi_interface ];then + wifi_ssid=$(iw dev $wifi_interface link | grep SSID | cut -d " " -f 2-) + wifi_strength=$(grep "^\s*w" /proc/net/wireless |\ + awk '{print int($3 * 100 / 70) "%"}') + wifi_ip=$(hostname -i | awk '{ print $1 }') + wifi_result="Wifi\t($wifi_interface)\n$wifi_ssid\t$wifi_strength\ + \n$wifi_ip\n\n" + fi + + if [ $eth_interface ];then + eth_ip=$(ifconfig $eth_interface | awk '/inet / {print $2}') + eth_result="Ethernet\t($eth_interface)\n$eth_ip" + fi + +elif [[ "$(uname)" == "OpenBSD" ]]; then + wifi_interface=$(netstat -rn | grep default | awk '{print $8}') +# eth_interface=$() + + if [ $wifi_interface ];then + wifi_ssid=$(ifconfig $wifi_interface | grep join | awk '{print $3}') + wifi_strength=$(ifconfig $wifi_interface | grep join |\ + awk '{print int((-0.0154*$8*$8)-(0.3794*$8)+98.182) "%"}') + wifi_ip=$(ifconfig $wifi_interface | grep inet | awk '{print $2}') + wifi_result="Wifi\t($wifi_interface)\n$wifi_ssid\t$wifi_strength\ + \n$wifi_ip\n\n" + fi +# if [ $eth_interface ];then + +# fi + +fi + +# public_ip=$(curl https://ipecho.net/plain) + +notify-send "Network details" "$wifi_result$eth_result" +echo $wifi_result diff --git a/.scripts/openbsd_connect_wifi.sh b/.scripts/openbsd_connect_wifi.sh new file mode 100644 index 0000000..c96a85a --- /dev/null +++ b/.scripts/openbsd_connect_wifi.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env bash + +interface=athn0 +ssid=$1 +pass=$2 + +doas -- bash -c " ifconfig $interface up ; ifconfig $interface nwid $ssid wpakey $pass ; dhclient $interface" diff --git a/.scripts/openbsd_install.sh b/.scripts/openbsd_install.sh index b83d92d..3f1d49b 100644 --- a/.scripts/openbsd_install.sh +++ b/.scripts/openbsd_install.sh @@ -29,7 +29,8 @@ dd if=/dev/zero of=/dev/$ram_newdisk bs=1m count=1 exit # syspatch -echo 'https://fastly.cdn.openbsd.org/pub/OpenBSD' > /etc/installurl +echo 'https://ftp.openbsd.org/pub/OpenBSD +https://fastly.cdn.openbsd.org/pub/OpenBSD' > /etc/installurl syspatch # fstab @@ -39,17 +40,25 @@ sed -i 's/datasize-max=768M/datasize-max=4096M/' /etc/login.conf # apmd rcctl enable apmd +#TODO -z options from supproted in dmesg rcctl set apmd flags -A -z 7 rcctl start apmd # doas +# TODO some commads no pass echo 'permit hassan' > /etc/doas.conf # disable inteldrm config -fe /bsd disable inteldrm* quit -sha256 +doas sha256 -h /var/db/kernel.SHA256 /bsd + +reorder kernel + +# change shell to bash +chsh -s /usr/local/bin/bash + ############################################################################### @@ -63,29 +72,63 @@ sha256 # install manual main programes # mount data +mkdir /mnt/data +mount sd0i /mnt/data + # dwm +cd /mnt/data/dev/suckless/dwm-6.2/ +vim config.mk +make clean install + +# azan +cd ../azan +make clean install + +# splanner +cd ../splanner +make clean install + # st +cd ../st* +vim config.mk +make clean install + # surf -# vifm -# tcc -# nerdfonts +cd ../st* +vim config.mk +make clean install + + # sent +cd ../st* +vim config.mk +make clean install + # dmenu +cd ../st* +vim config.mk +make clean install + # slstatus +cd ../st* +vim config.mk +make clean install # pull dotfiles +# vifm +sh .scripts/vifm_install.sh + +# tcc +sh .scripts/tcc_install.sh + +# nerdfonts + # install pkg_base sh .scripts/pkg_base.sh # config theme and font +sh .scripts/deploy_theme... # config ssh and gpg - - - - - - - - +sh .scripts/deploy_backup... diff --git a/.scripts/openbsd_ports.sh b/.scripts/openbsd_ports.sh index 41f281b..f4dfbe0 100644 --- a/.scripts/openbsd_ports.sh +++ b/.scripts/openbsd_ports.sh @@ -1,8 +1,8 @@ #!/usr/bin/env bash -$ cd /tmp -$ ftp https://cdn.openbsd.org/pub/OpenBSD/$(uname -r)/{ports.tar.gz,SHA256.sig} -$ signify -Cp /etc/signify/openbsd-$(uname -r | cut -c 1,3)-base.pub -x SHA256.sig ports.tar.gz +cd /tmp +ftp https://cdn.openbsd.org/pub/OpenBSD/$(uname -r)/{ports.tar.gz,SHA256.sig} +signify -Cp /etc/signify/openbsd-$(uname -r | cut -c 1,3)-base.pub -x SHA256.sig ports.tar.gz -# cd /usr -# tar xzf /tmp/ports.tar.gz +cd /usr +doas tar xzf /tmp/ports.tar.gz diff --git a/.scripts/pass_manager.sh b/.scripts/pass_manager.sh index 26b2d5a..8917f1a 100755 --- a/.scripts/pass_manager.sh +++ b/.scripts/pass_manager.sh @@ -9,31 +9,45 @@ #============================================================================== # gpg_id=0F6CD1196B2A5658 -gpg_id=CED2D2F771262467 -gpg_email=hassanafify@protonmail.com +# gpg_id=CED2D2F771262467 +# gpg_email=hassanafify@protonmail.com +gpg_id=$(sh "$HOME/.scripts/gpg.sh" ids | awk '{print $1}') +path=$HOME/.password-store/ # init pass # pass init $gpg_id # pass init $gpg_email -# copy to clipboard (will clear in 45s) -# pass -c $choosen - -# insert old password entry -# pass insert $category_dir/$entry_name - -# insert new generated password entry -# pass generate $category_dir/$entry_name $pass_length - -# remove password entry -# pass rm $category_dir/$entry_name -path=/home/hassan/.password-store/ - -chosen=$(\ - find $path -type f -name "*.gpg" -printf '%f\n' |\ - sed 's/\.gpg$//1'|\ - dmenu -i -p "Pass " -l 10) - -echo $chosen - -pass -c $chosen +insert_old_pass(){ + pass insert $1 +} + +create_new(){ + service_name=$1 + length=$2 + pass generate $service_name $length +} + +delete_pass(){ + pass rm $1 +} + +copy_to_clipboard(){ + chosen=$(\ + ls $path |\ + grep '.*\.gpg' |\ + sed -r 's/\.gpg//g' |\ + dmenu -i -p "Pass " -l 10) + + if [[ $chosen ]]; then + pass -c $chosen + fi +} + +case $1 in + delete) delete_pass $2 ;; + gen) create_new $2 $3 ;; + insert) insert_old_pass $2 ;; + *) copy_to_clipboard ;; + +esac diff --git a/.vimrc b/.vimrc index 745bab5..c19f0df 100644 --- a/.vimrc +++ b/.vimrc @@ -7,6 +7,7 @@ set encoding=utf-8 set fileformat=unix set noswapfile set nocompatible +set backspace=indent,eol,start "============================================================================== " Plugins @@ -233,6 +234,7 @@ let g:airline_symbols.linenr = '' " Linting "============================================================================== let g:syntastic_python_checkers = ['pylint'] +let g:syntastic_sh_checkers = ["bash"] let g:syntastic_c_checkers = ["splint"] let g:syntastic_c_splint_args = "-checks -DVERSION=\\\"VERSION\\\"" -- 2.11.4.GIT