From 19cb280a2cc8da730b2e6797aede1b36253e6714 Mon Sep 17 00:00:00 2001 From: kaotisk Date: Fri, 7 Jun 2024 01:41:33 +0300 Subject: Fixes and updates in tests --- bin/ak-log-rotate | 2 +- bin/ak-startup | 3 ++- config.sh | 2 +- init.sh | 17 ++++++++------- install.sh | 21 ++++++++++++------ ipfs-check-install-setup-init-update | 6 ++++-- podman/ContainerFile.alpine | 1 + test_with_podman.sh | 41 ++++++++++++++++++++++++++---------- 8 files changed, 62 insertions(+), 31 deletions(-) diff --git a/bin/ak-log-rotate b/bin/ak-log-rotate index 7bfee72..ddf8f84 100755 --- a/bin/ak-log-rotate +++ b/bin/ak-log-rotate @@ -1,6 +1,6 @@ #!/bin/bash -tar cvfz $AK_ARCHIVESDIR/logs_$(date -u +%s).tar.gz $AK_WORKDIR/akd.log $AK_WORKDIR/akd.err $AK_WORKDIR/logs +tar cvfz $AK_ARCHIVESDIR/logs_$(date -u +%s).tar.gz $AK_WORKDIR/logs cat /dev/null > $AK_WORKDIR/akd.log cat /dev/null > $AK_WORKDIR/akd.err diff --git a/bin/ak-startup b/bin/ak-startup index 84c0a6c..66a100d 100755 --- a/bin/ak-startup +++ b/bin/ak-startup @@ -4,5 +4,6 @@ PATH=$PATH:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:$HOME/bin:$HOME/.ar source $HOME/.arching-kaos/rc ak-ipfs-starter ak-log-rotate -screen -dmS akdaemon ak-daemon > $AK_WORKDIR/akd.log 2> $AK_WORKDIR/akd.err & printf '%s' "$!" > $AK_WORKDIR/akd.pid +# screen -dmS akdaemon +ak-daemon > $AK_WORKDIR/akd.log 2> $AK_WORKDIR/akd.err & printf '%s' "$!" > $AK_WORKDIR/akd.pid # ak-logfollow diff --git a/config.sh b/config.sh index 572041b..aa5bf4b 100755 --- a/config.sh +++ b/config.sh @@ -20,7 +20,7 @@ export AK_ZLIST="$AK_WORKDIR/zlist" export AK_ZLATEST="$AK_WORKDIR/zlatest" export AK_LOGSFILE="$AK_WORKDIR/logs" export AK_GPGHOME="$AK_WORKDIR/keyring" -export AK_FINGERPRINT="$(gpg2 --homedir $AK_GPGHOME --list-keys | grep kaos@kaos.kaos -1 | head -n1 | awk '{print $1}')" +export AK_FINGERPRINT="$(gpg2 --homedir $AK_GPGHOME --list-keys | grep kaos@kaos.kaos -B 1 | head -n 1 | awk '{print $1}')" export AK_MINEDBLOCKSDIR="$AK_WORKDIR/mined_blocks" export AK_ZBLOCKSFILE="$AK_WORKDIR/zBlocksFile" export AK_ZPAIRSFILE="$AK_WORKDIR/pairsFile" diff --git a/init.sh b/init.sh index 30532f9..43f2a40 100755 --- a/init.sh +++ b/init.sh @@ -1,4 +1,5 @@ #!/bin/bash +set -x source lib/_ak_ipfs # TODO GPG/PGP setup:: possibly done @@ -6,11 +7,11 @@ source lib/_ak_ipfs # or just question the user if they are going to use their # existing one if any. ak_gpg_check_or_create(){ - gpg2 --homedir $AK_GPGHOME --list-keys | grep kaos@kaos.kaos -1 + gpg2 --homedir $AK_GPGHOME --list-keys | grep kaos@kaos.kaos -B 1 if [ "$?" -ne "0" ] then gpg2 --homedir $AK_GPGHOME --batch --passphrase '' --quick-gen-key kaos@kaos.kaos rsa3072 sign 0 - AK_FINGERPRINT="$(gpg2 --homedir $AK_GPGHOME --list-keys | grep kaos@kaos.kaos -1 | head -n 1 | awk '{print $1}')" + AK_FINGERPRINT="$(gpg2 --homedir $AK_GPGHOME --list-keys | grep kaos@kaos.kaos -B 1 | head -n 1 | awk '{print $1}')" gpg2 --homedir $AK_GPGHOME --batch --passphrase '' --quick-add-key $AK_FINGERPRINT rsa3072 encrypt 0 fi } @@ -51,22 +52,22 @@ printf "Initialization started... \n" ak_gpg_check_or_create -if [ -f $AK_ZGENESIS ] ; then printf "%s" "$(ipfs add -q $AK_GENESIS)" > $AK_ZGENESIS;fi +if [ -f $AK_ZGENESIS ] ; then printf "%s" "$(_ak_ipfs add -q $AK_GENESIS)" > $AK_ZGENESIS;fi if [ ! -f $AK_ZCHAIN ] then _ak_ipfs key list | grep zchain if [ "$?" -ne 0 ] then - printf "%s" "$(ipfs key gen zchain)" > $AK_ZCHAIN + printf "%s" "$(_ak_ipfs key gen zchain)" > $AK_ZCHAIN else - printf "%s" "$(ipfs key list -l | grep zchain | awk '{ print $1 }')" > $AK_ZCHAIN + printf "%s" "$(_ak_ipfs key list -l | grep zchain | awk '{ print $1 }')" > $AK_ZCHAIN fi fi if [ ! -f $AK_ZLATEST ] ; then cp $AK_ZGENESIS $AK_ZLATEST;fi if [ ! -f $AK_ZCHAINASC ] ; then gpg2 --homedir $AK_GPGHOME -bao $AK_ZCHAINASC $AK_ZCHAIN;fi -if [ ! -f $AK_ZZCHAIN ] ; then printf "%s" "$(ipfs add -q $AK_ZCHAINASC)" > $AK_ZZCHAIN;fi +if [ ! -f $AK_ZZCHAIN ] ; then printf "%s" "$(_ak_ipfs add -q $AK_ZCHAINASC)" > $AK_ZZCHAIN;fi if [ ! -f $AK_GENESISASC ] ; then gpg2 --homedir $AK_GPGHOME -bao $AK_GENESISASC $AK_GENESIS;fi -if [ ! -f $AK_ZGENESISASC ] ; then printf "%s" "$(ipfs add -q $AK_GENESISASC)" > $AK_ZGENESISASC;fi +if [ ! -f $AK_ZGENESISASC ] ; then printf "%s" "$(_ak_ipfs add -q $AK_GENESISASC)" > $AK_ZGENESISASC;fi if [ ! -f $AK_ZBLOCKSFILE ] ; then printf "[]" > $AK_ZBLOCKSFILE;fi if [ ! -f $AK_ZPAIRSFILE ] ; then printf "[]" > $AK_ZPAIRSFILE;fi if [ ! -f $AK_ZPEERSFILE ] ; then printf "[]" > $AK_ZPEERSFILE;fi @@ -119,7 +120,7 @@ do printf "\tOK!\n" fi done -# + # Find modules and create symlinks modfiles=$(ls -1 $(pwd)/modules) for m in $modfiles diff --git a/install.sh b/install.sh index e05a634..5a04c5e 100755 --- a/install.sh +++ b/install.sh @@ -93,7 +93,7 @@ checkIfSudoAvailable(){ checkIfSudoAvailable # Depedencies check and install -declare -a depedencies=("curl" "wget" "bash" "jq" "npm" "gpg" "git" "make" "screen") +declare -a depedencies=("curl" "wget" "bash" "jq" "npm" "gpg" "git" "make" "screen" "gpg-agent") for dep in "${depedencies[@]}" do printf "Checking for %s..." "$dep" @@ -171,37 +171,44 @@ if [ ! -d $HOME/$HAK ]; then mkdir $HOME/$HAK logthis "$HAK created in $HOME"; fi + logthis "Searching for rc" if [ ! -f $HOME/$HAK/rc ]; then echo export PATH=$PATH:$HOME/$HAK/bin > $HOME/$HAK/rc cat config.sh >> $HOME/$HAK/rc logthis "New rc export to file"; fi + logthis "Searching for shell" -if [ $SHELL == "/usr/bin/zsh" ]; then +if [ $SHELL == "/usr/bin/zsh" ] +then SHELLRC=".zshrc" logthis "ZSH found"; -elif [ $SHELL == "/usr/bin/bash" ]; then +elif [ $SHELL == "/usr/bin/bash" ] +then SHELLRC='.bashrc' logthis "BASH found"; else logthis "Unknown shell... defaulting to bash" SHELLRC='.bashrc' fi + logthis "Searching if rc is already there" grep "source $HOME/$HAK/rc" $HOME/$SHELLRC > /dev/null 2>&1 -if [ $? == 0 ]; then +if [ $? -eq 0 ] +then logthis "Already installed"; else echo "source $HOME/$HAK/rc" >> $HOME/$SHELLRC logthis "$HAK installed at $HOME and sourced it in $SHELLRC" source $HOME/$HAK/rc; fi -sh update.sh -sh ipfs-check-install-setup-init-update + +bash update.sh +bash ipfs-check-install-setup-init-update source ./config.sh source $HOME/$SHELLRC -sh init.sh +bash init.sh cd api npm i cd .. diff --git a/ipfs-check-install-setup-init-update b/ipfs-check-install-setup-init-update index b892768..4472417 100755 --- a/ipfs-check-install-setup-init-update +++ b/ipfs-check-install-setup-init-update @@ -20,7 +20,8 @@ _ak_ipfs_install(){ } which ipfs > /dev/null 2>&1 -if [ $? -ne 0 ]; then +if [ $? -ne 0 ] +then _ak_ipfs_download _ak_ipfs_install _ak_ipfs init @@ -29,7 +30,8 @@ else logit "INFO" "Found IPFS! Skipping downloading..." _ak_ipfs_swarm_install fi -if [ ! -d $HOME/.ipfs ]; then +if [ ! -d $AK_IPFS_REPO ] +then _ak_ipfs init _ak_ipfs_swarm_install fi diff --git a/podman/ContainerFile.alpine b/podman/ContainerFile.alpine index bdc763b..cb79e9d 100644 --- a/podman/ContainerFile.alpine +++ b/podman/ContainerFile.alpine @@ -1,6 +1,7 @@ FROM alpine:latest RUN apk update -q RUN apk upgrade -q && apk add bash which git screen pinentry -q +RUN bash COPY . /root/arching-kaos-tools RUN bash -c 'cd /root/arching-kaos-tools && /root/arching-kaos-tools/install.sh' RUN git config --global user.email "kaos@kaos.kaos" diff --git a/test_with_podman.sh b/test_with_podman.sh index aaa8c57..574c8ed 100755 --- a/test_with_podman.sh +++ b/test_with_podman.sh @@ -1,16 +1,35 @@ #!/bin/bash podman_dir="podman" now="$(date -u +%s)" -for file in $podman_dir/* -do - distro="$(printf "%s" "$file"|cut -d '.' -f 2)" - build_log="$now-podman-$distro-build_log" - printf "Building %s container..." "$distro" - podman build -f $file -t arching-kaos-tools-$distro . >> $build_log 2>&1 - if [ $? -ne 0 ] + +_build_container(){ + if [ ! -z $1 ] && [ -n "$1" ] then - printf "\tFailed!\n" - else - printf "\tSuccess!\n" + file="$podman_dir/ContainerFile.$1" + distro="$(printf "%s" "$file"|cut -d '.' -f 2)" + build_log="$now-podman-$distro-build_log" + printf "Building %s container..." "$distro" + podman build -f $file -t arching-kaos-tools-$distro . >> $build_log 2>&1 + if [ $? -ne 0 ] + then + printf "\tFailed!\n" + else + printf "\tSuccess!\n" + fi + tail -n 2 $build_log fi -done +} + +_build_all_containers(){ + for file in $podman_dir/* + do + _build_container "$(basename $file | cut -d '.' -f 2)" + done +} + +if [ ! -z $1 ] && [ -n "$1" ] +then + _build_container $1 +else + _build_all_containers +fi -- cgit v1.2.3