Browse Source

Improve custom script handling

master
jcmdln 1 year ago
parent
commit
cd73d77ef6
6 changed files with 114 additions and 146 deletions
  1. 1
    1
      etc/i3/config
  2. 27
    37
      etc/profile
  3. 0
    70
      etc/profile.d/gpkg.sh
  4. 0
    38
      etc/profile.d/kbuild.sh
  5. 50
    0
      usr/local/gein/gpkg
  6. 36
    0
      usr/local/gein/kbuild

+ 1
- 1
etc/i3/config View File

@@ -13,7 +13,7 @@ bindsym $mod+d exec --no-startup-id dmenu_run
bindsym $mod+Return exec --no-startup-id st -f 'Noto Mono:10pt'

## Display
exec --no-startup-id "bash /etc/srandr.sh"
exec --no-startup-id "sh /etc/srandr.sh"


### Appearance ###################################

+ 27
- 37
etc/profile View File

@@ -5,34 +5,27 @@
# '/usr/share/doc/setup/uidgid' to confirm this is valid.

case $- in
*i*) INTERACTIVE="true" ;;

*)
if [ "$UID" -gt 199 ] && [ "`id -gn`" = "`id -un`" ]; then
# Mask current process as a daemon
umask 002
else
# Mask current process as an initscript
umask 022
fi

return
*i*) INTERACTIVE=true ;;
*) INTERACTIVE=false ;;
esac

# Gentoo has '/etc/profile.env' which needs to be read. Here we will
# check if it exists and source it if found.
if [ $INTERACTIVE = false ]; then
if [ $UID -gt 199 ] && [ "`id -gn`" = "`id -un`" ]; then
# Mask current process as a daemon
umask 002
else
# Mask current process as an initscript
umask 022
fi

[ -e /etc/profile.env ] &&
. /etc/profile.env
return
fi


# OpenBSD allows setting a custom URL for pkgsrc. This section confirms
# that 'pkg_add' is an available command
# Gentoo has '/etc/profile.env' which needs to be read. Here we will
# check if it exists and source it if found.

[ -e "$(command -v pkg_add)" ] &&
PKG_PATH="https://mirror.leaseweb.com/openbsd" &&
PKG_PATH="$PKG_PATH/snapshots/packages/amd64/" &&
export PKG_PATH
[ -e /etc/profile.env ] && source /etc/profile.env


# Setting PS1 correctly depending on the current shell can be important
@@ -40,9 +33,7 @@ esac
# other shells if currently in use, and default to standard shell
# semantics.

if [ -e "$BASH_VERSION" ]; then
PS1="[\u@\h \W]\$ "
elif [ -e "$ZSH_VERSION" ]; then
if [ ! -n $ZSH_VERSION ]; then
PS1="[%n@%M %d]$ "
else
PS1="[\u@\h \W]\$ "
@@ -54,10 +45,7 @@ fi
# may look quite upsetting but it works for our purposes.

PATH="/usr/local/sbin/:/usr/local/bin:/usr/sbin:/usr/bin:/opt/bin"
PATH="$PATH:/sbin:/bin:$HOME/.local/bin:$HOME/.bin:$HOME/bin"

[ -d /usr/X11R6/bin ] &&
PATH="$PATH:/usr/X11R6/bin"
PATH="$PATH:/usr/local/gein:/sbin:/bin:$HOME/.local/bin:$HOME/.bin:$HOME/bin"

MANPATH="/usr/man:/usr/share/man:/usr/local/man:/usr/local/share/man"
MANPATH="$MANPATH:$HOME/.local/man:$HOME/.local/share/man"
@@ -66,14 +54,16 @@ MANPATH="$MANPATH:$HOME/.local/man:$HOME/.local/share/man"
# This section defines our exports, including the PATH, MANPATH and PS1
# that we defined in previous sections.

export EDITOR="emacs -nw"
export EDITOR="vi"
#export HISTTIMEFORMAT="(%m/%d/%y) %T "
export LANG="en_US.UTF-8"
export MANPATH
export PAGER="less"
export PAGER="/usr/bin/less"
export PATH
export PROMPT_COMMAND="history -a"
export PS1
export SSH_KEY_PATH="$HOME/.ssh/rsa_id"
export TERM="xterm"


# This section will find and source all files in '/etc/profile.d' that
@@ -81,8 +71,7 @@ export SSH_KEY_PATH="$HOME/.ssh/rsa_id"
# that will comprise environment settings or other configurations.

for sh in /etc/profile.d/*.sh; do
[ -r "$sh" ] &&
. "$sh"
[ -r "$sh" ] && source "$sh"
done


@@ -91,10 +80,11 @@ done
# files within '$HOME/profile.d' that end in '.sh' similarly to the above
# section.

if [ -d "$HOME"/.profile.d ]; then
for sh in $HOME/.profile.d/*.sh; do
[ -r "$sh" ] &&
. "$sh"
[ -e $HOME/.profile ] && source $HOME/.profile

if [ -d $HOME/profile.d ]; then
for sh in $HOME/profile.d/*.sh; do
[ -r "$sh" ] && source "$sh"
done
fi


+ 0
- 70
etc/profile.d/gpkg.sh View File

@@ -1,70 +0,0 @@
# /etc/profile.d/gein.sh

gpkg() {
if [ $EUID -ne 0 ]; then
if [ -e $(command -v sudo) ]; then
SU="sudo"
else
SU="su -c"
fi
fi

case $1 in
-S|sync)
echo "gpkg: syncing Portage..."
$SU emerge -q --sync &&
echo "gpkg: Portage sync completed"
;;

-i|install)
$SU emerge -av --quiet-build ${@:2}
;;

-d|depends)
$SU equery
;;

-r|--remove)
$SU emerge -avc --quiet-build ${@:2}
;;

-p|--purge)
$SU gpkg -r $(qlist -CI ${@:2})
;;

-c|--clean)
$SU emerge -av --depclean --quiet-build
;;

-u|--update)
case $2 in
-w|--world)
$SU emerge -avuDU --keep-going --with-bdeps=y \
--quiet-build @world
;;

-s|--system)
$SU emerge -avuDN --quiet-build @system
;;

*)
echo "gpkg: update: Available options:"
echo " -w, --world Update world packages"
echo " -s, --system Update system packages"
;;
esac
;;

*)
echo "gpkg: Available options:"
echo " -S, --sync Sync Portage"
echo " -i, --install Install a package"
echo " -r, --remove Safely remove a package"
echo " -p, --purge Purge package and dependencies"
echo " -c, --clean Remove unneeded packages"
echo " -u, --update Update packages"
echo " -w, --world Update world packages"
echo " -s, --system Update system packages"
;;
esac
}

+ 0
- 38
etc/profile.d/kbuild.sh View File

@@ -1,38 +0,0 @@
# /etc/profile.d/kbuild.sh

kbuild() {
CWD="$(pwd)"

if [ $EUID -ne 0 ]; then
if [ -e $(command -v sudo) ]; then
SU="sudo"
else
SU="su -c"
fi
fi

KMake="make -s -j$(grep -c ^processor /proc/cpuinfo)"

eselect kernel list
TargetProfile=""
while [ -z "$TargetProfile" ]; do
read -ep "Which profile?: " TargetProfile
done

if [ -n "$TargetProfile" ]; then
$SU eselect kernel set "$TargetProfile" &&
cd /usr/src/linux &&
$SU make menuconfig &&
$SU $KMake &&
$SU $KMake modules &&
$SU $KMake install &&
$SU $KMake modules install &&
$SU grub-mkconfig -o /boot/grub/grub.cfg &&
$SU emerge -av --quiet-build @module-rebuild
fi

$SU make clean
unset KMake

cd $CWD
}

+ 50
- 0
usr/local/gein/gpkg View File

@@ -0,0 +1,50 @@
#!/usr/bin/env sh

if [ $EUID -ne 0 ]; then
if [ -e $(command -v sudo) ]; then
SU="sudo"
else
SU="su -c"
fi
fi

case $@ in
-s|sync)
echo "gpkg: syncing Portage..."
$SU emerge -q --sync &&
echo "gpkg: Portage sync completed"
;;

-i|install)
$SU emerge -av --quiet-build ${@:2}
;;

-r|remove)
$SU emerge -avc --quiet-build ${@:2}
;;

-p|purge)
$SU gpkg -r $(qlist -CI ${@:2})
;;

-u|update)
$SU emerge -avuDU --keep-going --quiet-build @world &&
$SU emerge -av --depclean --quiet-build
;;

-U|upgrade)
$SU emerge -avuDN --quiet-build @system &&
$SU emerge -av --depclean --quiet-build
;;

*)
echo "gpkg: Available options:"
echo " -s, sync Sync Portage"
echo " -i, install Install a package"
echo " -r, remove Safely remove a package"
echo " -p, purge Purge package and dependencies"
echo " -c, clean Remove unneeded packages"
echo " -u, update Update @world packages"
echo " -U, upgrade Update @system packages"
;;
esac

+ 36
- 0
usr/local/gein/kbuild View File

@@ -0,0 +1,36 @@
#!/usr/bin/env sh

CWD="$(pwd)"

if [ $EUID -ne 0 ]; then
if [ -e $(command -v sudo) ]; then
SU="sudo"
else
SU="su -c"
fi
fi

KMake="make -s -j$(grep -c ^processor /proc/cpuinfo)"

eselect kernel list
TargetProfile=""
while [ -z "$TargetProfile" ]; do
read -ep "Which profile?: " TargetProfile
done

if [ -n "$TargetProfile" ]; then
$SU eselect kernel set "$TargetProfile" &&
cd /usr/src/linux &&
$SU make menuconfig &&
$SU $KMake &&
$SU $KMake modules &&
$SU $KMake install &&
$SU $KMake modules install &&
$SU grub-mkconfig -o /boot/grub/grub.cfg &&
$SU emerge -av --quiet-build @module-rebuild
fi

$SU make clean
unset KMake

cd $CWD

Loading…
Cancel
Save