- 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.
|
# 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
8
calm
|
|
@ -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)...\"\)
|
||||||
|
|
|
||||||
5
cdz
5
cdz
|
|
@ -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
|
||||||
|
|
|
||||||
|
|
@ -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
5
editx
|
|
@ -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."
|
||||||
|
|
|
||||||
6
filewait
6
filewait
|
|
@ -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
5
newday
|
|
@ -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
15
own
|
|
@ -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) $@
|
||||||
|
|
|
||||||
7
short
7
short
|
|
@ -1,4 +1,4 @@
|
||||||
#!/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".
|
||||||
#
|
#
|
||||||
|
|
@ -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"
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
13
sw
13
sw
|
|
@ -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,10 +12,10 @@ 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
|
||||||
}
|
}
|
||||||
|
|
@ -20,6 +23,10 @@ function helpFn()
|
||||||
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
3
what
|
|
@ -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")
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue