- Many fixes to sourcing, now will always resolve to base dir.
- All scripts are again `sh` compatible. - Binbox overhaul, symlinks finally work just like `busybox`. - Error checking to some files like `sw` and `own`. TODO: Make it pretty and make `short` already.
This commit is contained in:
parent
b5c8a3f894
commit
0912f2d3d4
13 changed files with 1143 additions and 33 deletions
24
binbox
24
binbox
|
|
@ -1,10 +1,10 @@
|
|||
#!/bin/bash
|
||||
#!/bin/sh
|
||||
# binbox: Creates a multi-binary script that self-contains the input scripts.
|
||||
# Symlinking to the resulting binary with the name of one of the original scripts will trigger
|
||||
# said script. The idea is similar to `busybox`.
|
||||
|
||||
DAISY_INTERNAL=1
|
||||
. daisy.source
|
||||
. $(dirname $(realpath $0))/daisy.source
|
||||
|
||||
ARGS=$@
|
||||
|
||||
|
|
@ -135,15 +135,6 @@ for f in "${includes[@]}"; do
|
|||
add "$(cat "$f")"
|
||||
done
|
||||
|
||||
add ""
|
||||
add "if [[ \$# -eq 0 ]]; then"
|
||||
add " echo 'Available modules:'"
|
||||
for f in "${inputs[@]}"; do
|
||||
add "echo '$f'"
|
||||
done
|
||||
add " exit 0"
|
||||
add "fi"
|
||||
|
||||
|
||||
# >>> Section 2: Modules
|
||||
for f in "${inputs[@]}"; do
|
||||
|
|
@ -156,10 +147,17 @@ done
|
|||
|
||||
# >>> Section 3: Module selection
|
||||
add "SYMED=1"
|
||||
add "BINSELF=\$(basename \$0 | rev | cut -d "/" -f 1 | rev)"
|
||||
add "BOXFILE=$(basename \"$output\")"
|
||||
add "BINSELF=\$(basename \$0)"
|
||||
add "BOXFILE=\"$output\""
|
||||
add "if [[ \$BINSELF == \$BOXFILE ]]; then"
|
||||
add " SYMED=0"
|
||||
add " if [[ \$# -eq 0 ]]; then"
|
||||
add " echo 'Available modules:'"
|
||||
for f in "${inputs[@]}"; do
|
||||
add " echo '$f'"
|
||||
done
|
||||
add " exit 0"
|
||||
add " fi"
|
||||
add "fi"
|
||||
|
||||
add "if [[ \$SYMED -eq 0 ]]; then"
|
||||
|
|
|
|||
8
calm
8
calm
|
|
@ -1,5 +1,4 @@
|
|||
#!/bin/bash
|
||||
#LACKSETUP
|
||||
#!/bin/sh
|
||||
# Calm a process down
|
||||
# NEEDS_WORK: cleanup
|
||||
# calm <pid> == only one process
|
||||
|
|
@ -8,7 +7,12 @@
|
|||
# calm <pid> <bin> .... OK
|
||||
# set's NICE value to 0
|
||||
# need sudo
|
||||
|
||||
DAISY_INTERNAL=1
|
||||
. $(dirname $(realpath $0))/daisy.source
|
||||
|
||||
PIDS=$@
|
||||
|
||||
errorFn()
|
||||
{
|
||||
echo calm: Invalid operation or no such PID/process \(\"$(echo "$PIDS" | tr '\n' ' ' | cut -c -20)...\"\)
|
||||
|
|
|
|||
5
cdz
5
cdz
|
|
@ -1,8 +1,9 @@
|
|||
#!/bin/bash
|
||||
#!/bin/sh
|
||||
|
||||
if [[ $DAISY_INTERNAL -ne 1 ]];
|
||||
then
|
||||
DAISY_INTERNAL=1 source $DAISY_SOURCE_FILE
|
||||
export DAISY_INTERNAL=1
|
||||
. $(dirname $(realpath $0))/daisy.source
|
||||
fi
|
||||
|
||||
target=$1
|
||||
|
|
|
|||
|
|
@ -11,7 +11,10 @@
|
|||
# only included if sourced from one of the included scripts, though you are
|
||||
# free to bypass this by setting env variable DAISY_INTERNAL to 1.
|
||||
|
||||
[[ $DAISY_INTERNAL -eq 1 ]] && export DAISY_BIN=$(basename $0)
|
||||
if [[ $DAISY_INTERNAL -eq 1 ]];
|
||||
then
|
||||
export DAISY_BIN=$(basename $0)
|
||||
fi
|
||||
|
||||
# Intro function
|
||||
function daisy_help()
|
||||
|
|
|
|||
5
editx
5
editx
|
|
@ -1,7 +1,10 @@
|
|||
# !/bin/bash
|
||||
# !/bin/sh
|
||||
# This utility pre-allocs a file and adds execution permissions. It also
|
||||
# removes the resulting file if it is empty after the editor closes.
|
||||
|
||||
DAISY_INTERNAL=1
|
||||
. $(dirname $(realpath $0))/daisy.source
|
||||
|
||||
if [[ -z $1 ]];
|
||||
then
|
||||
echo "No filename specified."
|
||||
|
|
|
|||
6
filewait
6
filewait
|
|
@ -1,5 +1,9 @@
|
|||
#!/bin/bash
|
||||
#!/bin/sh
|
||||
# A simple utility that waits for a file to become available, infinitely
|
||||
|
||||
DAISY_INTERNAL=1
|
||||
. $(dirname $(realpath $0))/daisy.source
|
||||
|
||||
FILE=$@
|
||||
while [ ! -f "$FILE" ]
|
||||
do
|
||||
|
|
|
|||
5
newday
5
newday
|
|
@ -14,6 +14,9 @@
|
|||
# You can use this for a primitive form of note-taking, but aside from notes -
|
||||
# you can store any data this way.
|
||||
|
||||
DAISY_INTERNAL=1
|
||||
. $(dirname $(realpath $0))/daisy.source
|
||||
|
||||
BINSELF=$(basename $0)
|
||||
DIR_NAME=ByDate
|
||||
ROOT_DIR=$HOME/$DIR_NAME
|
||||
|
|
@ -49,4 +52,4 @@ test -L "$TODAY_SYM" && rm -rf "$TODAY_SYM"
|
|||
mkdir -p "$ROOT_DIR/$YEAR/$MONTH/$DAY"
|
||||
cd $ROOT_DIR
|
||||
ln -s "./$DIR_NAME/$YEAR/$MONTH/$DAY" "$TODAY_SYM"
|
||||
|
||||
exitcode=@?
|
||||
|
|
|
|||
15
own
15
own
|
|
@ -1,4 +1,17 @@
|
|||
#!/bin/sh
|
||||
# Simple program that changes ownership to the current
|
||||
# user, recursively.
|
||||
sudo chown -R $(whoami):$(whoami) $1
|
||||
|
||||
DAISY_INTERNAL=1
|
||||
. $(dirname $(realpath $0))/daisy.source
|
||||
|
||||
if [[ $@ == '' ]];
|
||||
then
|
||||
echo "$DAISY_BIN: Used to quickly take ownership of files/folders."
|
||||
echo "Requires sudo. If sudo is not installed, this tool will fai."
|
||||
echo "Usage: $DAISY_BIN <folders or files>"
|
||||
echo "Means: chown -R <youruser>:<youruser> <folders or files>"
|
||||
exit 2
|
||||
fi
|
||||
|
||||
sudo chown -R $(whoami):$(whoami) $@
|
||||
|
|
|
|||
13
short
13
short
|
|
@ -1,11 +1,11 @@
|
|||
#!/bin/bash
|
||||
#!/bin/sh
|
||||
# short: Creates shortcuts that can be used anywhere.
|
||||
# Can also be used as an alternative for "alias".
|
||||
#
|
||||
# Example usage:
|
||||
# Add a shortcut: short -A dev "/home/john/Development"
|
||||
# Print shortcut content: short dev -> "/home/john/Development"
|
||||
# Remove shortcut: short -D dev
|
||||
# Add a shortcut: short -A dev "/home/john/Development"
|
||||
# Print shortcut content: short dev -> "/home/john/Development"
|
||||
# Remove shortcut: short -D dev
|
||||
#
|
||||
# One could use this to do things like:
|
||||
# cp -R files $(short dev)
|
||||
|
|
@ -14,6 +14,9 @@
|
|||
#
|
||||
# Uses a file named .shortcuts in $HOME
|
||||
|
||||
SHORT_FILE=$HOME/.shortcuts
|
||||
DAISY_INTERNAL=1
|
||||
. $(dirname $(realpath $0))/daisy.source
|
||||
|
||||
SHORT_FILE="$DAISY_CONFIG_FOLDER/.shortcuts"
|
||||
|
||||
|
||||
|
|
|
|||
2
shrc
2
shrc
|
|
@ -25,7 +25,7 @@ else
|
|||
RC_NAME="."$BASENAME"rc"
|
||||
RC_PATH="$HOME/$RC_NAME"
|
||||
|
||||
# Optional MD5 checks
|
||||
# Optional MD5 checks
|
||||
HAS_CHANGED=1
|
||||
SUM1=$(md5_opt "$RC_PATH")
|
||||
SUM2=
|
||||
|
|
|
|||
15
sw
15
sw
|
|
@ -1,6 +1,9 @@
|
|||
#!/bin/sh
|
||||
# It just swaps two files
|
||||
|
||||
export DAISY_INTERNAL=1
|
||||
. $(dirname $(realpath $0))/daisy.source
|
||||
|
||||
FILE1=$1
|
||||
FILE2=$2
|
||||
|
||||
|
|
@ -9,17 +12,21 @@ function helpFn()
|
|||
ERROR=$?
|
||||
if [[ $ERROR -gt 0 ]];
|
||||
then
|
||||
echo "$BINSELF error ($ERROR): "
|
||||
perl -E 'say $!=shift' $ERROR
|
||||
ERROR_TEXT=$(perl -E 'say $!=shift' $ERROR)
|
||||
echo "$DAISY_BIN error ($ERROR): $ERROR_TEXT"
|
||||
fi
|
||||
echo "Usage: $BINSELF <file1> <file2>"
|
||||
echo "Usage: $DAISY_BIN <file1> <file2>"
|
||||
echo Swap two files in a filesystem.
|
||||
exit $ERROR
|
||||
}
|
||||
|
||||
if [[ $@ == *"--help"* ]];
|
||||
if [[ $@ == *"--help"* ]];
|
||||
then
|
||||
helpFn
|
||||
elif [[ $@ == '' ]];
|
||||
then
|
||||
echo "No arguments specified."
|
||||
helpFn
|
||||
fi
|
||||
|
||||
# We set a trap here, together with 'set -e' above,
|
||||
|
|
|
|||
3
what
3
what
|
|
@ -23,6 +23,9 @@
|
|||
# /usr/sbin/vsftpd
|
||||
#
|
||||
|
||||
DAISY_INTERNAL=1
|
||||
. $(dirname $(realpath $0))/daisy.source
|
||||
|
||||
PWD=/
|
||||
ALL_BINS=$(cd / && echo $PATH | sed 's/[:]/ /g' | xargs ls -A | grep -v ":" | sort | uniq)
|
||||
OUTPUT=$(printf '%s\n' "-n" $ALL_BINS | grep -i "$1")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue