diff --git a/.copyrightheader b/.copyrightheader new file mode 100755 index 0000000..e69de29 diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml old mode 100644 new mode 100755 index 86b1a4d..95ff13b --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -20,6 +20,7 @@ jobs: - 'bootstrap' - bashrc/** - zshrc/** + - tools/** manual: - .github/workflows/lint.yml - name: ShellCheck diff --git a/bashrc/worthwhile-functions b/bashrc/worthwhile-functions index 31ea1aa..7399052 100644 --- a/bashrc/worthwhile-functions +++ b/bashrc/worthwhile-functions @@ -10,7 +10,7 @@ disable-funcs () { } edit-funcs-bashrc() { - $(echo $EDITOR || command -v nano>>/dev/null && echo nano || echo vi) ~/.dotfiles/bashrc/worthwhile-functions + $(command -v nano>>/dev/null && echo nano || echo vi) ~/.dotfiles/bashrc/worthwhile-functions } list-debs-size() { @@ -19,7 +19,7 @@ list-debs-size() { edit-script-file() { # if you use other editor, please set $EDITOR. - $(echo $EDITOR || command -v code>>/dev/null && echo code || command -v nano>>/dev/null && echo nano || echo vi) "$(command -v $1)" + $(command -v code>>/dev/null && echo code || command -v nano>>/dev/null && echo nano || echo vi) "$(command -v $1)" } # reloading stuff @@ -34,16 +34,10 @@ refresh-aliases() { git() { # check command for some automation KEK, especially i want to do DCO by default if [[ "$1" == "init" && "$@" != *"--help"* ]]; then - [[ $DEBUG != "" ]] && echo "args: $@" && sleep 3 if command git "$@"; then echo "Setting HEAD to branch main" command git symbolic-ref HEAD refs/heads/main fi - elif [[ "$1" == "commit" && "$@" != *"--help"* && ( "$@" != *"--signoff"* && "$@" != *"-s"* && $@ != *"--amend" ) ]]; then - [ $DEBUG != "" ] && echo "args: $@ --signoff" && sleep 3 - command git "$@" --signoff - elif [[ "$1" == "pull" && "$@" != *"--help"* && ( "$@" != *"--signoff"* && "$@" != *"-s"* ) ]]; then - command git "$@" --signoff else command git "$@" fi diff --git a/bin/setup-chroot b/bin/setup-chroot new file mode 100755 index 0000000..a013606 --- /dev/null +++ b/bin/setup-chroot @@ -0,0 +1,36 @@ +#!/usr/bin/bash + +# Chroot command is optional and assume login binary +CHROOT_COMMAND=${2:-"/usr/bin/login"} +TARGET_DIR=$1 + +if [[ $TARGET_DIR == "" ]]; then + echo "Usage: $0 TARGET_DIR [CHROOT_COMMAND]" + exit 1 +fi + +if [ $EUID != "0" ]; then + echo "error: Must be root to proceed!" + exit 1 +fi + +echo "===> Mounting required parts for chroot operation..." +mount -o bind /dev "$TARGET_DIR/dev" +mount -t proc none "$TARGET_DIR/proc" +mount -o bind /sys "$TARGET_DIR/sys" +echo " Kernel and device mount setup done!" +sleep 3 + +if [[ -f "$TARGET_DIR/setup-chroot-env.sh" ]]; then + echo "===> Preparing chroot environment..." + if ! bash "$TARGET_DIR/setup-chroot-env.sh"; then + echo "! Chroot env setup failed, please proceed at your own risk." + else + echo " Setup done!" + fi + sleep 3 +fi + +echo "===> Teleporting to the chroot environment in 3 seconds..." +sleep 3 +exec chroot "$TARGET_DIR" ${CHROOT_COMMAND} diff --git a/ssh-client/ubuntu b/ssh-client/ubuntu index 18a7bd8..740b93e 100644 --- a/ssh-client/ubuntu +++ b/ssh-client/ubuntu @@ -60,3 +60,9 @@ Host stellapent.local User cursed-remote-user IdentityFile ~/.ssh/launchpad LocalForward 3380 localhost:3389 + +# SourceForge +Host sourceforge + User ajhalili2006 + Hostname shell.sourceforge.net + IdentityFile ~/.ssh/launchpad diff --git a/tools/README.md b/tools/README.md new file mode 100755 index 0000000..3a7acf3 --- /dev/null +++ b/tools/README.md @@ -0,0 +1,4 @@ +# Toolkit for different aspects + +* `setup-scripts` - Post-install scripts for Arch and Alpine, assuming that `/home` is an separate partition. +* `rtapp-spfx-` diff --git a/tools/deb-dist-upgrade b/tools/deb-dist-upgrade new file mode 100755 index 0000000..11cef44 --- /dev/null +++ b/tools/deb-dist-upgrade @@ -0,0 +1,15 @@ +#!/bin/bash + +set -e + +echo "===> Updating local index..." +apt update +echo +sleep 3 + +echo "===> Doing distro upgrade..." +apt-get dist-upgrade --yes +echo +sleep 3 + +echo "info: Please reboot to proceed by typing /sbin/reboot!" diff --git a/tools/rtapp-copyright-headers b/tools/rtapp-copyright-headers new file mode 100755 index 0000000..9ab5b3e --- /dev/null +++ b/tools/rtapp-copyright-headers @@ -0,0 +1,287 @@ +#!/usr/bin/env python +# coding: utf8 +# +## Idempotently add copyright headers to source files. +# +# To check that all files have required headers: +# $ copyright-headers check +# +# To add/update the copyright headers: +# $ copyright-headers update +# +# To ignore files under a certain directory and below: +# $ touch some/directory/.autocopyrightignore +# $ git add some/directory/.autocopyrightignore +# Originally from https://github.com/ghuntley/ghuntley/blob/trunk/third_party/copyright-headers/copyright-headers. +# SPDX-License + +import os +import re +import string +import subprocess +import sys + +######################### +# File-type configuration +# start: The start marker of the block. +# line: The prefix for the notice text. +# end: The end marker of the block. +# skip: Optional prefix for lines to skip when adding header initially. + +filetypes = \ + { 'hs' : { 'start' : '-' * 80 , 'line' : '--' , 'end' : '' , 'empty_line' : '', 'skip' : '#!' } , + 'lhs' : { 'start' : '-' * 80 , 'line' : '--' , 'end' : '' , 'empty_line' : '' } , + 'chs' : { 'start' : '-' * 80 , 'line' : '--' , 'end' : '' , 'empty_line' : '' } , + 'js' : { 'start' : '' , 'line' : '//' , 'end' : '' , 'empty_line' : '' } , + 'ts' : { 'start' : '' , 'line' : '//' , 'end' : '' , 'empty_line' : '' } , + 'tsx' : { 'start' : '' , 'line' : '//' , 'end' : '' , 'empty_line' : '' } , + 'java' : { 'start' : '' , 'line' : '//' , 'end' : '' , 'empty_line' : '' } , + 'scala' : { 'start' : '' , 'line' : '//' , 'end' : '' , 'empty_line' : '' } , + 'rst' : { 'start' : '' , 'line' : '..' , 'end' : '' , 'empty_line' : '' } , + 'tex' : { 'start' : '%' * 80 , 'line' : '%' , 'end' : '' , 'empty_line' : '' } , + 'py' : { 'start' : '#' * 80 , 'line' : '#' , 'end' : '' , 'empty_line' : '', 'skip' : '#!' } , + 'proto' : { 'start' : '/*' , 'line' : '//' , 'end' : '' , 'empty_line' : '' } , + 'c' : { 'start' : '/*' , 'line' : '//' , 'end' : '' , 'empty_line' : '' } , + 'cpp' : { 'start' : '/*' , 'line' : '//' , 'end' : '' , 'empty_line' : '' } , + 'cc' : { 'start' : '/*' , 'line' : '//' , 'end' : '' , 'empty_line' : '' } , + 'h' : { 'start' : '/*' , 'line' : '//' , 'end' : '' , 'empty_line' : '' } , + 'hpp' : { 'start' : '/*' , 'line' : '//' , 'end' : '' , 'empty_line' : '' } , + 'hh' : { 'start' : '/*' , 'line' : '//' , 'end' : '' , 'empty_line' : '' } , + 'groovy' : { 'start' : '/*' , 'line' : '//' , 'end' : '' , 'empty_line' : '' } , + 'sql' : { 'start' : '/*' , 'line' : '--' , 'end' : '' , 'empty_line' : '' } , + 'sh' : { 'start' : '#' * 80 , 'line' : '#' , 'end' : '' , 'empty_line' : '', 'skip' : '#!' } , + 'bats' : { 'start' : '#' * 80 , 'line' : '#' , 'end' : '' , 'empty_line' : '', 'skip' : '#!' } , + 'html' : { 'start' : '' , 'skip' : ' [DIRECTORY]") + print(" If DIRECTORY is provided, checks only in that directory") + print(" Otherwise, checks in 'pkgs'.") + print(" Note that the provided directory must be relative to the") + print(" root of the git repository.") + sys.exit(1) + +chdir_to_toplevel() +with open('.copyrightheader', 'r') as f: + LEGAL_NOTICES = list(map(lambda x: x.strip(), f.readlines())) + +if len(sys.argv) != 2 and len(sys.argv) != 3: + usage() + +if sys.argv[1] == "update": + check_only = False +elif sys.argv[1] == "check": + check_only = True +else: + usage() + +dir = None +if len(sys.argv) > 2: + dir = sys.argv[2] + +failed=False +for file in list_files(dir): + if not process_file(file, check_only): + failed=True + +if failed and check_only: + print("\nCopyright header check failed.\nPlease update copyright headers by running 'copyright-headers update'") + +sys.exit(failed) diff --git a/tools/setup-scripts/alpine b/tools/setup-scripts/alpine new file mode 100755 index 0000000..4e403c1 --- /dev/null +++ b/tools/setup-scripts/alpine @@ -0,0 +1,34 @@ +#!/bin/sh + +set -ex + +# The script will assume you that you\'re on the edge repository and not on stable (in Debian terms, it's +# latest stable version/release) There are some stuff that I didn't include here assuming that your Linux +# setup would be separate home directory for ease installation process. + +SCREEN_NAME="Stick Michael" +USERNAME="gildedguy" + +# Basics: you should use doas instead in daily admin ops +apk add bash zsh git git-lfs github-cli coreutils procps mandoc mandoc-apropos doas +# Documentation stuff goes here, because I don't have time +apk add bash-doc coreutils-doc git-doc git-lfs-doc man-pages mandoc-doc zsh-doc +# shell completions +apk add git-bash-completion github-cli-bash-completion github-cli-zsh-completion +# development packages +apk add python3 python3-doc python3-dev nodejs nodejs-doc py3-pip-bash-completion py3-pip py3-pip-zsh-completion py3-pip-doc + +# setup user and some doas prep +#adduser -g "$SCREEN_NAME" $USERNAME +#adduser $USERNAME video +#adduser $USERNAME audio +#adduser $USERNAME wheel +echo "permit persist :wheel" >> /etc/doas.conf + +# setup xorg server first +setup-xorg-server +# xfce basics + KDE Breeze theme stuff +apk add xfce4 xfce4-terminal xfce4-screensaver lightdm-gtk-greeter breeze breeze-gtk adwaita-gtk2-theme adwaita-icon-theme elogind polkit-elogind +# automounting kek and bloody pulseaudio BS +apk add gvfs udisks2 ntfs-3g pulseaudio pulseaudio-alsa alsa-plugins-pulse +# TODO: Firefox anyone? diff --git a/zshrc/ubuntu.zshrc b/zshrc/ubuntu.zshrc index f2b9299..da12c69 100644 --- a/zshrc/ubuntu.zshrc +++ b/zshrc/ubuntu.zshrc @@ -135,19 +135,19 @@ fi # As long as possible, attempt to setup our GnuPG agent when we're on an SSH session. if [[ -n "$SSH_CLIENT" ]] || [[ -n "$SSH_TTY" ]]; then - eval $(keychain --agents gpg,ssh --eval --nogui --noinherit) + eval $(keychain --agents gpg,ssh --eval --nogui) export GPG_TTY=$(tty) else # We'll do some checks here btw, Currently I use GNOME and Xfce4 as my desktop environments case $(ps -o comm= -p $PPID) in # Sometimes, $SSH_CLIENT and/or $SSH_TTY doesn't exists so we'll pull what ps says - sshd | */sshd) eval $(keychain --agents gpg,ssh --eval --nogui --noinherit);; + sshd | */sshd) eval $(keychain --agents gpg,ssh --eval --nogui);; xfce*) eval $(keychain --agents gpg,ssh --eval);; gnome*) eval $(keychain --agents gpg,ssh --eval);; konsole*) eval $(keychain --agents gpg,ssh --eval);; # Don't forget VS Code and code-server! code* | node*) eval $(keychain --agents gpg,ssh --eval);; - *) eval $(keychain --agents gpg,ssh --eval --nogui --noinherit) ;; + *) eval $(keychain --agents gpg,ssh --eval --nogui) ;; esac fi @@ -178,7 +178,7 @@ export DOCKER_BUILDKIT=1 [ -s "$HOME/.config/envman/load.sh" ] && source "$HOME/.config/envman/load.sh" # direnv -[ "$(which direnv)" != "" ] && eval "$(direnv hook zsh)" +[ "$(command -v direnv)" != "" ] && eval "$(direnv hook zsh)" # Pyenv export PYENV_ROOT="$HOME/.pyenv"