maple/maple

1231 lines
83 KiB
Bash
Executable File

#!/usr/bin/env bash
################################################################################################################# SOF
# echo -e '\033[0;34m'" .:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::. "
# echo -e '\033[0;34m'" /mMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMNd- "
# echo -e '\033[0;34m'"-MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMN."
# echo -e '\033[0;34m'"/MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM-"
# echo -e '\033[0;34m'"/MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMmNMMMMMMMMMMMmMMMMMMMMMMMMMMMMMMMMMMMMMMMMM-"
# echo -e '\033[0;34m'"/MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMh:NMMMMMMMMMMoyMMMMMMMMMMMMMMMMMMMMMMMMMMMM-"
# echo -e '\033[0;34m'"/MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMm -NMMMMMMMMMs.NMMMMMMMMMMMMMMMMMMMMMMMMMMM-"
# echo -e '\033[0;34m'"/MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMy -hmmmmmNNm- sMMMMMMMMMMMMMMMMMMMMMMMMMMM-"
# echo -e '\033[0;34m'"/MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMmdyo+:. ......... .NMMMymMMMMMMMMMMMMMMMMMMMMM-"
# echo -e '\033[0;34m'"/MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMmy+-.. -hNm-+MMMMMMMMMMMMMMMMMMMMM-"
# echo -e '\033[0;34m'"/MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMms:. ... /MMMMMMMMMMMMMMMMMMMMM-"
# echo -e '\033[0;34m'"/MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMh/. /MMMMMMMMMMMMMMMMMMMMM-"
# echo -e '\033[0;34m'"/MMMMMMMMMMMMMMMMMMMmMMMMMMMMMMMmhN:. /MMMMMMMMMMMMMMMMMMMMM-"
# echo -e '\033[0;34m'"/MMMMMMMMMMMMMMMMMMM+sNMMMMMMMMMN-h: .-+syyys/- -NMMMMMMMMMMMMMMMMMMMM-"
# echo -e '\033[0;34m'"/MMMMMMMMMMMMMMMMMMMs +NMMMMMMMhm--d. :. -sdNMMMMMNNmy. :ydMMMMMMMMMMMMMMMMMM-"
# echo -e '\033[0;34m'"/MMMMMMMMMMMMMMMMMMM+ :yhyyyhhso. os yhshNMMMMMMMh+:-:. :s- .NMMMMMMMMMMMMMMMMM-"
# echo -e '\033[0;34m'"/MMMMMMMMMMMMMMMMmho. . .yo.h:sMMMMMMMMMMNd+. -NNs- yMMMMMMMMMMMMMMMMM-"
# echo -e '\033[0;34m'"/MMMMMMMMMMMMMNh/. :++.-MMMMMMMMMMMMMm+. :ymds. -NMMMMMMMMMMMMMMMM-"
# echo -e '\033[0;34m'"/MMMMMMMMMMMmo- .MMMMMMMMMMMMMMMdo. ..-. yMMMMMMMMMMMMMMMM-"
# echo -e '\033[0;34m'"/MMMMMMMMMmo. .NMMMMMMMMMMMMMMMMNy/.. .mMMMMMMMMMMMMMMM-"
# echo -e '\033[0;34m'"/MMMMMMMNs. hMMMMMMMMMMMMMMMMMMMNho-. :NMMMMMMMMMMMMMM-"
# echo -e '\033[0;34m'"/MMMMMMm: ./syyyo- -hmNMMMMMMMMMMMMMMMMMMMMmho:.. /NMMMMMMMMMMMMM-"
# echo -e '\033[0;34m'"/MMMMMd. .smMMMNNNms. . .+MMMMMMMMMMMMMMMMMMMMMMMMNdy/ ..yMMMMMMMMMMMMM-"
# echo -e '\033[0;34m'"/MMMMd. /mMMMMMy/:--. so. .mMMMMMMMMMMMMMMMMMMMMMMMNdo--:+sdNMMMMMMMMMMMMMM-"
# echo -e '\033[0;34m'"/MMMN- /NMMMMMMMMdo. oMm+. /MMMMMMMMMMMMMMMMdNMMMMMMNNNMMmMMMMMMMMMMMMMMMMM-"
# echo -e '\033[0;34m'"/MMMo -NMMMMMMMMMMdso-. /hmm+ sMMMMMMMMMMMMMMMs-mMMMMMMMMMM:dMMMMMMMMMMMMMMMM-"
# echo -e '\033[0;34m'"/MMN. sMMMMMMMMMMMo .os/..... .dMMMMMMMMMMMMMMs -NMMMMMMMMM-:MMMMMMMMMMMMMMMM-"
# echo -e '\033[0;34m'"/MMd mMMMMMMMMMMM/ .:os+-. .dMMMMMMMMMMMNm. -soosyhdms .mMMMMMMMMMMMMMMM-"
# echo -e '\033[0;34m'"/MMs mMMMMMMMMMMM: .hNhs/.. .dMMMMNmhs+:-. +MMMNoMMMMMMMMMM-"
# echo -e '\033[0;34m'"/MMy hMMMMMMMMMMM: oMMMMMNdyo/. .mNh+-. +mNy.mMMMMMMMMM-"
# echo -e '\033[0;34m'"/MMd +MMMMMMMMMMM/ :MMMMMMMMNs...:ohh/. . mMMMMMMMMM-"
# echo -e '\033[0;34m'"/MMN. .mMMMMMMMMMMo .NMMMMMMNhhdNMMh: mMMMMMMMMM-"
# echo -e '\033[0;34m'"/MMM+ /MMMMMMMMMMh yMMMMMMMMMMMN+ .NMMMMMMMMM-"
# echo -e '\033[0;34m'"/MMMm. +MMMMMMMMMN. .NMMMMMMMMMN- :sdmNNNdy+. dMMMMMMMMM-"
# echo -e '\033[0;34m'"/MMMMo +MMMMMMMMM+ +MMMMMMMMM/ -dMMMMMMNmmNN/ .sdMMMMMMM-"
# echo -e '\033[0;34m'"/MMMMN: :mMMMMMMMm. oMMMMMMMh .mMMMMMMMms- .. /o. .mMMMMMM-"
# echo -e '\033[0;34m'"/MMMMMm. .yMMMMMMMo oMMMMMM/ sMMMMMMMMMMMh: :NNo. sMMMMMM-"
# echo -e '\033[0;34m'"/MMMMMMm. -hMMMMMN: /NMMMM. dMMMMMMMMMMMMMh- :hmNy. .NMMMMM-"
# echo -e '\033[0;34m'"/MMMMMMMm- -yNMMMm. .yMMM. dMMMMMMMMMMMMMMNh:. .... yMMMMM-"
# echo -e '\033[0;34m'"/MMMMMMMMN+ .+hNMd. :hM: dMMMMMMMMMMMMMMMMNmo- .NMMMM-"
# echo -e '\033[0;34m'"/MMMMMMMMMMh- ./ss. .:: sMMMMMMMMMMMMMMMMMMMNms/. /MMMM-"
# echo -e '\033[0;34m'"/MMMMMMMMMMMNo. . :MMMMMMMMMMMMMMMMMMMMMMMNdo:.. oMMM-"
# echo -e '\033[0;34m'"/MMMMMMMMMMMMMmo. .mMMMMMMMMMMMMMMMMMMMMMMMMMMNmh: .dMM-"
# echo -e '\033[0;34m'"/MMMMMMMMMMMMMMMNy:. +MMMMMMMMMMMMMMMMMMMMMMMMMMNh+::/+sdNMMM-"
# echo -e '\033[0;34m'"/MMMMMMMMMMMMMMMMMNdo- .dMMMMMMMMMMMMMMMMMMMMMMMMMNNNNNMMMMMMMM-"
# echo -e '\033[0;34m'"/MMMMMMMMMMMMMMMMMMMMNd+-. -NMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM-"
# echo -e '\033[0;34m'"-NMMMMMMMMMMMMMMMMMMMMMMNdo:. /NMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMd."
# echo -e '\033[0;34m'" -ymNNNNNNNNNNNNNNNNNNNNNNNNdo-. +NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNmy."
# echo -e '\033[0;34m'" ............................ .-................................"
# echo -e '\033[0;34m'" ...... ......... .............. .......... saiset ......\n"
#####################################################################################################################
i=`cat maple|grep -n MARKER|cut -f1 -d":"`;i=$(echo $i|xargs|cut -f2 -d" ");ii=`wc -l maple|cut -f1 -d" "`;
iii=$((ii-i));tail -n $iii $0>mpl;MD5=$(md5sum mpl|cut -f1 -d ' ');rm mpl;DM5="608d56969ec34b3a59dc1932fe87ef9b";
[ "$MD5" = "$DM5" ] || exit;
# MARKER ############################################################################################################
R="\x1b[5;31m";G="\x1b[5;32m";Y="\x1b[5;33m";B="\x1b[5;34m";M="\x1b[5;35m";C="\x1b[5;36m";W="\x1b[5;37m";
CMD=$1;
CMDARG=$2;
COMMANDS=(setup start stop cleanup );
DISCORD__SERVICING=-1
TELEGRAM_SERVICING=-1
MATRIX___SERVICING=-1
OPENAI___SERVICING=-1
YOUTUBE__SERVICING=-1
TWITTER__SERVICING=-1
PREREQUISITES_PROGS=(jq nc)
FOUND_PROGS=()
for p in ${PREREQUISITES_PROGS[@]}; do
which $p >> /dev/null 2>&1
if [ $? -eq 0 ]; then
echo -e "\033[0;32mlocated $p\033[0m"
else
FOUND_PROGS+=("$p")
fi
done
for p in ${FOUND_PROGS[@]}; do
MESSAGE="\033[0;91minstallation required\033[0;0m"
##################################################
[ "jq" == $p ] && echo -e "\033[0;31mmissing $p -\033[0;34m $MESSAGE"
[ "nc" == $p ] && echo -e "\033[0;31mmissing $p -\033[0;34m $MESSAGE"
done
[ 0 -ne "${#FOUND_PROGS[@]}" ] && echo -e "\n\033[0;33m[ PREREQUISITES CHECK - \033[0;33mFAILED \033[0;33m]\033[0m\n"
[ 0 -ne "${#FOUND_PROGS[@]}" ] && exit
echo -e "\033[0;33m\n[ PREREQUISITES CHECK - \033[0;34mPASSED \033[0;33m]\033[0m"
INIT=0;
[ -e storage/bot/status ] || (mkdir storage/bot/status)
STATUS_ID="storage/bot/status/status_id";
[ -f $STATUS_ID ] && INIT=1;
MEMORY="";
if [ -e preset ]; then
if [ -e preset/credentials ]; then
[ -e storage/user/credentials ] || (mkdir storage/user/credentials)
cp preset/credentials/* storage/user/credentials/
fi
fi
#####################################################################################################################
function rgb () {
R=$((RANDOM%256))
G=$((RANDOM%256))
B=$((RANDOM%256))
echo -e "\e[38;2;"$R";"$G";"$B"m"
}
#####################################################################################################################
function analyze () {
R="$(rgb)"
G="$(rgb)"
B="$(rgb)"
W="$(rgb)"
CYCLE=$((CYCLE+1))
echo -e "######################################################### SOF"
echo -e $W" stage: $CYCLE - ( CONTENT BELOW )"
echo -e $B"filename: $1"
echo -e $B"filesize: `cat $1|wc -c`"
echo -e $G" md5sum: `md5sum $1|cut -c-32`"
echo -e $G"fileinfo: `file $1`"
echo -e $R"`cat $1|hexdump -C`"|head -n 4
echo -e $R"`cat $1|hexdump -C`"|tail -n 4
echo -e $B"filename: $1"
echo -e $W"stage $CYCLE: ( CONTENT ABOVE )"
echo -e "EOF #########################################################"
}
#####################################################################################################################
function pin_ops () {
####################
# encrypts the pin #
####################
function encrypt_pin () {
echo "encrypting pin"
[ -e storage/user/config/maple.pin ] || (echo "storage/user/config/maple.pin not even here")
[ -e storage/user/config/maple.pin ] && (gpg -a --symmetric --cipher-algo AES256 storage/user/config/maple.pin);
}
#############################################################################################################
##############################
# generates a new sshkey ide #
##############################
function generate_pin () {
echo "generating pin"
PASSPHRASE=$(gpg --gen-random 2 48 | base64);
echo -e "$PASSPHRASE" > storage/user/config/maple.pin;
}
#############################################################################################################
########################################################################
# reverts sshkey identify passphrase from a php encrypted file storage #
########################################################################
function decrypt_pin () {
echo "decrypting pin"
PASSPHRASE=$(gpg -d -q storage/user/config/maple.pin.asc);
}
#############################################################################################################
# ENTRY POINT ENTRY POINT ENTRY POINT ENTRY POINT ENTRY POINT ENTRY POINT ENTRY POINT ENTRY POINT ENTRY #
# ENTRY POINT ENTRY POINT ENTRY POINT ENTRY POINT ENTRY POINT ENTRY POINT ENTRY POINT ENTRY POINT ENTRY #
# ENTRY POINT ENTRY POINT ENTRY POINT ENTRY POINT ENTRY POINT ENTRY POINT ENTRY POINT ENTRY POINT ENTRY #
#############################################################################################################
export GPG_TTY=$(tty)
[ -e storage/user/config ] || (mkdir -p storage/user/config)
[ -e storage/user/status ] || (mkdir storage/user/status)
echo "offline" > storage/user/status/status_id
#############################################################################################################
##############################################################################
# check if an encrypted file exists that stores our ssh identity passphrase, #
# if not- create a new identity passphrase and then encrypt it into a file. #
##############################################################################
if [ -e storage/user/config/maple.pin.asc ]; then
echo "storage/user/config/maple.pin.asc found"
if [ -e storage/user/config/maple.pin ]; then
echo "storage/user/config/maple.pin found"
else
echo "storage/user/config/maple.pin not found"
fi; #[ -e storage/user/config/maple.pin ]
else
echo "storage/user/config/maple.pin.asc not found"
(generate_pin);
fi; #[ -e storage/user/config/maple.pin.asc ];
#############################################################################################################
###################################################
# check if ssh agent is running, if not, start it #
###################################################
ssh-add > /dev/null 2>&1; [ $? -eq 2 ] && eval $(ssh-agent -s);
#############################################################################################################
############################################################
# ssh running, create and/or add our identity to the agent #
############################################################
ssh-add > /dev/null 2>&1;
#########################
if [ $? -eq 1 ]; then
####################
IDENTITY="maplenet";
####################
#################################
# check if identify files exist #
#################################
if [ -e "storage/user/config/"$IDENTITY".pub" ]; then
echo "storage/user/config/"$IDENTITY".pub found"
if [ -e "storage/user/config/"$IDENTITY ]; then
export FLAG_IDENTITY=1;
echo "storage/user/config/"$IDENTITY" found"
echo "storage/user/config/"$IDENTITY" not found"
fi; #[ -e storage/user/config/maplenet ]
else
export FLAG_IDENTITY=0;
echo "storage/user/config/"$IDENTITY" not found"
fi; #[ -e storage/user/config/maplenet.pub ]
##############################
# generate new identify file #
##############################
if [ $FLAG_IDENTITY -eq 0 ]; then
(generate_pin);
(echo -e "PASSPHRASE: $PASSPHRASE");
ssh-keygen -t rsa -m pem -b 4096 -f storage/user/config/"$IDENTITY" -N "$PASSPHRASE"
else
(decrypt_pin);
fi; #[ $FLAG_IDENTIFY -eq 0 ]
########################################################################
# add identify file to the ssh-agent including the identity passphrase #
########################################################################
echo "$PASSPHRASE" | openssl rsa -in storage/user/config/"$IDENTITY" -passin stdin | ssh-add -
[ -e storage/user/config/maple.pin.asc ] || (encrypt_pin);
[ -e storage/user/config/maple.pin.asc ] && echo "pin encrypted"
[ -e storage/user/config/maple.pin ] && (rm storage/user/config/maple.pin)
fi; #[ $? -eq 1 ]
}
#####################################################################################################################
kset() {
if [[ -z $1 ]] || [[ -z $2 ]]; then echo "error: no variable or value to kset()"; exit; fi
echo "$1 = $2" >> $CONFIG
}
#####################################################################################################################
kwrite() {
if [[ -z $1 ]]; then echo "error: no value to kwrite()"; exit; fi
echo "$1" >> $CONFIG
}
#####################################################################################################################
kblank() {
echo "" >> $CONFIG
}
#####################################################################################################################
kmodesetup() {
HYDRA=$1; MODE=$2; FAILED=0; echo -e "[ running $HYDRA ]";
if [ ! -e env ]; then
echo -e "[ setting up $HYDRA ]";
which python3 > /dev/null 2>&1
if [ $? -eq 1 ]; then echo "python3 not installed, install like pacman -Sy python3, apt install python3, brew install python3"; FAILED=1; fi
python3 -m pip > /dev/null 2>&1
if [ $? -eq 1 ]; then echo "python3 pip module not installed, attempting to auto-install"; wget https://bootstrap.pypa.io/get-pip.py; python3 get-pip.py; fi
python3 -m pip > /dev/null 2>&1
if [ $? -eq 1 ]; then echo "python3 pip module still not installed, manually install python3 pip module before proceeding"; FAILED=1; fi
which virtualenv > /dev/null 2>&1
if [ $? -eq 1 ]; then echo "python3 virtualenv module not installed, attempting to auto-install"; python3 -m pip install virtualenv; fi
which virtualenv > /dev/null 2>&1
if [ $? -eq 1 ]; then echo "python3 virtualenv module still not installed, manually instlal python3 virtualenv module before proceeding"; FAILED=1; fi
if [ $FAILED -eq 1 ]; then echo "pre-requisites not met, aborting installation"; exit 1; fi
which python3.9 > /dev/null 2>&1
if [ $? -eq 0 ]; then virtualenv -p python3.9 env; else virtualenv -p python3 env; fi
source env/bin/activate
pip install --upgrade pip
[ "$MODE" = "0" ] && ( cp storage/bot/variants/dupe/bot_maple__services.py ./bot_maple.py; pip install -r storage/bot/requirements/requirements_services.txt )
if [ "$MODE" = "0" ]
then
cmd_services
cat activation >> env/bin/activate
fi
[ "$MODE" = "1" ] && (cp storage/bot/variants/core/maple.ini bot_maple.ini;pip install -r storage/bot/requirements/requirements_core.txt)
[ "$MODE" = "2" ] && (cp storage/bot/variants/dupe/bot_maple__services.py bot_maple.py;pip install -r storage/bot/requirements/requirements_services.txt)
[ "$MODE" = "3" ] && (cp storage/bot/variants/dupe/bot_maple__devops.py bot_maple.py;pip install -r storage/bot/requirements/requirements_devops.txt)
echo -e "\n[ $HYDRA setup complete ]"
deactivate
echo -e "[ setting up $HYDRA activation ]"
if [ "$MODE" = "1" ] || [ "$MODE" = "2" ] || [ "$MODE" = "3" ]; then
echo -e "[ fetching $HYDRA credentials ]"
cmd_hydra_undak
if [ ! $? -eq 13 ]; then
cp data_dack/hydra.key storage/user/config/
cp data_dack/maplenet.pub storage/user/config/
cp data_dack/maple.pin.asc storage/user/config/
[ "$MODE" = "1" ] && ( cat data_dack/activate__hydra_core__standalone >> env/bin/activate )
[ "$MODE" = "2" ] && ( cat data_dack/activate__hydra_dupe__services >> env/bin/activate )
[ "$MODE" = "3" ] && ( cat data_dack/activate__hydra_dupe__devops >> env/bin/activate )
rm -Rf {data_dack,data_aes}
else
echo "TOKEN WAS OMITTED, UNDAK OF CREDENTIALS NOT POSSIBLE - APPEND CREDENTIALS TO ENV/BIN/ACTIVATE - SEE BOTTOM OF README.MD FOR HELP WITH ENVIRONMENTAL VARIABLE EXPORTS"
[ "$MODE" = "1" ] && ( cat storage/user/credentials/activate__hydra_core__standalone >> env/bin/activate )
[ "$MODE" = "2" ] && ( cat storage/user/credentials/activate__hydra_dupe__services >> env/bin/activate )
[ "$MODE" = "3" ] && ( cat storage/user/credentials/activate__hydra_dupe__devops >> env/bin/activate )
fi
fi
echo -e "[ leaving setup and running $HYDRA ]"
fi; #[ ! -e env ]
#############################################################################################################
}
#####################################################################################################################
kmode () {
MODE=$1
echo "entered kmode"
if [ "$MODE" = "0" ]; then
HYDRA="default"
elif [ "$MODE" = "1" ]; then
HYDRA="hydra_core__standalone"
elif [ "$MODE" = "2" ]; then
HYDRA="hydra_dupe__services"
elif [ "$MODE" = "3" ]; then
HYDRA="hydra_dupe__devops"
fi; #[ "$MODE" = "0" ]
[ -e storage/bot/status ] || (mkdir storage/bot/status)
echo "$HYDRA" > storage/bot/status/status_id
kmodesetup "$HYDRA" "$MODE"
}
#####################################################################################################################
kprompt() {
if [[ -z $1 ]] || [[ -z $2 ]] || [[ -z $3 ]] || [[ -z $4 ]] || [[ -z $5 ]] || [[ -z $6 ]]; then echo "error: no variable, prompt, help, enforcement, type or memory passed to kprompt()"; exit; fi
local INIVAR=$1; local PROMPT=$2; local DIALOG=$3; local ENFORCE=$4; local TYPE=$5; local MEMORIZE=$6; unset REPLY;
while [[ -z "${REPLY}" ]] || [[ $ENFORCE -eq 1 ]]; do
if [ $TYPE -eq 1 ]; then
echo -e "$DIALOG"; echo -en "$PROMPT"; [ $ENFORCE -eq 0 ] && echo -n ": " || echo -n "[1/2]: "
elif [ $TYPE -eq 2 ]; then
echo -e "$DIALOG"; echo -en "$PROMPT"; [ $ENFORCE -eq 0 ] && echo -n ": " || echo -n "[1/2/3]: "
elif [ $TYPE -eq 3 ]; then
echo -e "$DIALOG"; echo -en "$PROMPT"; [ $ENFORCE -eq 0 ] && echo -n ": " || echo -n ": "
else
echo -en "$PROMPT"; [ $ENFORCE -eq 0 ] && echo -n ": " || echo -n "[y/n]: "
fi;
read;
if [[ $ENFORCE -eq 1 ]] && [[ $TYPE -eq 0 ]]; then
while ! [[ -z $ENFORCE ]]; do
if ([ ${REPLY} == "y" ] || [ ${REPLY} == "Y" ]); then
return 0
elif ([ ${REPLY} == "n" ] || [ ${REPLY} == "N" ]); then
return 9
else
echo -en "$PROMPT"; [ $ENFORCE -eq 0 ] && echo -n ": " || echo -n "[y/n]: "
read;
fi;
done;
elif [[ $ENFORCE -eq 1 ]] && [[ $TYPE -eq 1 ]]; then
while ! [[ -z $ENFORCE ]]; do
if ([ "${REPLY}" = "1" ]); then
return 1
elif ([ "${REPLY}" = "2" ]); then
return 2
else
echo -en "$PROMPT"; [ $ENFORCE -eq 0 ] && echo -n ": " || echo -n "[1/2]: "
read;
fi;
done;
elif [[ $ENFORCE -eq 1 ]] && [[ $TYPE -eq 2 ]]; then
while ! [[ -z $ENFORCE ]]; do
if ([ "${REPLY}" = "1" ]); then
return 1
elif ([ "${REPLY}" = "2" ]); then
return 2
elif ([ "${REPLY}" = "3" ]); then
return 3
else
echo -en "$PROMPT"; [ $ENFORCE -eq 0 ] && echo -n ": " || echo -n "[1/2/3]: "
read;
fi;
done;
elif [[ $ENFORCE -eq 1 ]] && [[ $TYPE -eq 3 ]]; then
while ! [[ -z $ENFORCE ]]; do
if ([ ! "${REPLY}" = "" ]); then
REPLY="$REPLY"
return 0
else
echo -en "$PROMPT"; [ $ENFORCE -eq 0 ] && echo -n ": " || echo -n ": "
read;
fi
done;
elif [[ $TYPE -eq 1 ]]; then
while true; do
[[ ${REPLY} =~ ^-?[0-9]+$ ]]
if ! [ $? -eq 0 ]; then
echo -en "$PROMPT"; [ $ENFORCE -eq 0 ] && echo -n ": " || echo -n "[y/n]: "
read;
else
return ${REPLY}
fi
done;
fi;
done;
if [ $MEMORIZE -eq 1 ]; then
echo "MEMORIZE"
MEMORY=${REPLY}
fi;
[ $TYPE -eq 1 ] && return ${REPLY} || kset "$INIVAR" "${REPLY}"
return 0;
}
#####################################################################################################################
cmd_hydra_dak () {
##########################################################################
[ -e data_dack ] && ( rm -Rf data_dack )
##########################################################################
mkdir data_dack
cp storage/user/config/hydra.key data_dack
cp storage/user/config/maplenet.pub data_dack
cp storage/user/config/maple.pin.asc data_dack
[ -e storage/user/credentials ] || (mkdir storage/user/credentials)
cp storage/user/credentials/activate__hydra_core__standalone data_dack
cp storage/user/credentials/activate__hydra_dupe__services data_dack
cp storage/user/credentials/activate__hydra_dupe__devops data_dack
##########################################################################
DAK=data_dack
###################################################################################################################################################
# STAGE 1 STAGE 1 STAGE 1 STAGE 1 STAGE 1 STAGE 1 STAGE 1 STAGE 1 STAGE 1 STAGE 1 STAGE 1 STAGE 1 STAGE 1 STAGE 1 STAGE 1 STAGE 1 STAGE 1 STAGE 1 #
###################################################################################################################################################
FDIR=$(basename "$DAK"); FNAME="data_dak"; CYCLE=0;
##########################################################################
echo -e $C"[ dacking archive ]"$B
##########################################################################
tar cvfz $FNAME.tgz $FDIR
analyze $FNAME.tgz
###################################################################################################################################################
# STAGE 2 STAGE 2 STAGE 2 STAGE 2 STAGE 2 STAGE 2 STAGE 2 STAGE 2 STAGE 2 STAGE 2 STAGE 2 STAGE 2 STAGE 2 STAGE 2 STAGE 2 STAGE 2 STAGE 2 STAGE 2 #
###################################################################################################################################################
cat $FNAME.tgz|base64 > $FNAME.tgz.b64
analyze $FNAME.tgz.b64
###################################################################################################################################################
# STAGE 3 STAGE 3 STAGE 3 STAGE 3 STAGE 3 STAGE 3 STAGE 3 STAGE 3 STAGE 3 STAGE 3 STAGE 3 STAGE 3 STAGE 3 STAGE 3 STAGE 3 STAGE 3 STAGE 3 STAGE 3 #
###################################################################################################################################################
dd bs=128 count=3 if=/dev/random of=random > /dev/null 2>&1
cat random|base64 > b64
dd bs=77 count=2 if=b64 of=trash > /dev/null 2>&1
cat $FNAME.tgz.b64 >> trash
mv trash $FNAME.tgz.b64.d
analyze $FNAME.tgz.b64.d
rm random && rm *b64 && rm $FNAME.tgz
###################################################################################################################################################
# STAGE 4 STAGE 4 STAGE 4 STAGE 4 STAGE 4 STAGE 4 STAGE 4 STAGE 4 STAGE 4 STAGE 4 STAGE 4 STAGE 4 STAGE 4 STAGE 4 STAGE 4 STAGE 4 STAGE 4 STAGE 4 #
###################################################################################################################################################
FPASS=$(sha256sum $FNAME.tgz.b64.d|cut -c1-64)
zip $FNAME.zip $FNAME.tgz.b64.d -r9 -P $FPASS
analyze $FNAME.zip
rm -Rf $FDIR && rm $FNAME.tgz.b64.d
###################################################################################################################################################
# STAGE 5 STAGE 5 STAGE 5 STAGE 5 STAGE 5 STAGE 5 STAGE 5 STAGE 5 STAGE 5 STAGE 5 STAGE 5 STAGE 5 STAGE 5 STAGE 5 STAGE 5 STAGE 5 STAGE 5 STAGE 5 #
###################################################################################################################################################
PASSWORD=$(gpg --gen-random 2 1024|base64)
echo $PASSWORD|tr -d ' ' > dr1p_aes1
openssl enc -aes-256-cbc -pbkdf2 -iter 20000 -in "$FNAME.zip" -out "$FNAME.aes" -pass file:"dr1p_aes1"
analyze $FNAME.aes
###################################################################################################################################################
# STAGE 6 STAGE 6 STAGE 6 STAGE 6 STAGE 6 STAGE 6 STAGE 6 STAGE 6 STAGE 6 STAGE 6 STAGE 6 STAGE 6 STAGE 6 STAGE 6 STAGE 6 STAGE 6 STAGE 6 STAGE 6 #
###################################################################################################################################################
base64 < "$FNAME.aes" > "$FNAME.dak" && rm "$FNAME.aes" && rm "$FNAME.zip"
analyze $FNAME.dak
##########################################################################
echo -e "[ crypto password ]\n$PASSWORD\n[ archive password ]\n$FPASS\n[ archive filename ]\n$FNAME.zip\n[ archive contents ]" > $FNAME.passwords
echo -e $C"[ crypto password ]\n$B$PASSWORD\n"$C"[ archive password ]\n$B$FPASS\n"$C"[ archive filename ]\n$B$FNAME.zip\n"$C"[ archive contents ]"
echo $PASSWORD|tr -d ' ' > dr1p_aes2
echo $FPASS > dr1p_zip
cat $FNAME.passwords > data_dack_dak
cat $FNAME.dak >> data_dack_dak
################################################################################################################################################### data_dack_dat is a staged encryption
# STAGE 7 STAGE 7 STAGE 7 STAGE 7 STAGE 7 STAGE 7 STAGE 7 STAGE 7 STAGE 7 STAGE 7 STAGE 7 STAGE 7 STAGE 7 STAGE 7 STAGE 7 STAGE 7 STAGE 7 STAGE 7 # while some of it is already ciphered
################################################################################################################################################### & packed, some top layers are not yet
export GPG_TTY=$(tty)
PASSPHRASE=$(gpg -d -q storage/user/config/maple.pin.asc);
gpg -a --symmetric --cipher-algo AES256 data_dack_dak
################################################################################################################################################### dak_tcp is the fully ciphered up form
# STAGE 8 STAGE 8 STAGE 8 STAGE 8 STAGE 8 STAGE 8 STAGE 8 STAGE 8 STAGE 8 STAGE 8 STAGE 8 STAGE 8 STAGE 8 STAGE 8 STAGE 8 STAGE 8 STAGE 8 STAGE 8 # that is ready to bounce around the
################################################################################################################################################### internet
openssl enc -aes-256-cbc -pbkdf2 -iter 20000 -in "data_dack_dak.asc" -out "data_dack_aes" -k $PASSPHRASE
base64 < "data_dack_aes" > "dak_tcp" && rm {dr1p_,data_}*
analyze dak_tcp
echo -e $B".[d]. xmit dakd .[d]."
cat storage/user/config/maple.pin.asc > dak_tcp.tmp
cat dak_tcp >> dak_tcp.tmp
analyze dak_tcp.tmp
mv dak_tcp.tmp dak_tcp
[ -e storage/user/logs ] || (mkdir storage/user/logs)
TCPAC=$(cat dak_tcp|nc tcp.ac 9999|jq -r '.txt,.del'|xargs) > /dev/null 2>&1;
if [ ! -z "$TCPAC" ]; then
echo $TCPAC>storage/user/logs/tcpac.log
TXT=$(echo $TCPAC|cut -f 1 -d ' '); DEL=$(echo $TCPAC|cut -f 2 -d ' ');
echo -e "\n*** WRITE DOWN THIS TOKEN ***"
[ -e storage/user/logs ] || (mkdir storage/user/logs)
basename "$TXT">storage/user/logs/token.log
TOKEN=$(cat storage/user/logs/token.log)
echo -e "TOKEN: $TOKEN"
echo -e "*** WRITE DOWN THIS TOKEN ***"
else
echo -e "TCP.AC SERVICE OUTAGE // YOU WILL HAVE TO MOVE CREDENTIALS MANUALLY"
fi
}
#####################################################################################################################
cmd_hydra_undak () {
if [ -z "$TOKEN" ]; then
echo -ne "\nwhat is the token?: "
read token
else
token=$TOKEN
fi
if [ "$TOKEN"="" ]; then
echo -e "TOKEN OMITTED - BYPASSING CREDENTIAL AUTOMATION - YOU WILL HAVE TO SETUP CREDENTIALS MANUALLY"
return 13;
fi
curl -L "https://tcp.ac/t/$token" --output dak_tcp
mkdir -p storage/user/config
cp storage/user/scripts/unkey.py .
python3 unkey.py
###################################################################################################################################################
# STAGE 9 STAGE 9 STAGE 9 STAGE 9 STAGE 9 STAGE 9 STAGE 9 STAGE 9 STAGE 9 STAGE 9 STAGE 9 STAGE 9 STAGE 9 STAGE 9 STAGE 9 STAGE 9 STAGE 9 STAGE 9 #
###################################################################################################################################################
echo -e '\x1b[5;36m[ reached cmd_hydra_undak ]'
export GPG_TTY=$(tty)
PASSPHRASE=$(gpg -d -q storage/user/config/maple.pin.asc);
base64 -d < dak_tcp > data_dack_aes
analyze data_dack_aes
openssl enc -d -aes-256-cbc -pbkdf2 -iter 20000 -in "data_dack_aes" -out "data_dack_dak.asc" -k $PASSPHRASE
analyze data_dack_dak.asc
###################################################################################################################################################
# STAGE A STAGE A STAGE A STAGE A STAGE A STAGE A STAGE A STAGE A STAGE A STAGE A STAGE A STAGE A STAGE A STAGE A STAGE A STAGE A STAGE A STAGE A #
###################################################################################################################################################
export GPG_TTY=$(tty)
PASSPHRASE=$(gpg -o data_tcp -d -q data_dack_dak.asc)
analyze data_dack_dak.asc
cp storage/user/scripts/undak.py . && python3 undak.py
###################################################################################################################################################
# STAGE B STAGE B STAGE B STAGE B STAGE B STAGE B STAGE B STAGE B STAGE B STAGE B STAGE B STAGE B STAGE B STAGE B STAGE B STAGE B STAGE B STAGE B #
###################################################################################################################################################
base64 -d < data_tcp_deconcatenated > data_aes
openssl enc -d -aes-256-cbc -pbkdf2 -iter 20000 -in "data_aes" -out "data_dak" -pass file:"dr1p_aes2"
FNAME="data_dak"
FPASS=$(cat dr1p_zip)
unzip -P $FPASS $FNAME && FNAMELESS=$(echo "$FNAME" | cut -f 1 -d '.')
###################################################################################################################################################
# STAGE C STAGE C STAGE C STAGE C STAGE C STAGE C STAGE C STAGE C STAGE C STAGE C STAGE C STAGE C STAGE C STAGE C STAGE C STAGE C STAGE C STAGE C #
###################################################################################################################################################
if [ $? -ne 0 ]; then echo "not ok: $?"; echo "error: problem undacking"; exit 666; fi
dd skip=77 bs=2 if=$FNAMELESS.tgz.b64.d of=$FNAMELESS.tgz.b64 #> /dev/null 2>&1
if [ $? -ne 0 ]; then echo "not ok: $?"; echo "error: problem undacking"; exit 666; fi
cat $FNAMELESS.tgz.b64|base64 -d > $FNAMELESS.tgz
if [ $? -ne 0 ]; then echo "not ok: $?"; echo "error: problem undacking"; exit 666; fi
tar zxvf $FNAMELESS.tgz
if [ $? -ne 0 ]; then echo "not ok: $?"; echo "error: problem undacking"; exit 666; fi
echo ".[d]. undacked .[d]."
rm *.tgz.b64.d && rm *.tgz.b64 && rm $FNAMELESS.tgz; rm data_dack_aes; rm data_dack_dak.asc; rm data_dak; rm data_tcp; rm data_tcp_deconcatenated;
rm dr1p_*; rm dak_*; rm undak.py; rm unkey.py;
}
#####################################################################################################################
cmd_hydra () {
L="\x1b[0;94m"; D="\x1b[0;34m"; G="\x1b[0;90m"
export GPG_TTY=$(tty)
if [ ! -e storage/user/config/hydra.key ]; then
echo -e "\ngenerating hydra keyset"
HYDRAKEY=$(gpg --gen-random 2 4096 | base64);
[ -e storage/user/config ] || (mkdir storage/user/config)
echo -e "$HYDRAKEY" > storage/user/config/hydra.key
fi;
if [ ! -e storage/user/config/maplenet.pub ]; then
pin_ops;
fi;
kprompt "MODE" "$L""\nneed an online credential pak? " "credential pak" 1 0 0; RESULT=$?
if [ $RESULT = "0" ]; then
cmd_hydra_dak;
fi;
}
#####################################################################################################################
cmd_default () {
(kmode 0);
}
#####################################################################################################################
cmd_services_hydra () {
L="\x1b[0;94m"; D="\x1b[0;34m"; G="\x1b[0;90m"
echo -e "\n"$G"[ "$L"setting up services "$G"]\n"
[ -e storage/user/credentials ] || (mkdir -p storage/user/credentials)
if [ -e storage/user/credentials/activate__hydra_core__standalone ]; then
echo -e "storage/user/credentials/activate__hydra_core__standalone exists"
if [ -e storage/user/credentials/activate__hydra_dupe__services ]; then
echo -e "storage/user/credentials/activate__hydra_dupe__services exists"
if [ -e storage/user/credentials/activate__hydra_dupe__devops ]; then
echo -e "storage/user/credentials/activate__hydra_dupe__devops exists"
return
fi
fi
fi
kprompt "MODE" "hydra irc homechannel" "[ hyrdra irc homechannel ] example: #b0ts3x" 1 3 0; RESULT=$?
echo -e "export HYDRA_DESIGNATION=core" >> storage/user/credentials/activate__hydra_core__standalone
echo -e "export HYDRA_DESIGNATION=dupe" >> storage/user/credentials/activate__hydra_dupe__services
echo -e "export HYDRA_DESIGNATION=dupe" >> storage/user/credentials/activate__hydra_dupe__devops
echo -e "export HYDRA_HOME=$REPLY" >> storage/user/credentials/activate__hydra_core__standalone
echo -e "export HYDRA_HOME=$REPLY" >> storage/user/credentials/activate__hydra_dupe__services
echo -e "export HYDRA_HOME=$REPLY" >> storage/user/credentials/activate__hydra_dupe__devops
echo -e 'export HYDRA_PURPOSE="core - keep uptime and designate tasks"' >> storage/user/credentials/activate__hydra_core__standalone
echo -e 'export HYDRA_PURPOSE="services - runs the ai"' >> storage/user/credentials/activate__hydra_dupe__services
echo -e 'export HYDRA_PURPOSE="devops - doing development"' >> storage/user/credentials/activate__hydra_dupe__devops
kprompt "MODE" "nickserv username" "[ nickserv username ] example: username" 1 3 0; RESULT=$?
echo -e "export BOT_SASL_USERNAME=$REPLY" >> storage/user/credentials/activate__hydra_core__standalone
echo -e "export BOT_SASL_USERNAME=$REPLY" >> storage/user/credentials/activate__hydra_dupe__services
echo -e "export BOT_SASL_USERNAME=$REPLY" >> storage/user/credentials/activate__hydra_dupe__devops
echo -e "export NICKSERV_USERNAME=$REPLY" >> storage/user/credentials/activate__hydra_core__standalone
echo -e "export NICKSERV_USERNAME=$REPLY" >> storage/user/credentials/activate__hydra_dupe__services
echo -e "export NICKSERV_USERNAME=$REPLY" >> storage/user/credentials/activate__hydra_dupe__devops
kprompt "MODE" "nickserv password" "[ nickserv password ] example: password" 1 3 0; RESULT=$?
echo -e "export BOT_SASL_PASSWORD=$REPLY" >> storage/user/credentials/activate__hydra_core__standalone
echo -e "export BOT_SASL_PASSWORD=$REPLY" >> storage/user/credentials/activate__hydra_dupe__services
echo -e "export BOT_SASL_PASSWORD=$REPLY" >> storage/user/credentials/activate__hydra_dupe__devops
echo -e "export NICKSERV_PASSWORD=$REPLY" >> storage/user/credentials/activate__hydra_core__standalone
echo -e "export NICKSERV_PASSWORD=$REPLY" >> storage/user/credentials/activate__hydra_dupe__services
echo -e "export NICKSERV_PASSWORD=$REPLY" >> storage/user/credentials/activate__hydra_dupe__devops
kprompt "MODE" "will this bot use youtube services? " "youtube" 1 0 0; RESULT=$?
if [ $RESULT = "0" ]; then
kprompt "MODE" "developer_key" "[ youtube api key ] example: AIzaSyDmlgOry16XSTIVmm9au06YJDOmNrAZeRz" 1 3 0; RESULT=$?
echo -e "export YOUTUBE_DEVELOPER_KEY=$REPLY" >> storage/user/credentials/activate__hydra_dupe__services
YOUTUBE__SERVICING=1
else
YOUTUBE__SERVICING=0
fi
kprompt "MODE" "will this bot use twitter services? " "twitter" 1 0 0; RESULT=$?
if [ $RESULT = "0" ]; then
kprompt "MODE" "consumer_key" "[ twitter api key ] example: RMIn8DlEGhhJJBCRovD7RezZR" 1 3 0; RESULT=$?
echo -e "export TWITTER_CONSUMER_KEY=$REPLY" >> storage/user/credentials/activate__hydra_dupe__services
kprompt "MODE" "consumer_secret" "[ twitter api key ] example: Uc5X87M7kIah0mPucdQVFJZrPWvtIvmZPR9x2L4QPLpZdd3ZzD" 1 3 0; RESULT=$?
echo -e "export TWITTER_CONSUMER_SECRET=$REPLY" >> storage/user/credentials/activate__hydra_dupe__services
kprompt "MODE" "access_token_key" "[ twitter api key ] example: 1032240340353188844-yqnMN7ulbgsc4yWUYM0yxAbDdDeeeZ" 1 3 0; RESULT=$?
echo -e "export TWITTER_ACCESS_TOKEN_KEY=$REPLY" >> storage/user/credentials/activate__hydra_dupe__services
kprompt "MODE" "access_token_secret" "[ twitter api key ] example: UhlWXud7RTHRdSxdVQWgEBfC9GHmG5tcYos5lq3Zee77E" 1 3 0; RESULT=$?
echo -e "export TWITTER_ACCESS_TOKEN_SECRET=$REPLY" >> storage/user/credentials/activate__hydra_dupe__services
TWITTER__SERVICING=1
else
TWITTER__SERVICING=0
fi
kprompt "MODE" "will this bot use openai services? " "openai" 1 0 0; RESULT=$?
if [ $RESULT = "0" ]; then
kprompt "MODE" "openai_key" "[ openai api key ] example: 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" 1 3 0; RESULT=$?
echo -e "export OPENAI_KEY=$REPLY" >> storage/user/credentials/activate__hydra_dupe__services
OPENAI___SERVICING=1
else
OPENAI___SERVICING=0
fi
kprompt "MODE" "will this bot use matrix services? " "matrix" 1 0 0; RESULT=$?
if [ $RESULT = "0" ]; then
kprompt "MODE" "matrix homeserver" "[ matrix homeserver ] example: https://matrix.org" 1 3 0; RESULT=$?
echo -e "export MATRIX_HOMESERVER=$REPLY" >> storage/user/credentials/activate__hydra_dupe__services
kprompt "MODE" "matrix username" "[ matrix username ] example: whatever username you setup" 1 3 0; RESULT=$?
echo -e "export MATRIX___USERNAME=$REPLY" >> storage/user/credentials/activate__hydra_dupe__services
kprompt "MODE" "matrix password" "[ matrix password ] example: whatever password you setup for this username" 1 3 0; RESULT=$?
echo -e "export MATRIX___PASSWORD=$REPLY" >> storage/user/credentials/activate__hydra_dupe__services
MATRIX___SERVICING=1
else
MATRIX___SERVICING=0
fi
kprompt "MODE" "will this bot use discord services? " "discord" 1 0 0; RESULT=$?
if [ $RESULT = "0" ]; then
kprompt "MODE" "discord_token" "[ discord token ] example: OTAzOTU4NjQyNTIzNTI5MjM2.GXqwzj.Rnv8RudPRnv5jAeVu4dPnIl6TpSER7Eez5RZze" 1 3 0; RESULT=$?
echo -e "export DISCORD__TOKEN=$REPLY" >> storage/user/credentials/activate__hydra_dupe__services
kprompt "MODE" "channel_id" "[ channel_id ] example: 1009465637633929222" 1 3 0; RESULT=$?
echo -e "export DISCORD__SCHAN=$REPLY" >> storage/user/credentials/activate__hydra_dupe__services
DISCORD__SERVICING=1
else
DISCORD__SERVICING=0
fi
kprompt "MODE" "will this bot use telegram services? " "discord" 1 0 0; RESULT=$?
if [ $RESULT = "0" ]; then
kprompt "MODE" "telegram_token" "[ telegram token ] example: 5405833579:AAHvEUc1hms29JBoJDhoGBUE8Ept8dBrZr5" 1 3 0; RESULT=$?
echo -e "export TELEGRAM_TOKEN=$REPLY" >> storage/user/credentials/activate__hydra_dupe__services
TELEGRAM_SERVICING=1
else
TELEGRAM_SERVICING=0
fi
# [ -e storage/user/credentials/activate__hydra_dupe__services ] && ( cat storage/user/credentials/activate__hydra_dupe__services >> env/bin/activate )
}
#####################################################################################################################
cmd_services () {
[ -e activation ] && rm activation
kprompt "MODE" "will this bot use nickserv/sasl services? " "nickserv/sasl" 1 0 0; RESULT=$?
if [ $RESULT = "0" ]; then
kprompt "MODE" "nickserv username" "[ nickserv username ] example: username" 1 3 0; RESULT=$?
echo -e "export BOT_SASL_USERNAME=$REPLY" >> activation
echo -e "export NICKSERV_USERNAME=$REPLY" >> activation
kprompt "MODE" "nickserv password" "[ nickserv password ] example: password" 1 3 0; RESULT=$?
echo -e "export BOT_SASL_PASSWORD=$REPLY" >> activation
echo -e "export NICKSERV_PASSWORD=$REPLY" >> activation
fi
kprompt "MODE" "will this bot use youtube services? " "youtube" 1 0 0; RESULT=$?
if [ $RESULT = "0" ]; then
kprompt "MODE" "developer_key" "[ youtube api key ] example: AIzaSyDmlgOry16XSTIVmm9au06YJDOmNrAZeRz" 1 3 0; RESULT=$?
echo -e "export YOUTUBE_DEVELOPER_KEY=$REPLY" >> activation
fi
kprompt "MODE" "will this bot use twitter services? " "twitter" 1 0 0; RESULT=$?
if [ $RESULT = "0" ]; then
kprompt "MODE" "consumer_key" "[ twitter api key ] example: RMIn8DlEGhhJJBCRovD7RezZR" 1 3 0; RESULT=$?
echo -e "export TWITTER_CONSUMER_KEY=$REPLY" >> activation
kprompt "MODE" "consumer_secret" "[ twitter api key ] example: Uc5X87M7kIah0mPucdQVFJZrPWvtIvmZPR9x2L4QPLpZdd3ZzD" 1 3 0; RESULT=$?
echo -e "export TWITTER_CONSUMER_SECRET=$REPLY" >> activation
kprompt "MODE" "access_token_key" "[ twitter api key ] example: 1032240340353188844-yqnMN7ulbgsc4yWUYM0yxAbDdDeeeZ" 1 3 0; RESULT=$?
echo -e "export TWITTER_ACCESS_TOKEN_KEY=$REPLY" >> activation
kprompt "MODE" "access_token_secret" "[ twitter api key ] example: UhlWXud7RTHRdSxdVQWgEBfC9GHmG5tcYos5lq3Zee77E" 1 3 0; RESULT=$?
echo -e "export TWITTER_ACCESS_TOKEN_SECRET=$REPLY" >> activation
fi
kprompt "MODE" "will this bot use openai services? " "openai" 1 0 0; RESULT=$?
if [ $RESULT = "0" ]; then
kprompt "MODE" "openai_key" "[ openai api key ] example: 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" 1 3 0; RESULT=$?
echo -e "export OPENAI_KEY=$REPLY" >> activation
fi
kprompt "MODE" "will this bot use matrix services? " "matrix" 1 0 0; RESULT=$?
if [ $RESULT = "0" ]; then
kprompt "MODE" "matrix homeserver" "[ matrix homeserver ] example: https://matrix.org" 1 3 0; RESULT=$?
echo -e "export MATRIX_HOMESERVER=$REPLY" >> activation
kprompt "MODE" "matrix username" "[ matrix username ] example: whatever username you setup" 1 3 0; RESULT=$?
echo -e "export MATRIX___USERNAME=$REPLY" >> activation
kprompt "MODE" "matrix password" "[ matrix password ] example: whatever password you setup for this username" 1 3 0; RESULT=$?
echo -e "export MATRIX___PASSWORD=$REPLY" >> activation
fi
kprompt "MODE" "will this bot use discord services? " "discord" 1 0 0; RESULT=$?
if [ $RESULT = "0" ]; then
kprompt "MODE" "discord_token" "[ discord token ] example: OTAzOTU4NjQyNTIzNTI5MjM2.GXqwzj.Rnv8RudPRnv5jAeVu4dPnIl6TpSER7Eez5RZze" 1 3 0; RESULT=$?
echo -e "export DISCORD__TOKEN=$REPLY" >> activation
kprompt "MODE" "channel_id" "[ channel_id ] example: 1009465637633929222" 1 3 0; RESULT=$?
echo -e "export DISCORD__SCHAN=$REPLY" >> activation
fi
kprompt "MODE" "will this bot use telegram services? " "discord" 1 0 0; RESULT=$?
if [ $RESULT = "0" ]; then
kprompt "MODE" "telegram_token" "[ telegram token ] example: 5405833579:AAHvEUc1hms29JBoJDhoGBUE8Ept8dBrZr5" 1 3 0; RESULT=$?
echo -e "export TELEGRAM_TOKEN=$REPLY" >> activation
fi
# [ -e storage/user/credentials/activate__hydra_dupe__services ] && ( cat storage/user/credentials/activate__hydra_dupe__services >> env/bin/activate )
}
#####################################################################################################################
cmd_setup () {
#######################################################################
L="\x1b[0;94m"; D="\x1b[0;34m"; G="\x1b[0;90m"
if [ $INIT = 0 ]; then
kprompt "MODE" "which type? " "1"$G") "$L"NON-HYDRA\n"$B"2"$G") "$L"HYDRA\n" 1 1 0
RESULT=2 #$?
if [ $RESULT -eq 1 ]; then
(kmode 0);
if [ ! -e plugins ]; then
mkdir plugins
cat storage/bot/variants/default/bot_maple__default__initial_plugins.txt|grep -v "#"|grep -v irc3|sed s/plugins.//|xargs -I{} cp storage/bot/plugins/{}.py plugins/
# ideally i would simply use sed -i s/this/that/g file; however osx/unix and gnused are not exactly posix compliant(idc) specifically with (inplace) file updating, ppl getting gsed on osx vs using ased, ill skip past.
if [ $DISCORD__SERVICING -eq 0 ]; then
cat plugins/tool_bus_plugin.py|sed s/"???DISCORD???"/"SERVICES_DISCORD=False"/g > plugins/tool_bus_plugin.tmp;mv plugins/tool_bus_plugin.tmp plugins/tool_bus_plugin.py
cat plugins/cmd_irc_plugin.py|sed s/"???DISCORD???"/"SERVICES_DISCORD=False"/g > plugins/cmd_irc_plugin.tmp;mv plugins/cmd_irc_plugin.tmp plugins/cmd_irc_plugin.py
cat plugins/net_discord_plugin.py|sed s/"???DISCORD???"/"SERVICES_DISCORD=False"/g > plugins/net_discord_plugin.tmp;mv plugins/net_discord_plugin.tmp plugins/net_discord_plugin.py
cat plugins/tool_dims_plugin.py|sed s/"???DISCORD???"/"SERVICES_DISCORD=False"/g > plugins/tool_dims_plugin.tmp;mv plugins/tool_dims_plugin.tmp plugins/tool_dims_plugin.py
else
cat plugins/tool_bus_plugin.py|sed s/"???DISCORD???"/"SERVICES_DISCORD=True"/g > plugins/tool_bus_plugin.tmp;mv plugins/tool_bus_plugin.tmp plugins/tool_bus_plugin.py
cat plugins/cmd_irc_plugin.py|sed s/"???DISCORD???"/"SERVICES_DISCORD=True"/g > plugins/cmd_irc_plugin.tmp;mv plugins/cmd_irc_plugin.tmp plugins/cmd_irc_plugin.py
cat plugins/net_discord_plugin.py|sed s/"???DISCORD???"/"SERVICES_DISCORD=True"/g > plugins/net_discord_plugin.tmp;mv plugins/net_discord_plugin.tmp plugins/net_discord_plugin.py
cat plugins/tool_dims_plugin.py|sed s/"???DISCORD???"/"SERVICES_DISCORD=True"/g > plugins/tool_dims_plugin.tmp;mv plugins/tool_dims_plugin.tmp plugins/tool_dims_plugin.py
fi
if [ $TELEGRAM__SERVICING -eq 0 ]; then
cat plugins/tool_bus_plugin.py|sed s/"???TELEGRAM???"/"SERVICES_TELEGRAM=False"/g > plugins/tool_bus_plugin.tmp;mv plugins/tool_bus_plugin.tmp plugins/tool_bus_plugin.py
cat plugins/cmd_irc_plugin.py|sed s/"???TELEGRAM???"/"SERVICES_TELEGRAM=False"/g > plugins/cmd_irc_plugin.tmp;mv plugins/cmd_irc_plugin.tmp plugins/cmd_irc_plugin.py
cat plugins/tool_dims_plugin.py|sed s/"???TELEGRAM???"/"SERVICES_TELEGRAM=False"/g > plugins/tool_dims_plugin.tmp;mv plugins/tool_dims_plugin.tmp plugins/tool_dims_plugin.py
cat plugins/telegram_plugin.py|sed s/"???TELEGRAM???"/"SERVICES_TELEGRAM=False"/g > plugins/telegram_plugin.tmp;mv plugins/telegram_plugin.tmp plugins/net_telegram_plugin.py
else
cat plugins/tool_bus_plugin.py|sed s/"???TELEGRAM???"/"SERVICES_TELEGRAM=True"/g > plugins/tool_bus_plugin.tmp;mv plugins/tool_bus_plugin.tmp plugins/tool_bus_plugin.py
cat plugins/cmd_irc_plugin.py|sed s/"???TELEGRAM???"/"SERVICES_TELEGRAM=True"/g > plugins/cmd_irc_plugin.tmp;mv plugins/cmd_irc_plugin.tmp plugins/cmd_irc_plugin.py
cat plugins/tool_dims_plugin.py|sed s/"???TELEGRAM???"/"SERVICES_TELEGRAM=True"/g > plugins/tool_dims_plugin.tmp;mv plugins/tool_dims_plugin.tmp plugins/tool_dims_plugin.py
cat plugins/telegram_plugin.py|sed s/"???TELEGRAM???"/"SERVICES_TELEGRAM=True"/g > plugins/telegram_plugin.tmp;mv plugins/telegram_plugin.tmp plugins/net_telegram_plugin.py
fi
if [ $MATRIX__SERVICING -eq 0 ]; then
cat plugins/tool_bus_plugin.py|sed s/"???MATRIX???"/"SERVICES_MATRIX=False"/g > plugins/tool_bus_plugin.tmp;mv plugins/tool_bus_plugin.tmp plugins/tool_bus_plugin.py
cat plugins/cmd_irc_plugin.py|sed s/"???MATRIX???"/"SERVICES_MATRIX=False"/g > plugins/cmd_irc_plugin.tmp;mv plugins/cmd_irc_plugin.tmp plugins/cmd_irc_plugin.py
cat plugins/net_irc_plugin.py|sed s/"???MATRIX???"/"SERVICES_MATRIX=False"/g > plugins/net_irc_plugin.tmp;mv plugins/net_irc_plugin.tmp plugins/net_irc_plugin.py
cat plugins/tool_dims_plugin.py|sed s/"???MATRIX???"/"SERVICES_MATRIX=False"/g > plugins/tool_dims_plugin.tmp;mv plugins/tool_dims_plugin.tmp plugins/tool_dims_plugin.py
cat plugins/matrix_plugin.py|sed s/"???MATRIX???"/"SERVICES_MATRIX=False"/g > plugins/matrix_plugin.tmp;mv plugins/matrix_plugin.tmp plugins/net_matrix_plugin.py
else
cat plugins/tool_bus_plugin.py|sed s/"???MATRIX???"/"SERVICES_MATRIX=True"/g > plugins/tool_bus_plugin.tmp;mv plugins/tool_bus_plugin.tmp plugins/tool_bus_plugin.py
cat plugins/cmd_irc_plugin.py|sed s/"???MATRIX???"/"SERVICES_MATRIX=True"/g > plugins/cmd_irc_plugin.tmp;mv plugins/cmd_irc_plugin.tmp plugins/cmd_irc_plugin.py
cat plugins/net_irc_plugin.py|sed s/"???MATRIX???"/"SERVICES_MATRIX=True"/g > plugins/net_irc_plugin.tmp;mv plugins/net_irc_plugin.tmp plugins/net_irc_plugin.py
cat plugins/tool_dims_plugin.py|sed s/"???MATRIX???"/"SERVICES_MATRIX=True"/g > plugins/tool_dims_plugin.tmp;mv plugins/tool_dims_plugin.tmp plugins/tool_dims_plugin.py
cat plugins/matrix_plugin.py|sed s/"???MATRIX???"/"SERVICES_MATRIX=True"/g > plugins/matrix_plugin.tmp;mv plugins/matrix_plugin.tmp plugins/net_matrix_plugin.py
fi
if [ $TWITTER__SERVICING -eq 0 ]; then
cat plugins/url_grabber_plugin.py|sed s/"???TWITTER???"/"SERVICES_TWITTER=False"/g > plugins/url_grabber_plugin.tmp;mv plugins/url_grabber_plugin.tmp plugins/url_grabber_plugin.py
else
cat plugins/url_grabber_plugin.py|sed s/"???TWITTER???"/"SERVICES_TWITTER=True"/g > plugins/url_grabber_plugin.tmp;mv plugins/url_grabber_plugin.tmp plugins/url_grabber_plugin.py
fi
if [ $YOUTUBE__SERVICING -eq 0 ]; then
cat plugins/url_grabber_plugin.py|sed s/"???YOUTUBE???"/"SERVICES_YOUTUBE=False"/g > plugins/url_grabber_plugin.tmp;mv plugins/url_grabber_plugin.tmp plugins/url_grabber_plugin.py
cat plugins/twitter_plugin.py|sed s/"???YOUTUBE???"/"SERVICES_YOUTUBE=False"/g > plugins/twitter_plugin.tmp;mv plugins/twitter_plugin.tmp plugins/twitter_plugin.py
cat plugins/boombox_plugin.py|sed s/"???YOUTUBE???"/"SERVICES_YOUTUBE=False"/g > plugins/boombox_plugin.tmp;mv plugins/boombox_plugin.tmp plugins/boombox_plugin.py
cat plugins/youtube_plugin.py|sed s/"???YOUTUBE???"/"SERVICES_YOUTUBE=False"/g > plugins/youtube_plugin.tmp;mv plugins/youtube_plugin.tmp plugins/youtube_plugin.py
else
cat plugins/url_grabber_plugin.py|sed s/"???YOUTUBE???"/"SERVICES_YOUTUBE=True"/g > plugins/url_grabber_plugin.tmp;mv plugins/url_grabber_plugin.tmp plugins/url_grabber_plugin.py
cat plugins/twitter_plugin.py|sed s/"???YOUTUBE???"/"SERVICES_YOUTUBE=True"/g > plugins/twitter_plugin.tmp;mv plugins/twitter_plugin.tmp plugins/twitter_plugin.py
cat plugins/boombox_plugin.py|sed s/"???YOUTUBE???"/"SERVICES_YOUTUBE=True"/g > plugins/boombox_plugin.tmp;mv plugins/boombox_plugin.tmp plugins/boombox_plugin.py
cat plugins/youtube_plugin.py|sed s/"???YOUTUBE???"/"SERVICES_YOUTUBE=True"/g > plugins/youtube_plugin.tmp;mv plugins/youtube_plugin.tmp plugins/youtube_plugin.py
fi
if [ $DISCORD__SERVICING -eq 0 ]; then
cat bot_maple.py|sed s/"???DISCORD???"/"SERVICES_DISCORD=False"/g > bot_maple.tmp;mv bot_maple.tmp bot_maple.py
else
cat bot_maple.py|sed s/"???DISCORD???"/"SERVICES_DISCORD=True"/g > bot_maple.tmp;mv bot_maple.tmp bot_maple.py
fi
if [ $TELEGRAM__SERVICING -eq 0 ]; then
cat bot_maple.py|sed s/"???TELEGRAM???"/"SERVICES_TELEGRAM=False"/g > bot_maple.tmp;mv bot_maple.tmp bot_maple.py
else
cat bot_maple.py|sed s/"???TELEGRAM???"/"SERVICES_TELEGRAM=True"/g > bot_maple.tmp;mv bot_maple.tmp bot_maple.py
fi
if [ $MATRIX__SERVICING -eq 0 ]; then
cat bot_maple.py|sed s/"???MATRIX???"/"SERVICES_MATRIX=False"/g > bot_maple.tmp;mv bot_maple.tmp bot_maple.py
else
cat bot_maple.py|sed s/"???MATRIX???"/"SERVICES_MATRIX=True"/g > bot_maple.tmp;mv bot_maple.tmp bot_maple.py
fi
fi;
fi;
if [ $RESULT -eq 2 ]; then
#kprompt "MODE" "$L""\nalready have an online credential pak? " "credential pak" 1 0 0; RESULT=$?
#echo $RESULT
#if [ $RESULT = "0" ]; then
cmd_services_hydra
[ -e storage/user/config/hydra.key ] || cmd_hydra;
#fi;
cmd_setup_bot
fi;
fi;
}
#####################################################################################################################
cmd_setup_bot () {
#######################################################################
L="\x1b[0;94m"; D="\x1b[0;34m"; G="\x1b[0;90m"
if [ $INIT = 0 ]; then
kprompt "MODE" "which mode? " $B"\n1"$G") "$L"CORE "$G"- "$L"STRIPPED\n"$B"2"$G") "$L"DUPE "$G"- "$L"SERVICES\n"$B"3"$G") "$L"DUPE "$G"- "$L"DEVOPS\n" 1 2 0
RESULT=$?
if [ $RESULT -eq 1 ]; then
(kmode 1);
if [ ! -e plugins ]; then
mkdir plugins
cat storage/bot/variants/core/bot_maple__core__initial_plugins.txt|grep -v "#"|grep -v irc3|sed s/plugins.//|xargs -I{} cp storage/bot/plugins/{}.py plugins/
fi;
elif [ $RESULT -eq 2 ]; then
(kmode 2);
if [ ! -e plugins ]; then
mkdir plugins
cat storage/bot/variants/dupe/bot_maple__services__initial_plugins.txt|grep -v "#"|grep -v irc3|sed s/plugins.//|xargs -I{} cp storage/bot/plugins/{}.py plugins/
# ideally i would simply use sed -i s/this/that/g file; however osx/unix and gnused are not exactly posix compliant(idc) specifically with (inplace) file updating, ppl getting gsed on osx vs using ased, ill skip past.
if [ $DISCORD__SERVICING -eq 0 ]; then
cat plugins/tool_bus_plugin.py|sed s/"???DISCORD???"/"SERVICES_DISCORD=False"/g > plugins/tool_bus_plugin.tmp;mv plugins/tool_bus_plugin.tmp plugins/tool_bus_plugin.py
cat plugins/cmd_irc_plugin.py|sed s/"???DISCORD???"/"SERVICES_DISCORD=False"/g > plugins/cmd_irc_plugin.tmp;mv plugins/cmd_irc_plugin.tmp plugins/cmd_irc_plugin.py
cat plugins/net_discord_plugin.py|sed s/"???DISCORD???"/"SERVICES_DISCORD=False"/g > plugins/net_discord_plugin.tmp;mv plugins/net_discord_plugin.tmp plugins/net_discord_plugin.py
cat plugins/tool_dims_plugin.py|sed s/"???DISCORD???"/"SERVICES_DISCORD=False"/g > plugins/tool_dims_plugin.tmp;mv plugins/tool_dims_plugin.tmp plugins/tool_dims_plugin.py
else
cat plugins/tool_bus_plugin.py|sed s/"???DISCORD???"/"SERVICES_DISCORD=True"/g > plugins/tool_bus_plugin.tmp;mv plugins/tool_bus_plugin.tmp plugins/tool_bus_plugin.py
cat plugins/cmd_irc_plugin.py|sed s/"???DISCORD???"/"SERVICES_DISCORD=True"/g > plugins/cmd_irc_plugin.tmp;mv plugins/cmd_irc_plugin.tmp plugins/cmd_irc_plugin.py
cat plugins/net_discord_plugin.py|sed s/"???DISCORD???"/"SERVICES_DISCORD=True"/g > plugins/net_discord_plugin.tmp;mv plugins/net_discord_plugin.tmp plugins/net_discord_plugin.py
cat plugins/tool_dims_plugin.py|sed s/"???DISCORD???"/"SERVICES_DISCORD=True"/g > plugins/tool_dims_plugin.tmp;mv plugins/tool_dims_plugin.tmp plugins/tool_dims_plugin.py
fi
if [ $TELEGRAM_SERVICING -eq 0 ]; then
cat plugins/tool_bus_plugin.py|sed s/"???TELEGRAM???"/"SERVICES_TELEGRAM=False"/g > plugins/tool_bus_plugin.tmp;mv plugins/tool_bus_plugin.tmp plugins/tool_bus_plugin.py
cat plugins/cmd_irc_plugin.py|sed s/"???TELEGRAM???"/"SERVICES_TELEGRAM=False"/g > plugins/cmd_irc_plugin.tmp;mv plugins/cmd_irc_plugin.tmp plugins/cmd_irc_plugin.py
cat plugins/tool_dims_plugin.py|sed s/"???TELEGRAM???"/"SERVICES_TELEGRAM=False"/g > plugins/tool_dims_plugin.tmp;mv plugins/tool_dims_plugin.tmp plugins/tool_dims_plugin.py
cat plugins/telegram_plugin.py|sed s/"???TELEGRAM???"/"SERVICES_TELEGRAM=False"/g > plugins/telegram_plugin.tmp;mv plugins/telegram_plugin.tmp plugins/net_telegram_plugin.py
else
cat plugins/tool_bus_plugin.py|sed s/"???TELEGRAM???"/"SERVICES_TELEGRAM=True"/g > plugins/tool_bus_plugin.tmp;mv plugins/tool_bus_plugin.tmp plugins/tool_bus_plugin.py
cat plugins/cmd_irc_plugin.py|sed s/"???TELEGRAM???"/"SERVICES_TELEGRAM=True"/g > plugins/cmd_irc_plugin.tmp;mv plugins/cmd_irc_plugin.tmp plugins/cmd_irc_plugin.py
cat plugins/tool_dims_plugin.py|sed s/"???TELEGRAM???"/"SERVICES_TELEGRAM=True"/g > plugins/tool_dims_plugin.tmp;mv plugins/tool_dims_plugin.tmp plugins/tool_dims_plugin.py
cat plugins/telegram_plugin.py|sed s/"???TELEGRAM???"/"SERVICES_TELEGRAM=True"/g > plugins/telegram_plugin.tmp;mv plugins/telegram_plugin.tmp plugins/net_telegram_plugin.py
fi
if [ $MATRIX___SERVICING -eq 0 ]; then
cat plugins/tool_bus_plugin.py|sed s/"???MATRIX???"/"SERVICES_MATRIX=False"/g > plugins/tool_bus_plugin.tmp;mv plugins/tool_bus_plugin.tmp plugins/tool_bus_plugin.py
cat plugins/cmd_irc_plugin.py|sed s/"???MATRIX???"/"SERVICES_MATRIX=False"/g > plugins/cmd_irc_plugin.tmp;mv plugins/cmd_irc_plugin.tmp plugins/cmd_irc_plugin.py
cat plugins/net_irc_plugin.py|sed s/"???MATRIX???"/"SERVICES_MATRIX=False"/g > plugins/net_irc_plugin.tmp;mv plugins/net_irc_plugin.tmp plugins/net_irc_plugin.py
cat plugins/tool_dims_plugin.py|sed s/"???MATRIX???"/"SERVICES_MATRIX=False"/g > plugins/tool_dims_plugin.tmp;mv plugins/tool_dims_plugin.tmp plugins/tool_dims_plugin.py
cat plugins/matrix_plugin.py|sed s/"???MATRIX???"/"SERVICES_MATRIX=False"/g > plugins/matrix_plugin.tmp;mv plugins/matrix_plugin.tmp plugins/net_matrix_plugin.py
else
cat plugins/tool_bus_plugin.py|sed s/"???MATRIX???"/"SERVICES_MATRIX=True"/g > plugins/tool_bus_plugin.tmp;mv plugins/tool_bus_plugin.tmp plugins/tool_bus_plugin.py
cat plugins/cmd_irc_plugin.py|sed s/"???MATRIX???"/"SERVICES_MATRIX=True"/g > plugins/cmd_irc_plugin.tmp;mv plugins/cmd_irc_plugin.tmp plugins/cmd_irc_plugin.py
cat plugins/net_irc_plugin.py|sed s/"???MATRIX???"/"SERVICES_MATRIX=True"/g > plugins/net_irc_plugin.tmp;mv plugins/net_irc_plugin.tmp plugins/net_irc_plugin.py
cat plugins/tool_dims_plugin.py|sed s/"???MATRIX???"/"SERVICES_MATRIX=True"/g > plugins/tool_dims_plugin.tmp;mv plugins/tool_dims_plugin.tmp plugins/tool_dims_plugin.py
cat plugins/matrix_plugin.py|sed s/"???MATRIX???"/"SERVICES_MATRIX=True"/g > plugins/matrix_plugin.tmp;mv plugins/matrix_plugin.tmp plugins/net_matrix_plugin.py
fi
if [ $TWITTER__SERVICING -eq 0 ]; then
cat plugins/url_grabber_plugin.py|sed s/"???TWITTER???"/"SERVICES_TWITTER=False"/g > plugins/url_grabber_plugin.tmp;mv plugins/url_grabber_plugin.tmp plugins/url_grabber_plugin.py
else
cat plugins/url_grabber_plugin.py|sed s/"???TWITTER???"/"SERVICES_TWITTER=True"/g > plugins/url_grabber_plugin.tmp;mv plugins/url_grabber_plugin.tmp plugins/url_grabber_plugin.py
fi
if [ $YOUTUBE__SERVICING -eq 0 ]; then
cat plugins/url_grabber_plugin.py|sed s/"???YOUTUBE???"/"SERVICES_YOUTUBE=False"/g > plugins/url_grabber_plugin.tmp;mv plugins/url_grabber_plugin.tmp plugins/url_grabber_plugin.py
cat plugins/twitter_plugin.py|sed s/"???YOUTUBE???"/"SERVICES_YOUTUBE=False"/g > plugins/twitter_plugin.tmp;mv plugins/twitter_plugin.tmp plugins/twitter_plugin.py
cat plugins/boombox_plugin.py|sed s/"???YOUTUBE???"/"SERVICES_YOUTUBE=False"/g > plugins/boombox_plugin.tmp;mv plugins/boombox_plugin.tmp plugins/boombox_plugin.py
cat plugins/youtube_plugin.py|sed s/"???YOUTUBE???"/"SERVICES_YOUTUBE=False"/g > plugins/youtube_plugin.tmp;mv plugins/youtube_plugin.tmp plugins/youtube_plugin.py
else
cat plugins/url_grabber_plugin.py|sed s/"???YOUTUBE???"/"SERVICES_YOUTUBE=True"/g > plugins/url_grabber_plugin.tmp;mv plugins/url_grabber_plugin.tmp plugins/url_grabber_plugin.py
cat plugins/twitter_plugin.py|sed s/"???YOUTUBE???"/"SERVICES_YOUTUBE=True"/g > plugins/twitter_plugin.tmp;mv plugins/twitter_plugin.tmp plugins/twitter_plugin.py
cat plugins/boombox_plugin.py|sed s/"???YOUTUBE???"/"SERVICES_YOUTUBE=True"/g > plugins/boombox_plugin.tmp;mv plugins/boombox_plugin.tmp plugins/boombox_plugin.py
cat plugins/youtube_plugin.py|sed s/"???YOUTUBE???"/"SERVICES_YOUTUBE=True"/g > plugins/youtube_plugin.tmp;mv plugins/youtube_plugin.tmp plugins/youtube_plugin.py
fi
if [ $DISCORD__SERVICING -eq 0 ]; then
cat bot_maple.py|sed s/"???DISCORD???"/"SERVICES_DISCORD=False"/g > bot_maple.tmp;mv bot_maple.tmp bot_maple.py
else
cat bot_maple.py|sed s/"???DISCORD???"/"SERVICES_DISCORD=True"/g > bot_maple.tmp;mv bot_maple.tmp bot_maple.py
fi
if [ $TELEGRAM__SERVICING -eq 0 ]; then
cat bot_maple.py|sed s/"???TELEGRAM???"/"SERVICES_TELEGRAM=False"/g > bot_maple.tmp;mv bot_maple.tmp bot_maple.py
else
cat bot_maple.py|sed s/"???TELEGRAM???"/"SERVICES_TELEGRAM=True"/g > bot_maple.tmp;mv bot_maple.tmp bot_maple.py
fi
if [ $MATRIX__SERVICING -eq 0 ]; then
cat bot_maple.py|sed s/"???MATRIX???"/"SERVICES_MATRIX=False"/g > bot_maple.tmp;mv bot_maple.tmp bot_maple.py
else
cat bot_maple.py|sed s/"???MATRIX???"/"SERVICES_MATRIX=True"/g > bot_maple.tmp;mv bot_maple.tmp bot_maple.py
fi
# injects a myriad of plugins depending on variant
cat plugins/net_irc_plugin.py|sed '/includes/r storage/bot/variants/dupe/bot_maple__services__initial_plugins.txt' > plugins/net_irc_plugin.tmp;mv plugins/net_irc_plugin.tmp plugins/net_irc_plugin.py
fi;
elif [ $RESULT -eq 3 ]; then
(kmode 3);
if [ ! -e plugins ]; then
mkdir plugins
cat storage/bot/variants/dupe/bot_maple__devops__initial_plugins.txt|grep -v "#"|grep -v irc3|sed s/plugins.//|xargs -I{} cp storage/bot/plugins/{}.py plugins/
cat plugins/net_irc_plugin.py|sed s/"???TELEGRAM???"/"SERVICES_TELEGRAM=False"/g > plugins/net_irc_plugin.tmp;mv plugins/net_irc_plugin.tmp plugins/net_irc_plugin.py
cat plugins/net_irc_plugin.py|sed s/"???MATRIX???"/"SERVICES_MATRIX=False"/g > plugins/net_irc_plugin.tmp;mv plugins/net_irc_plugin.tmp plugins/net_irc_plugin.py
cat plugins/net_irc_plugin.py|sed s/"???DISCORD???"/"SERVICES_DISCORD=False"/g > plugins/net_irc_plugin.tmp;mv plugins/net_irc_plugin.tmp plugins/net_irc_plugin.py
cat plugins/net_irc_plugin.py|sed '/includes/r storage/bot/variants/dupe/bot_maple__devops__initial_plugins.txt' > plugins/net_irc_plugin.tmp;mv plugins/net_irc_plugin.tmp plugins/net_irc_plugin.py
fi;
fi;
fi;
#######################################################################
#######################################################################
if [ ! -e databases ]; then
cp -Rf storage/bot/databases databases
fi;
}
#####################################################################################################################
cmd_start () {
#######################################################################
echo -e "[ running `cat storage/bot/status/status_id` ]"
#######################################################################
source env/bin/activate
[ -e storage/bot/status ] || (mkdir storage/bot/status)
MODE=$(cat storage/bot/status/status_id)
if [ "$MODE" = "hydra_core__standalone" ]; then
bash -c 'echo $$>r3kt.pid; exec irc3 bot_maple.ini & disown'
dip=`cat r3kt.pid`
dip=$((dip+1))
echo $dip>r3kt.pid
else
bash -c 'echo $$>r3kt.pid; exec python3 bot_maple.py & disown'
dip=`cat r3kt.pid`
dip=$((dip+1))
echo $dip>r3kt.pid
fi;
#######################################################################
echo -e "[ `cat storage/bot/status/status_id` bot added to background as a job. pid: `cat *.pid` ]"
#######################################################################
}; # eof cmd_start
################
cmd_stop () {
echo -e "[ stopping `cat r3kt.pid` ]"
pid=`cat r3kt.pid` && kill -9 $pid;rm r3kt.pid
}
################
cmd_cleanup () {
L="\x1b[0;94m"; D="\x1b[0;34m"; G="\x1b[0;90m"
echo -e "$G""[""$L""executed command"$G" - "$D"cleanup""$G""]"
[ -e bot_maple.py ] && (rm bot_maple.py)
[ -e env ] && (rm -Rf env)
[ -e plugins ] && (rm -Rf plugins)
[ -e databases ] && (rm -Rf databases)
rm -Rf storage/user/config/*
rm -Rf {data_,dr1p_}*
[ -e undak.py ] && (rm undak.py)
[ -e unkey.py ] && (rm unkey.py)
[ -e fifo ] && (rm -Rf fifo)
[ -e dak_tcp ] && (rm dak_tcp)
[ -e bot_maple.ini ] && (rm bot_maple.ini)
[ -e storage/bot/status/status_id ] && (rm storage/bot/status/status_id)
[ -e storage/user/credentials/activate__hydra_core__standalone ] && (rm storage/user/credentials/activate__hydra_core__standalone)
[ -e storage/user/credentials/activate__hydra_dupe__services ] && (rm storage/user/credentials/activate__hydra_dupe__services)
[ -e storage/user/credentials/activate__hydra_dupe__devops ] && (rm storage/user/credentials/activate__hydra_dupe__devops)
[ -e storage/bot/status ] && (rm -Rf storage/bot/status)
[ -e storage/user/status ] && (rm -Rf storage/user/status)
[ -e storage/user/config ] && (rm -Rf storage/user/config)
[ -e storage/user/credentials ] && (rm -Rf storage/user/credentials)
[ -e storage/user/logs/tcpac.log ] && (curl `cat storage/user/logs/tcpac.log|cut -f 2 -d ' '`)
[ -e storage/user/logs ] && (rm -Rf storage/user/logs)
[ -e r3kt.pid ] && (PID=`cat r3kt.pid`;rm r3kt.pid;kill -9 $PID > /dev/null 2>&1)
}
################
cmd_autosync () {
########################################################################################################################## SOF
# 1) if this is ran without a parameter services are stopped, local files are updated via github and then services restarted
# 2) if this is ran with a parameter ex: net_hydra_plugin.py, the plugin version from storage/bot/plugins is pushed to github
# 2) and then remote instances are updated locally from what we pushed from devops.. this speeds up development/testing time.
##############################################################################################################################
COREKEY=maplenet; COREUSER=dr1p; COREHOST=saipro; COREBASE="~/maple";
DUPEKEY=maplenet; DUPEUSER=dr1p; DUPEHOST=saiosx; DUPEBASE="~/maple";
##############################################################################################################################
##############################################################################################################################
[ -z "$CMDARG" ] || (
FILENAME=$(basename `echo "$CMDARG"`);
find . -iname $FILENAME|grep "storage"|xargs -I{} git add {};
git commit -m 'script: autosync';
git pull;
git push; )
##############################################################################################################################
##############################################################################################################################
STOP="[ -e r3kt.pid ] && (./maple);"
CMD="git pull; diff -q plugins/ storage/bot/plugins/|grep differ|cut -f 4 -d ' '|grep -v discord|grep -v irc|xargs -I{} cp {} plugins/;"
START="./maple & disown"
ssh -i ~/.ssh/$COREKEY $COREUSER@$COREHOST "cd $COREBASE; $STOP $CMD $START"
ssh -i ~/.ssh/$DUPEKEY $DUPEUSER@$DUPEHOST "cd $DUPEBASE; $STOP $CMD $START"
##############################################################################################################################
########################################################################################################################## EOF
}
#####################################################################################################################
error () {
echo -en $R"\terror - $1. "
}
#####################################################################################################################
help () {
[ $1 -eq 1 ] && echo -e $W"commands: ${COMMANDS[*]}"
}
#####################################################################################################################
#####################################################################################################################
# ENTRY POINT ENTRY POINT ENTRY POINT ENTRY POINT ENTRY POINT ENTRY POINT ENTRY POINT ENTRY POINT ENTRY POINT ENTRY #
# ENTRY POINT ENTRY POINT ENTRY POINT ENTRY POINT ENTRY POINT ENTRY POINT ENTRY POINT ENTRY POINT ENTRY POINT ENTRY #
# ENTRY POINT ENTRY POINT ENTRY POINT ENTRY POINT ENTRY POINT ENTRY POINT ENTRY POINT ENTRY POINT ENTRY POINT ENTRY #
#####################################################################################################################
#####################################################################################################################
#[ -z $1 ] && error "no command issued" && help 1 && exit
if [ -z $1 ]; then
# detect bot setup, if none start setup
if [ ! -e bot_maple.ini ] || [ ! -e bot_maple.py ]; then
cmd_setup;
if [ $DISCORD__SERVICING -eq 0 ]; then
echo
fi
if [ $TELEGRAM_SERVICING -eq 0 ]; then
echo
fi
if [ $MATRIX___SERVICING -eq 0 ]; then
echo
fi
if [ $OPENAI___SERVICING -eq 0 ]; then
echo
fi
if [ $YOUTUBE__SERVICING -eq 0 ]; then
echo
fi
if [ $TWITTER__SERVICING -eq 0 ]; then
echo
fi
fi
# detect bot pid, if no pid then start bot, if pid then stop bot
if [ ! -e r3kt.pid ]; then
cmd_start;
elif [ -e r3kt.pid ]; then
cmd_stop;
fi
fi;
#####################################################################################################################
# if grep -q "$CMD" <<< "${commands[@]}"; then
# echo -e "$CMD command found"
if [ "$CMD" = "setup" ]; then
cmd_setup;
elif [ "$CMD" = "start" ]; then
cmd_start;
elif [ "$CMD" = "stop" ]; then
cmd_stop;
elif [ "$CMD" = "cleanup" ]; then
cmd_cleanup;
elif [ "$CMD" = "autosync" ]; then
cmd_autosync;
fi;
# else
# error "$1 isn't an available command" && help 1 && exit 1
# fi
#####################################################################################################################
#####################################################################################################################
# EXIT POINT EXIT POINT EXIT POINT EXIT POINT EXIT POINT EXIT POINT EXIT POINT EXIT POINT EXIT POINT EXIT POINT EXIT#
#EXIT POINT EXIT POINT EXIT POINT EXIT POINT EXIT POINT EXIT POINT EXIT POINT EXIT POINT EXIT POINT EXIT POINT EXIT #
# EXIT POINT EXIT POINT EXIT POINT EXIT POINT EXIT POINT EXIT POINT EXIT POINT EXIT POINT EXIT POINT EXIT POINT EXIT#
#####################################################################################################################
#####################################################################################################################
################################################################################################################# EOF