From: Nicolas Boisselier Date: Sun, 5 Jul 2015 03:52:31 +0000 (+0100) Subject: rename profile.sh and others X-Git-Url: https://git.nbdom.net/?a=commitdiff_plain;h=e757cca64844c4f56afda0ede9097e03b770696a;p=nb.git rename profile.sh and others --- diff --git a/bin/nb-install b/bin/nb-install index a95d2cc3..a47a68e5 100755 --- a/bin/nb-install +++ b/bin/nb-install @@ -4,7 +4,7 @@ # Install - NB 18.11.14 # ############################################################################## -. "${BASH_SOURCE%/*}/../etc/profile.sh" || exit +. "${BASH_SOURCE%/*}/../etc/profile" || exit declare -r NAME="$(basename "${0}")" declare TMP=/tmp/$NAME.$$ declare INSTALL="rsync -au --force" @@ -60,7 +60,7 @@ fi # # Profile # -echo "[ -r $NB_ROOT/etc/profile.sh ] && . $NB_ROOT/etc/profile.sh" > $TMP.profile +echo "[ -r $NB_ROOT/etc/profile ] && . $NB_ROOT/etc/profile" > $TMP.profile if [ -d /etc/profile.d ]; then if fdiff $TMP.profile /etc/profile.d/nb-profile.sh; then diff --git a/bin/nb-update b/bin/nb-update index 2d007e4d..b1de8a3d 100755 --- a/bin/nb-update +++ b/bin/nb-update @@ -4,8 +4,7 @@ # Call by cron/etc/nb # ##################################################################### - -. "${BASH_SOURCE%/*}/../etc/profile.sh" || exit +. "${BASH_SOURCE%/*}/../etc/profile" || exit declare -r NAME="$(basename "${0}")" ##################################################################### @@ -21,6 +20,10 @@ git pull echo ">nb-install" nb-install +NB_USER=`(ls -dl . 2>/dev/null || printf '1 2 root') | awk '{print $3}'` +echo ">Owner: $NB_USER" +chown "$NB_USER" /var/log/nb.log 2> /dev/null + ##################################################################### # Others git repos from nbdom # diff --git a/etc/aliases b/etc/aliases new file mode 100644 index 00000000..19501492 --- /dev/null +++ b/etc/aliases @@ -0,0 +1,124 @@ +################################################################################# +# +# Aliases +# +################################################################################# + +#-------------------------------------------------------------------------------- +# Others +# +alias uuid-hds='blkid -o full -s UUID' +# NB 20.05.15 alias myip='lynx --dump --source http://www.ipchicken.com/ | sed -ne "s/^.*[^0-9]\(\([0-9]\{1,3\}\.\)\{3\}[0-9]\{1,3\}\).*$/\1/p"' +alias myip='lynx --dump --source http://nicolas.boisselier.free.fr/myip/' +alias dpkg-sort-size="dpkg-query -W --showformat='${Installed-Size;10}\t${Package}\n' | sort -k1,1nr" +alias password-gener='apg -m 12 -x 12 -a 0 -M L|head -1;' +alias mysqlshow-view="mysql -e \"SHOW FULL TABLES WHERE TABLE_TYPE LIKE 'VIEW'\"" +alias nmap-ping="nmap -sP -PE -PS443 -PA21,22,23,80,3389" +alias arp-list="arp -an" +alias pdf2jpegs='gs -dNOPAUSE -sDEVICE=jpeg -dFirstPage=1 -dLastPage=5 -sOutputFile=pdf2jpegs%d.jpg -dJPEGQ=100 -r500 -c quit' +alias nb-maildir-make="maildirmake -S Maildir; for d in Spam Trash Sent;do maildirmake -f $d Maildir; done" + +#[ "$UID" = "0" ] && grep -q '^_\?postgres:' /etc/passwd && alias psql='sudo -u postgres psql' + +#-------------------------------------------------------------------------------- +# Etherwake +# Cable: alias advent-on="etherwake -i eth0 00:22:68:7b:fb:99 -D -b" +# +#which etherwake &> /dev/null && alias advent-on="etherwake -i eth0 48:5b:39:eb:db:8a -D -b" + +#-------------------------------------------------------------------------------- +# seq / jot +# +case "$OSTYPE" in + darwin*) alias seq='jot' ;; + *) alias jot='seq' ;; +esac + +#-------------------------------------------------------------------------------- +# Beep +# +alias beep='printf "\a"' + +#-------------------------------------------------------------------------------- +# Mac iTerm.app +# +test "$TERM_PROGRAM" = "iTerm.app" && export PROMPT_COMMAND='printf "\033]0;%s\007" "${USER}@${HOSTNAME%%.*}"' + +#-------------------------------------------------------------------------------- +# Get / Head +# +#if which lynx &> /dev/null; then + alias Head="lynx -dump -head -width=0" + alias Get="lynx -source -width=0" +#fi + +#-------------------------------------------------------------------------------- +# bc +# +alias bc="bc -q" + +#-------------------------------------------------------------------------------- +# iconv +# +alias latin1_utf8='iconv -f latin1 -t utf8' +alias utf8_latin1='iconv -f utf8 -t latin1' + +#-------------------------------------------------------------------------------- +# vim +# +alias vi=vim + +#-------------------------------------------------------------------------------- +# xterm +# +[ -x /usr/bin/xterm ] && alias xterm="xterm -bg black -fg gray -fn 10x20" + +#-------------------------------------------------------------------------------- +# Torrent +# +opt="--max_upload_rate 1 --minport 6881 --maxport 6999" +if which btlaunchmanycurses.py &> /dev/null; then + + opt="$opt --max_download_rate 150 --max_files_open 0" + + alias torrent="btdownloadcurses.py $opt" + alias torrentdir="btlaunchmanycurses.py $opt" + +elif which btdownloadcurses &> /dev/null; then + + alias torrent="btdownloadcurses $opt" + alias torrentdir="btlaunchmanycurses $opt" + +fi +unset opt + +#-------------------------------------------------------------------------------- +# debian upgrade +# +alias servers-upgrade='server-package.pl update,upgrade $((printf "big.cascais.loc\n";mysql -h mysql izi -NBe "select host from server where not hidden") | sort -u)' + +#-------------------------------------------------------------------------------- +# Mac OS +# +case "$OSTYPE" in darwin*) + + alias strace='dtruss' + alias updatedb='bash -c "cd / && /usr/libexec/locate.updatedb &"' + alias mac-dns-flush='dscacheutil -flushcache' + #alias mac-wakeup-screen="pmset schedule wake '\$(date +\"%d/%m/%Y %T\")'" + #alias mac-wakeup-screen2='osascript -e \'tell application "System Events" to key code 123\'' + alias mac-sleep='pmset sleepnow' + alias mac-halt='halt=1 && bash -c "(sleep 3 && halt) &" && logout' + alias mac-top-proc="echo 'TOP PROCESSES:'; ps -Aro'%cpu, ucomm, user' | grep $USER | grep -v ' 0.0 '" + alias mac-automount='sudo automount -v' + alias mac-vlc-playlists="open -a vlc --args /home/nico/Music/*/*.m3u" + alias mac-mount-nfs="sudo mount -o resvport -t nfs" + +esac + +#-------------------------------------------------------------------------------- +# Git +# +alias git-grep="git grep --color=auto" +alias git-ls-tree="git ls-tree --full-tree -r HEAD" +alias git-ls-files="git ls-files" diff --git a/etc/bashrc b/etc/bashrc index 9146f759..b5e36d11 100644 --- a/etc/bashrc +++ b/etc/bashrc @@ -5,6 +5,9 @@ ################################################################################# . "${BASH_SOURCE%/*}/bashrc.function" +# +# BASE +# NB_ROOT=$(realpath ${BASH_SOURCE%/*}/..) [ -z "$HOME" ] && HOME=`realpath ~/` [ -z "$HOSTNAME" ] && HOSTNAME=`hostname` @@ -13,7 +16,7 @@ NB_ROOT=$(realpath ${BASH_SOURCE%/*}/..) [ -z "$OSTYPE" ] && OSTYPE=`uname|tr [:upper:] [:lower:]` # -# PATH +# PATHS # PATH=`nb_env_add_path "$PATH" \ /bin \ @@ -83,6 +86,7 @@ fi # ls # ls_opt='-a' +case "$OSTYPE" in darwin*) DARWIN=1;; esac if [ -n "$DARWIN" ]; then [ "$color_prompt" = yes ] && ls_opt="$ls_opt -G" else @@ -93,8 +97,3 @@ fi unset ls_opt alias ll='ls -lh' unset color char color_prompt h - -# -# ALIASES -# -. "${BASH_SOURCE%/*}/bashrc.alias" diff --git a/etc/bashrc.alias b/etc/bashrc.alias deleted file mode 100644 index 19501492..00000000 --- a/etc/bashrc.alias +++ /dev/null @@ -1,124 +0,0 @@ -################################################################################# -# -# Aliases -# -################################################################################# - -#-------------------------------------------------------------------------------- -# Others -# -alias uuid-hds='blkid -o full -s UUID' -# NB 20.05.15 alias myip='lynx --dump --source http://www.ipchicken.com/ | sed -ne "s/^.*[^0-9]\(\([0-9]\{1,3\}\.\)\{3\}[0-9]\{1,3\}\).*$/\1/p"' -alias myip='lynx --dump --source http://nicolas.boisselier.free.fr/myip/' -alias dpkg-sort-size="dpkg-query -W --showformat='${Installed-Size;10}\t${Package}\n' | sort -k1,1nr" -alias password-gener='apg -m 12 -x 12 -a 0 -M L|head -1;' -alias mysqlshow-view="mysql -e \"SHOW FULL TABLES WHERE TABLE_TYPE LIKE 'VIEW'\"" -alias nmap-ping="nmap -sP -PE -PS443 -PA21,22,23,80,3389" -alias arp-list="arp -an" -alias pdf2jpegs='gs -dNOPAUSE -sDEVICE=jpeg -dFirstPage=1 -dLastPage=5 -sOutputFile=pdf2jpegs%d.jpg -dJPEGQ=100 -r500 -c quit' -alias nb-maildir-make="maildirmake -S Maildir; for d in Spam Trash Sent;do maildirmake -f $d Maildir; done" - -#[ "$UID" = "0" ] && grep -q '^_\?postgres:' /etc/passwd && alias psql='sudo -u postgres psql' - -#-------------------------------------------------------------------------------- -# Etherwake -# Cable: alias advent-on="etherwake -i eth0 00:22:68:7b:fb:99 -D -b" -# -#which etherwake &> /dev/null && alias advent-on="etherwake -i eth0 48:5b:39:eb:db:8a -D -b" - -#-------------------------------------------------------------------------------- -# seq / jot -# -case "$OSTYPE" in - darwin*) alias seq='jot' ;; - *) alias jot='seq' ;; -esac - -#-------------------------------------------------------------------------------- -# Beep -# -alias beep='printf "\a"' - -#-------------------------------------------------------------------------------- -# Mac iTerm.app -# -test "$TERM_PROGRAM" = "iTerm.app" && export PROMPT_COMMAND='printf "\033]0;%s\007" "${USER}@${HOSTNAME%%.*}"' - -#-------------------------------------------------------------------------------- -# Get / Head -# -#if which lynx &> /dev/null; then - alias Head="lynx -dump -head -width=0" - alias Get="lynx -source -width=0" -#fi - -#-------------------------------------------------------------------------------- -# bc -# -alias bc="bc -q" - -#-------------------------------------------------------------------------------- -# iconv -# -alias latin1_utf8='iconv -f latin1 -t utf8' -alias utf8_latin1='iconv -f utf8 -t latin1' - -#-------------------------------------------------------------------------------- -# vim -# -alias vi=vim - -#-------------------------------------------------------------------------------- -# xterm -# -[ -x /usr/bin/xterm ] && alias xterm="xterm -bg black -fg gray -fn 10x20" - -#-------------------------------------------------------------------------------- -# Torrent -# -opt="--max_upload_rate 1 --minport 6881 --maxport 6999" -if which btlaunchmanycurses.py &> /dev/null; then - - opt="$opt --max_download_rate 150 --max_files_open 0" - - alias torrent="btdownloadcurses.py $opt" - alias torrentdir="btlaunchmanycurses.py $opt" - -elif which btdownloadcurses &> /dev/null; then - - alias torrent="btdownloadcurses $opt" - alias torrentdir="btlaunchmanycurses $opt" - -fi -unset opt - -#-------------------------------------------------------------------------------- -# debian upgrade -# -alias servers-upgrade='server-package.pl update,upgrade $((printf "big.cascais.loc\n";mysql -h mysql izi -NBe "select host from server where not hidden") | sort -u)' - -#-------------------------------------------------------------------------------- -# Mac OS -# -case "$OSTYPE" in darwin*) - - alias strace='dtruss' - alias updatedb='bash -c "cd / && /usr/libexec/locate.updatedb &"' - alias mac-dns-flush='dscacheutil -flushcache' - #alias mac-wakeup-screen="pmset schedule wake '\$(date +\"%d/%m/%Y %T\")'" - #alias mac-wakeup-screen2='osascript -e \'tell application "System Events" to key code 123\'' - alias mac-sleep='pmset sleepnow' - alias mac-halt='halt=1 && bash -c "(sleep 3 && halt) &" && logout' - alias mac-top-proc="echo 'TOP PROCESSES:'; ps -Aro'%cpu, ucomm, user' | grep $USER | grep -v ' 0.0 '" - alias mac-automount='sudo automount -v' - alias mac-vlc-playlists="open -a vlc --args /home/nico/Music/*/*.m3u" - alias mac-mount-nfs="sudo mount -o resvport -t nfs" - -esac - -#-------------------------------------------------------------------------------- -# Git -# -alias git-grep="git grep --color=auto" -alias git-ls-tree="git ls-tree --full-tree -r HEAD" -alias git-ls-files="git ls-files" diff --git a/etc/bashrc.function b/etc/bashrc.function index 003bdfd1..1e94aea0 100644 --- a/etc/bashrc.function +++ b/etc/bashrc.function @@ -271,7 +271,7 @@ find-sort-mtime() { } nb-alert() { - local cmd=". $NB_ROOT/etc/profile.sh" + local cmd=". $NB_ROOT/etc/profile" local host=macbook.brighton.loc case "$1" in led) diff --git a/etc/profile b/etc/profile new file mode 100644 index 00000000..3883f93d --- /dev/null +++ b/etc/profile @@ -0,0 +1,10 @@ +#case "$SHELL" in */zsh) BASH_SOURCE=${(%):-%N} ;; esac +[ -r "${BASH_SOURCE%/*}/bashrc" ] && . "${BASH_SOURCE%/*}/bashrc" +[ -r "${BASH_SOURCE%/*}/aliases" ] && . "${BASH_SOURCE%/*}/aliases" + +for i in $NB_ROOT/etc/*.sh; do + [ -r "$i" ] && . "$i" +done +unset i + +true diff --git a/etc/profile.sh b/etc/profile.sh deleted file mode 100644 index 17a96433..00000000 --- a/etc/profile.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/usr/bin/env bash - -case "$SHELL" in - */zsh) BASH_SOURCE=${(%):-%N} ;; -esac - -case "$OSTYPE" in darwin*) - DARWIN=1 -esac - -[ -r "${BASH_SOURCE%/*}/bashrc" ] && . "${BASH_SOURCE%/*}/bashrc"