aboutsummaryrefslogtreecommitdiff
path: root/lib/_ak_cjdns
diff options
context:
space:
mode:
authorkaotisk <kaotisk@arching-kaos.org>2024-12-28 15:59:04 +0200
committerkaotisk <kaotisk@arching-kaos.org>2024-12-28 15:59:04 +0200
commit89d00fcbc75e128cba516009db100daec4b794a9 (patch)
tree9e98d87d9fef51a06d830ef2dd659cdc6fed2fb4 /lib/_ak_cjdns
parent756db3cbdb91d2cb4773dd16aec3b54d1a52c462 (diff)
downloadarching-kaos-tools-89d00fcbc75e128cba516009db100daec4b794a9.tar.gz
arching-kaos-tools-89d00fcbc75e128cba516009db100daec4b794a9.tar.bz2
arching-kaos-tools-89d00fcbc75e128cba516009db100daec4b794a9.zip
Diffstat (limited to 'lib/_ak_cjdns')
-rwxr-xr-xlib/_ak_cjdns37
1 files changed, 18 insertions, 19 deletions
diff --git a/lib/_ak_cjdns b/lib/_ak_cjdns
index 30229ca..69e5ffc 100755
--- a/lib/_ak_cjdns
+++ b/lib/_ak_cjdns
@@ -25,7 +25,7 @@ cjdns_src_git_repo_url="https://github.com/cjdelisle/cjdns"
cjdnstoolspath="$HOME/cjdns/tools"
cargo_env="$HOME/.cargo/env"
-_ak_cjdns_check_availability(){
+function _ak_cjdns_check_availability(){
declare -a cjdns_bins=("cjdroute" "makekeys" "mkpasswd" "privatetopublic" "publictoip6" "randombytes" "sybilsim")
for cbin in "${cjdns_bins[@]}"
do
@@ -40,19 +40,20 @@ _ak_cjdns_check_availability(){
done
}
-_ak_cargo_rust_check_install(){
- if [ ! -f $cargo_env ]
+function _ak_cargo_rust_check_install(){
+ if [ ! -f ${cargo_env} ]
then
- curl --proto '=https' --tlsv1.2 -sSf $rust_sh_install_url | sh
+ curl --proto '=https' --tlsv1.2 -sSf ${rust_sh_install_url} | sh
fi
- source $cargo_env
+ source ${cargo_env}
}
-_ak_cjdns_install(){
+function _ak_cjdns_install(){
_ak_cargo_rust_check_install
- git clone $cjdns_src_git_repo_url
+ git clone ${cjdns_src_git_repo_url}
+ cjdns_install_script="./do"
cd cjdns
- sh do
+ sh ${cjdns_install_script}
if [ $? -ne 0 ]
then
_ak_log_error "Failed to compile cjdns"
@@ -66,25 +67,24 @@ _ak_cjdns_install(){
sudo cp cjdns/target/release/publictoip6 /usr/bin/publictoip6
sudo cp cjdns/target/release/randombytes /usr/bin/randombytes
sudo cp cjdns/target/release/sybilsim /usr/bin/sybilsim
- ln -s "$(realpath cjdns/tools/dumpLinks)" $HOME/.arching-kaos/bin/dumpLinks
- ln -s "$(realpath cjdns/tools/cexec)" $HOME/.arching-kaos/bin/cjdns-cexec
- ln -s "$(realpath cjdns/tools/peerStats)" $HOME/.arching-kaos/bin/peerStats
+ ln -s "$(realpath cjdns/tools/dumpLinks)" ${HOME}/.arching-kaos/bin/dumpLinks
+ ln -s "$(realpath cjdns/tools/cexec)" ${HOME}/.arching-kaos/bin/cjdns-cexec
+ ln -s "$(realpath cjdns/tools/peerStats)" ${HOME}/.arching-kaos/bin/peerStats
which systemctl 2> /dev/null 1>&2
if [ $? -ne 0 ]
then
_ak_log_error "Systemctl not found... TODO"
else
- sudo cp "$(realpath cjdns/contrib/systemd/cjdns.service)" /etc/systemd/system/cjdns.service
- sudo cp "$(realpath cjdns/contrib/systemd/cjdns-resume.service)" /etc/systemd/system/cjdns-resume.service
+ sudo cp cjdns/contrib/systemd/cjdns.service /etc/systemd/system/cjdns.service
+ sudo cp cjdns/contrib/systemd/cjdns-resume.service /etc/systemd/system/cjdns-resume.service
sudo systemctl enable --now cjdns.service
fi
}
-_ak_cjdns_read_peers_to_vars_with_jq(){
+function _ak_cjdns_read_peers_to_vars_with_jq(){
totalpeers="$(jq '. | length' < $peersfile)"
number="0"
interface="0"
-
while [ $number -lt $totalpeers ]
do
address="$(jq -r '.['$number'].address' < $peersfile)"
@@ -103,7 +103,7 @@ _ak_cjdns_read_peers_to_vars_with_jq(){
done
}
-_ak_cjdns_read_peers_to_vars_natively(){
+function _ak_cjdns_read_peers_to_vars_natively(){
number=-1
cat $peersfile | tr -d $'\n' | sed -e 's/]$/\n/g' | tr -d ' ' | sed -e 's/"//g; s/,/,\n/g; s/}//g; s/,//g' | while read line
do
@@ -150,8 +150,7 @@ _ak_cjdns_read_peers_to_vars_natively(){
rm peerfile
}
-
-_ak_cjdns_connect_peers(){
+function _ak_cjdns_connect_peers(){
_ak_network_cjdns_connect
exit $?
#
@@ -187,7 +186,7 @@ _ak_cjdns_connect_peers(){
fi
}
-_ak_cjdns_get_ip(){
+function _ak_cjdns_get_ip(){
which ip > /dev/null 2>&1
if [ $? -ne 0 ]
then