mirror of
https://github.com/aljazceru/cyphernode.git
synced 2026-01-31 10:14:35 +01:00
Fixed permissions when using current user
This commit is contained in:
15
dist/setup.sh
vendored
15
dist/setup.sh
vendored
@@ -127,7 +127,7 @@ sudo_if_required() {
|
||||
}
|
||||
|
||||
modify_permissions() {
|
||||
local directories=("$BITCOIN_DATAPATH" "$LIGHTNING_DATAPATH" "$PROXY_DATAPATH" "$GATEKEEPER_DATAPATH" "$OTSCLIENT_DATAPATH" "$POSTGRES_DATAPATH" "$LOGS_DATAPATH" "$TRAEFIK_DATAPATH" "$TOR_DATAPATH")
|
||||
local directories=("$current_path/apps" "$BITCOIN_DATAPATH" "$LIGHTNING_DATAPATH" "$PROXY_DATAPATH" "$GATEKEEPER_DATAPATH" "$OTSCLIENT_DATAPATH" "$POSTGRES_DATAPATH" "$LOGS_DATAPATH" "$TRAEFIK_DATAPATH" "$TOR_DATAPATH")
|
||||
for d in "${directories[@]}"
|
||||
do
|
||||
if [[ -e $d ]]; then
|
||||
@@ -139,7 +139,7 @@ modify_permissions() {
|
||||
}
|
||||
|
||||
modify_owner() {
|
||||
local directories=("$BITCOIN_DATAPATH" "$LIGHTNING_DATAPATH" "$PROXY_DATAPATH" "$GATEKEEPER_DATAPATH" "$OTSCLIENT_DATAPATH" "$POSTGRES_DATAPATH" "$LOGS_DATAPATH" "$TRAEFIK_DATAPATH" "$TOR_DATAPATH")
|
||||
local directories=("$current_path/apps" "$BITCOIN_DATAPATH" "$LIGHTNING_DATAPATH" "$PROXY_DATAPATH" "$GATEKEEPER_DATAPATH" "$OTSCLIENT_DATAPATH" "$POSTGRES_DATAPATH" "$LOGS_DATAPATH" "$TRAEFIK_DATAPATH" "$TOR_DATAPATH")
|
||||
local user=$(id -u $RUN_AS_USER):$(id -g $RUN_AS_USER)
|
||||
for d in "${directories[@]}"
|
||||
do
|
||||
@@ -669,7 +669,7 @@ install_docker() {
|
||||
|
||||
check_directory_owner() {
|
||||
# if one directory does not have access rights for $RUN_AS_USER, we echo 1, else we echo 0
|
||||
local directories=("$BITCOIN_DATAPATH" "$LIGHTNING_DATAPATH" "$PROXY_DATAPATH" "$GATEKEEPER_DATAPATH" "$POSTGRES_DATAPATH" "$LOGS_DATAPATH" "$TRAEFIK_DATAPATH" "$TOR_DATAPATH")
|
||||
local directories=("$current_path/apps" "$BITCOIN_DATAPATH" "$LIGHTNING_DATAPATH" "$PROXY_DATAPATH" "$GATEKEEPER_DATAPATH" "$POSTGRES_DATAPATH" "$LOGS_DATAPATH" "$TRAEFIK_DATAPATH" "$TOR_DATAPATH")
|
||||
local status=0
|
||||
for d in "${directories[@]}"
|
||||
do
|
||||
@@ -773,7 +773,7 @@ sanity_checks_pre_install() {
|
||||
if [[ $sudo_reason == 'directories' ]]; then
|
||||
echo " [31mor check your data volumes if they have the right owner.[0m"
|
||||
echo " [31mThe owner of the following folders should be '$RUN_AS_USER':[0m"
|
||||
local directories=("$BITCOIN_DATAPATH" "$LIGHTNING_DATAPATH" "$PROXY_DATAPATH" "$GATEKEEPER_DATAPATH" "$POSTGRES_DATAPATH" "$LOGS_DATAPATH" "$TRAEFIK_DATAPATH" "$TOR_DATAPATH")
|
||||
local directories=("$current_path/apps" "$BITCOIN_DATAPATH" "$LIGHTNING_DATAPATH" "$PROXY_DATAPATH" "$GATEKEEPER_DATAPATH" "$POSTGRES_DATAPATH" "$LOGS_DATAPATH" "$TRAEFIK_DATAPATH" "$TOR_DATAPATH")
|
||||
local status=0
|
||||
for d in "${directories[@]}"
|
||||
do
|
||||
@@ -781,8 +781,8 @@ sanity_checks_pre_install() {
|
||||
echo " [31m$d[0m"
|
||||
fi
|
||||
done
|
||||
|
||||
fi
|
||||
|
||||
exit
|
||||
else
|
||||
SUDO_REQUIRED=1
|
||||
@@ -797,8 +797,7 @@ install_apps() {
|
||||
local user=$(id -u $RUN_AS_USER):$(id -g $RUN_AS_USER)
|
||||
local apps_repo="https://github.com/SatoshiPortal/cypherapps.git"
|
||||
echo " [32mclone[0m $apps_repo into apps"
|
||||
docker run --rm -v "$current_path":/git --entrypoint git cyphernode/cyphernodeconf:$CONF_VERSION clone --single-branch -b ${CYPHERAPPS_VERSION} "$apps_repo" /git/apps > /dev/null 2>&1
|
||||
sudo_if_required chown -R $user $current_path/apps
|
||||
docker run --rm -u $user -v "$current_path":/git --entrypoint git cyphernode/cyphernodeconf:$CONF_VERSION clone --single-branch -b ${CYPHERAPPS_VERSION} "$apps_repo" /git/apps > /dev/null 2>&1
|
||||
next
|
||||
fi
|
||||
|
||||
@@ -962,9 +961,9 @@ if [[ $INSTALL == 1 ]]; then
|
||||
sanity_checks_pre_install
|
||||
create_user
|
||||
install
|
||||
install_apps
|
||||
modify_owner
|
||||
modify_permissions
|
||||
install_apps
|
||||
if [[ ! $AUTOSTART == 1 ]]; then
|
||||
cowsay
|
||||
fi
|
||||
|
||||
@@ -91,6 +91,7 @@ testbatching() {
|
||||
id=$(echo "${response}" | jq ".result[0].batcherId")
|
||||
trace 3 "[testbatching] batcherId=${id}"
|
||||
if [ "${id}" -ne "1" ]; then
|
||||
trace 1 "\n\n[testbatching] ${On_IRed}${BBlack} Failed! ${Color_Off}\n"
|
||||
exit 10
|
||||
fi
|
||||
trace 2 "\n\n[testbatching] ${BCyan}Tested listbatchers.${Color_Off}\n"
|
||||
@@ -102,6 +103,7 @@ testbatching() {
|
||||
data=$(echo "${response}" | jq -r ".result.batcherLabel")
|
||||
trace 3 "[testbatching] batcherLabel=${data}"
|
||||
if [ "${data}" != "default" ]; then
|
||||
trace 1 "\n\n[testbatching] ${On_IRed}${BBlack} Failed! ${Color_Off}\n"
|
||||
exit 20
|
||||
fi
|
||||
|
||||
@@ -110,6 +112,7 @@ testbatching() {
|
||||
data=$(echo "${response}" | jq -r ".result.batcherLabel")
|
||||
trace 3 "[testbatching] batcherLabel=${data}"
|
||||
if [ "${data}" != "default" ]; then
|
||||
trace 1 "\n\n[testbatching] ${On_IRed}${BBlack} Failed! ${Color_Off}\n"
|
||||
exit 25
|
||||
fi
|
||||
trace 2 "\n\n[testbatching] ${BCyan}Tested getbatcher.${Color_Off}\n"
|
||||
@@ -121,10 +124,12 @@ testbatching() {
|
||||
data=$(echo "${response}" | jq -r ".result.batcherLabel")
|
||||
trace 3 "[testbatching] batcherLabel=${data}"
|
||||
if [ "${data}" != "default" ]; then
|
||||
trace 1 "\n\n[testbatching] ${On_IRed}${BBlack} Failed! ${Color_Off}\n"
|
||||
exit 30
|
||||
fi
|
||||
echo "${response}" | jq -e ".result.outputs"
|
||||
if [ "$?" -ne 0 ]; then
|
||||
trace 1 "\n\n[testbatching] ${On_IRed}${BBlack} Failed! ${Color_Off}\n"
|
||||
exit 32
|
||||
fi
|
||||
|
||||
@@ -133,10 +138,12 @@ testbatching() {
|
||||
data=$(echo "${response}" | jq -r ".result.batcherLabel")
|
||||
trace 3 "[testbatching] batcherLabel=${data}"
|
||||
if [ "${data}" != "default" ]; then
|
||||
trace 1 "\n\n[testbatching] ${On_IRed}${BBlack} Failed! ${Color_Off}\n"
|
||||
exit 35
|
||||
fi
|
||||
echo "${response}" | jq -e ".result.outputs"
|
||||
if [ "$?" -ne 0 ]; then
|
||||
trace 1 "\n\n[testbatching] ${On_IRed}${BBlack} Failed! ${Color_Off}\n"
|
||||
exit 37
|
||||
fi
|
||||
trace 2 "\n\n[testbatching] ${BCyan}Tested getbatchdetails.${Color_Off}\n"
|
||||
@@ -150,10 +157,12 @@ testbatching() {
|
||||
id=$(echo "${response}" | jq ".result.batcherId")
|
||||
trace 3 "[testbatching] batcherId=${id}"
|
||||
if [ "${id}" -ne "1" ]; then
|
||||
trace 1 "\n\n[testbatching] ${On_IRed}${BBlack} Failed! ${Color_Off}\n"
|
||||
exit 40
|
||||
fi
|
||||
id=$(echo "${response}" | jq -e ".result.outputId")
|
||||
if [ "$?" -ne 0 ]; then
|
||||
trace 1 "\n\n[testbatching] ${On_IRed}${BBlack} Failed! ${Color_Off}\n"
|
||||
exit 42
|
||||
fi
|
||||
trace 3 "[testbatching] outputId=${id}"
|
||||
@@ -165,10 +174,12 @@ testbatching() {
|
||||
id2=$(echo "${response}" | jq ".result.batcherId")
|
||||
trace 3 "[testbatching] batcherId=${id2}"
|
||||
if [ "${id2}" -ne "1" ]; then
|
||||
trace 1 "\n\n[testbatching] ${On_IRed}${BBlack} Failed! ${Color_Off}\n"
|
||||
exit 47
|
||||
fi
|
||||
id2=$(echo "${response}" | jq -e ".result.outputId")
|
||||
if [ "$?" -ne 0 ]; then
|
||||
trace 1 "\n\n[testbatching] ${On_IRed}${BBlack} Failed! ${Color_Off}\n"
|
||||
exit 50
|
||||
fi
|
||||
trace 3 "[testbatching] outputId=${id2}"
|
||||
@@ -180,6 +191,7 @@ testbatching() {
|
||||
trace 3 "[testbatching] response=${response}"
|
||||
echo "${response}" | jq -e ".error"
|
||||
if [ "$?" -ne 0 ]; then
|
||||
trace 1 "\n\n[testbatching] ${On_IRed}${BBlack} Failed! ${Color_Off}\n"
|
||||
exit 55
|
||||
fi
|
||||
trace 2 "\n\n[testbatching] ${BCyan}Tested batchspend.${Color_Off}\n"
|
||||
@@ -199,6 +211,7 @@ testbatching() {
|
||||
id=$(echo "${response}" | jq ".result.batcherId")
|
||||
trace 3 "[testbatching] batcherId=${id}"
|
||||
if [ "${id}" -ne "1" ]; then
|
||||
trace 1 "\n\n[testbatching] ${On_IRed}${BBlack} Failed! ${Color_Off}\n"
|
||||
exit 60
|
||||
fi
|
||||
|
||||
@@ -207,6 +220,7 @@ testbatching() {
|
||||
id=$(echo "${response}" | jq ".result.batcherId")
|
||||
trace 3 "[testbatching] batcherId=${id}"
|
||||
if [ "${id}" -ne "1" ]; then
|
||||
trace 1 "\n\n[testbatching] ${On_IRed}${BBlack} Failed! ${Color_Off}\n"
|
||||
exit 64
|
||||
fi
|
||||
trace 2 "\n\n[testbatching] ${BCyan}Tested removefrombatch.${Color_Off}\n"
|
||||
@@ -218,6 +232,7 @@ testbatching() {
|
||||
data2=$(echo "${response}" | jq ".result.nbOutputs")
|
||||
trace 3 "[testbatching] nbOutputs=${data2}"
|
||||
if [ "${data2}" -ne "$((${data}-2))" ]; then
|
||||
trace 1 "\n\n[testbatching] ${On_IRed}${BBlack} Failed! ${Color_Off}\n"
|
||||
exit 68
|
||||
fi
|
||||
trace 2 "\n\n[testbatching] ${BCyan}Tested getbatchdetails.${Color_Off}\n"
|
||||
@@ -230,6 +245,7 @@ testbatching() {
|
||||
trace 3 "[testbatching] response=${response}"
|
||||
id=$(echo "${response}" | jq -e ".result.batcherId")
|
||||
if [ "$?" -ne "0" ]; then
|
||||
trace 1 "\n\n[testbatching] ${On_IRed}${BBlack} Failed! ${Color_Off}\n"
|
||||
exit 70
|
||||
fi
|
||||
|
||||
@@ -240,6 +256,7 @@ testbatching() {
|
||||
id=$(echo "${response}" | jq '.result[] | select(.batcherLabel == "testbatcher") | .batcherId')
|
||||
trace 3 "[testbatching] batcherId=${id}"
|
||||
if [ -z "${id}" ]; then
|
||||
trace 1 "\n\n[testbatching] ${On_IRed}${BBlack} Failed! ${Color_Off}\n"
|
||||
exit 75
|
||||
fi
|
||||
trace 2 "\n\n[testbatching] ${BCyan}Tested listbatchers.${Color_Off}\n"
|
||||
@@ -251,6 +268,7 @@ testbatching() {
|
||||
data=$(echo "${response}" | jq -r ".result.batcherLabel")
|
||||
trace 3 "[testbatching] batcherLabel=${data}"
|
||||
if [ "${data}" != "testbatcher" ]; then
|
||||
trace 1 "\n\n[testbatching] ${On_IRed}${BBlack} Failed! ${Color_Off}\n"
|
||||
exit 80
|
||||
fi
|
||||
|
||||
@@ -259,6 +277,7 @@ testbatching() {
|
||||
data=$(echo "${response}" | jq -r ".result.batcherId")
|
||||
trace 3 "[testbatching] batcherId=${data}"
|
||||
if [ "${data}" != "${id}" ]; then
|
||||
trace 1 "\n\n[testbatching] ${On_IRed}${BBlack} Failed! ${Color_Off}\n"
|
||||
exit 90
|
||||
fi
|
||||
trace 2 "\n\n[testbatching] ${BCyan}Tested getbatcher.${Color_Off}\n"
|
||||
@@ -270,10 +289,12 @@ testbatching() {
|
||||
data=$(echo "${response}" | jq -r ".result.batcherId")
|
||||
trace 3 "[testbatching] batcherId=${data}"
|
||||
if [ "${data}" != "${id}" ]; then
|
||||
trace 1 "\n\n[testbatching] ${On_IRed}${BBlack} Failed! ${Color_Off}\n"
|
||||
exit 100
|
||||
fi
|
||||
echo "${response}" | jq -e ".result.outputs"
|
||||
if [ "$?" -ne 0 ]; then
|
||||
trace 1 "\n\n[testbatching] ${On_IRed}${BBlack} Failed! ${Color_Off}\n"
|
||||
exit 110
|
||||
fi
|
||||
|
||||
@@ -282,10 +303,12 @@ testbatching() {
|
||||
data=$(echo "${response}" | jq -r ".result.batcherLabel")
|
||||
trace 3 "[testbatching] batcherLabel=${data}"
|
||||
if [ "${data}" != "testbatcher" ]; then
|
||||
trace 1 "\n\n[testbatching] ${On_IRed}${BBlack} Failed! ${Color_Off}\n"
|
||||
exit 120
|
||||
fi
|
||||
echo "${response}" | jq -e ".result.outputs"
|
||||
if [ "$?" -ne 0 ]; then
|
||||
trace 1 "\n\n[testbatching] ${On_IRed}${BBlack} Failed! ${Color_Off}\n"
|
||||
exit 130
|
||||
fi
|
||||
trace 2 "\n\n[testbatching] ${BCyan}Tested getbatchdetails.${Color_Off}\n"
|
||||
@@ -299,10 +322,12 @@ testbatching() {
|
||||
data=$(echo "${response}" | jq ".result.batcherId")
|
||||
trace 3 "[testbatching] batcherId=${data}"
|
||||
if [ "${data}" -ne "${id}" ]; then
|
||||
trace 1 "\n\n[testbatching] ${On_IRed}${BBlack} Failed! ${Color_Off}\n"
|
||||
exit 140
|
||||
fi
|
||||
id2=$(echo "${response}" | jq -e ".result.outputId")
|
||||
if [ "$?" -ne 0 ]; then
|
||||
trace 1 "\n\n[testbatching] ${On_IRed}${BBlack} Failed! ${Color_Off}\n"
|
||||
exit 142
|
||||
fi
|
||||
trace 3 "[testbatching] outputId=${id2}"
|
||||
@@ -314,10 +339,12 @@ testbatching() {
|
||||
data=$(echo "${response}" | jq ".result.batcherId")
|
||||
trace 3 "[testbatching] batcherId=${data}"
|
||||
if [ "${data}" -ne "${id}" ]; then
|
||||
trace 1 "\n\n[testbatching] ${On_IRed}${BBlack} Failed! ${Color_Off}\n"
|
||||
exit 150
|
||||
fi
|
||||
id2=$(echo "${response}" | jq -e ".result.outputId")
|
||||
if [ "$?" -ne 0 ]; then
|
||||
trace 1 "\n\n[testbatching] ${On_IRed}${BBlack} Failed! ${Color_Off}\n"
|
||||
exit 152
|
||||
fi
|
||||
trace 3 "[testbatching] outputId=${id2}"
|
||||
@@ -329,11 +356,13 @@ testbatching() {
|
||||
trace 3 "[testbatching] response=${response}"
|
||||
data2=$(echo "${response}" | jq -e ".result.txid")
|
||||
if [ "$?" -ne 0 ]; then
|
||||
trace 1 "\n\n[testbatching] ${On_IRed}${BBlack} Failed! ${Color_Off}\n"
|
||||
exit 160
|
||||
fi
|
||||
trace 3 "[testbatching] txid=${data2}"
|
||||
data=$(echo "${response}" | jq ".result.outputs | length")
|
||||
if [ "${data}" -ne "2" ]; then
|
||||
if [ "${data}" -lt "2" ]; then
|
||||
trace 1 "\n\n[testbatching] ${On_IRed}${BBlack} Failed! ${Color_Off}\n"
|
||||
exit 162
|
||||
fi
|
||||
trace 2 "\n\n[testbatching] ${BCyan}Tested batchspend.${Color_Off}\n"
|
||||
@@ -345,7 +374,8 @@ testbatching() {
|
||||
trace 3 "[testbatching] response=${response}"
|
||||
data=$(echo "${response}" | jq ".result.nbOutputs")
|
||||
trace 3 "[testbatching] nbOutputs=${data}"
|
||||
if [ "${data}" -ne "2" ]; then
|
||||
if [ "${data}" -lt "2" ]; then
|
||||
trace 1 "\n\n[testbatching] ${On_IRed}${BBlack} Failed! ${Color_Off}\n"
|
||||
exit 170
|
||||
fi
|
||||
trace 2 "\n\n[testbatching] ${BCyan}Tested getbatchdetails.${Color_Off}\n"
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
. ./colors.sh
|
||||
|
||||
# You need jq installed for these tests to run correctly
|
||||
# You need to configure cyphernode with a default xpub for these tests to work.
|
||||
|
||||
# This will test:
|
||||
#
|
||||
@@ -130,7 +131,7 @@ tests_derive() {
|
||||
# real 0m 18.15s
|
||||
# user 0m 0.00s
|
||||
# sys 0m 0.00s
|
||||
#
|
||||
#
|
||||
# Deriving 500 addresses with derivepubpath_bitcoind (Bitcoin Core)...
|
||||
# real 0m 0.64s
|
||||
# user 0m 0.00s
|
||||
|
||||
Reference in New Issue
Block a user