- 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:
Sam Hardeman 2025-09-22 08:34:50 +02:00
parent b5c8a3f894
commit 0912f2d3d4
13 changed files with 1143 additions and 33 deletions

24
binbox
View file

@ -1,10 +1,10 @@
#!/bin/bash #!/bin/sh
# binbox: Creates a multi-binary script that self-contains the input scripts. # 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 # Symlinking to the resulting binary with the name of one of the original scripts will trigger
# said script. The idea is similar to `busybox`. # said script. The idea is similar to `busybox`.
DAISY_INTERNAL=1 DAISY_INTERNAL=1
. daisy.source . $(dirname $(realpath $0))/daisy.source
ARGS=$@ ARGS=$@
@ -135,15 +135,6 @@ for f in "${includes[@]}"; do
add "$(cat "$f")" add "$(cat "$f")"
done 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 # >>> Section 2: Modules
for f in "${inputs[@]}"; do for f in "${inputs[@]}"; do
@ -156,10 +147,17 @@ done
# >>> Section 3: Module selection # >>> Section 3: Module selection
add "SYMED=1" add "SYMED=1"
add "BINSELF=\$(basename \$0 | rev | cut -d "/" -f 1 | rev)" add "BINSELF=\$(basename \$0)"
add "BOXFILE=$(basename \"$output\")" add "BOXFILE=\"$output\""
add "if [[ \$BINSELF == \$BOXFILE ]]; then" add "if [[ \$BINSELF == \$BOXFILE ]]; then"
add " SYMED=0" 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 "fi"
add "if [[ \$SYMED -eq 0 ]]; then" add "if [[ \$SYMED -eq 0 ]]; then"

8
calm
View file

@ -1,5 +1,4 @@
#!/bin/bash #!/bin/sh
#LACKSETUP
# Calm a process down # Calm a process down
# NEEDS_WORK: cleanup # NEEDS_WORK: cleanup
# calm <pid> == only one process # calm <pid> == only one process
@ -8,7 +7,12 @@
# calm <pid> <bin> .... OK # calm <pid> <bin> .... OK
# set's NICE value to 0 # set's NICE value to 0
# need sudo # need sudo
DAISY_INTERNAL=1
. $(dirname $(realpath $0))/daisy.source
PIDS=$@ PIDS=$@
errorFn() errorFn()
{ {
echo calm: Invalid operation or no such PID/process \(\"$(echo "$PIDS" | tr '\n' ' ' | cut -c -20)...\"\) echo calm: Invalid operation or no such PID/process \(\"$(echo "$PIDS" | tr '\n' ' ' | cut -c -20)...\"\)

7
cdz
View file

@ -1,8 +1,9 @@
#!/bin/bash #!/bin/sh
if [[ $DAISY_INTERNAL -ne 1 ]]; if [[ $DAISY_INTERNAL -ne 1 ]];
then then
DAISY_INTERNAL=1 source $DAISY_SOURCE_FILE export DAISY_INTERNAL=1
. $(dirname $(realpath $0))/daisy.source
fi fi
target=$1 target=$1
@ -63,7 +64,7 @@ if (( $hasmounter == 0 )); then
istar=1 istar=1
iszip=1 iszip=1
israr=1 israr=1
fi fi
# Now we set the right command # Now we set the right command
if (( $istar == 0 )); then if (( $istar == 0 )); then

1068
daisy Executable file

File diff suppressed because it is too large Load diff

View file

@ -11,7 +11,10 @@
# only included if sourced from one of the included scripts, though you are # 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. # 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 # Intro function
function daisy_help() function daisy_help()

5
editx
View file

@ -1,7 +1,10 @@
# !/bin/bash # !/bin/sh
# This utility pre-allocs a file and adds execution permissions. It also # This utility pre-allocs a file and adds execution permissions. It also
# removes the resulting file if it is empty after the editor closes. # removes the resulting file if it is empty after the editor closes.
DAISY_INTERNAL=1
. $(dirname $(realpath $0))/daisy.source
if [[ -z $1 ]]; if [[ -z $1 ]];
then then
echo "No filename specified." echo "No filename specified."

View file

@ -1,5 +1,9 @@
#!/bin/bash #!/bin/sh
# A simple utility that waits for a file to become available, infinitely # A simple utility that waits for a file to become available, infinitely
DAISY_INTERNAL=1
. $(dirname $(realpath $0))/daisy.source
FILE=$@ FILE=$@
while [ ! -f "$FILE" ] while [ ! -f "$FILE" ]
do do

5
newday
View file

@ -14,6 +14,9 @@
# You can use this for a primitive form of note-taking, but aside from notes - # You can use this for a primitive form of note-taking, but aside from notes -
# you can store any data this way. # you can store any data this way.
DAISY_INTERNAL=1
. $(dirname $(realpath $0))/daisy.source
BINSELF=$(basename $0) BINSELF=$(basename $0)
DIR_NAME=ByDate DIR_NAME=ByDate
ROOT_DIR=$HOME/$DIR_NAME ROOT_DIR=$HOME/$DIR_NAME
@ -49,4 +52,4 @@ test -L "$TODAY_SYM" && rm -rf "$TODAY_SYM"
mkdir -p "$ROOT_DIR/$YEAR/$MONTH/$DAY" mkdir -p "$ROOT_DIR/$YEAR/$MONTH/$DAY"
cd $ROOT_DIR cd $ROOT_DIR
ln -s "./$DIR_NAME/$YEAR/$MONTH/$DAY" "$TODAY_SYM" ln -s "./$DIR_NAME/$YEAR/$MONTH/$DAY" "$TODAY_SYM"
exitcode=@?

15
own
View file

@ -1,4 +1,17 @@
#!/bin/sh #!/bin/sh
# Simple program that changes ownership to the current # Simple program that changes ownership to the current
# user, recursively. # 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
View file

@ -1,11 +1,11 @@
#!/bin/bash #!/bin/sh
# short: Creates shortcuts that can be used anywhere. # short: Creates shortcuts that can be used anywhere.
# Can also be used as an alternative for "alias". # Can also be used as an alternative for "alias".
# #
# Example usage: # Example usage:
# Add a shortcut: short -A dev "/home/john/Development" # Add a shortcut: short -A dev "/home/john/Development"
# Print shortcut content: short dev -> "/home/john/Development" # Print shortcut content: short dev -> "/home/john/Development"
# Remove shortcut: short -D dev # Remove shortcut: short -D dev
# #
# One could use this to do things like: # One could use this to do things like:
# cp -R files $(short dev) # cp -R files $(short dev)
@ -14,6 +14,9 @@
# #
# Uses a file named .shortcuts in $HOME # 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
View file

@ -25,7 +25,7 @@ else
RC_NAME="."$BASENAME"rc" RC_NAME="."$BASENAME"rc"
RC_PATH="$HOME/$RC_NAME" RC_PATH="$HOME/$RC_NAME"
# Optional MD5 checks # Optional MD5 checks
HAS_CHANGED=1 HAS_CHANGED=1
SUM1=$(md5_opt "$RC_PATH") SUM1=$(md5_opt "$RC_PATH")
SUM2= SUM2=

15
sw
View file

@ -1,6 +1,9 @@
#!/bin/sh #!/bin/sh
# It just swaps two files # It just swaps two files
export DAISY_INTERNAL=1
. $(dirname $(realpath $0))/daisy.source
FILE1=$1 FILE1=$1
FILE2=$2 FILE2=$2
@ -9,17 +12,21 @@ function helpFn()
ERROR=$? ERROR=$?
if [[ $ERROR -gt 0 ]]; if [[ $ERROR -gt 0 ]];
then then
echo "$BINSELF error ($ERROR): " ERROR_TEXT=$(perl -E 'say $!=shift' $ERROR)
perl -E 'say $!=shift' $ERROR echo "$DAISY_BIN error ($ERROR): $ERROR_TEXT"
fi fi
echo "Usage: $BINSELF <file1> <file2>" echo "Usage: $DAISY_BIN <file1> <file2>"
echo Swap two files in a filesystem. echo Swap two files in a filesystem.
exit $ERROR exit $ERROR
} }
if [[ $@ == *"--help"* ]]; if [[ $@ == *"--help"* ]];
then then
helpFn helpFn
elif [[ $@ == '' ]];
then
echo "No arguments specified."
helpFn
fi fi
# We set a trap here, together with 'set -e' above, # We set a trap here, together with 'set -e' above,

3
what
View file

@ -23,6 +23,9 @@
# /usr/sbin/vsftpd # /usr/sbin/vsftpd
# #
DAISY_INTERNAL=1
. $(dirname $(realpath $0))/daisy.source
PWD=/ PWD=/
ALL_BINS=$(cd / && echo $PATH | sed 's/[:]/ /g' | xargs ls -A | grep -v ":" | sort | uniq) 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") OUTPUT=$(printf '%s\n' "-n" $ALL_BINS | grep -i "$1")