Skip to content

Commit

Permalink
build: switch to runuser in buid_joininbox.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
openoms committed Sep 12, 2023
1 parent 35dbb59 commit 09d012b
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 16 deletions.
18 changes: 9 additions & 9 deletions build_joininbox.sh
Original file line number Diff line number Diff line change
Expand Up @@ -372,27 +372,27 @@ adduser --system --group --home /home/joinmarket joinmarket

echo "# clone the joininbox repo and copy the scripts"
cd /home/joinmarket || exit 1
sudo -u joinmarket git clone -b ${wantedBranch} https://github.com/${githubUser}/joininbox.git
runuser joinmarket -c "git clone -b ${wantedBranch} https://github.com/${githubUser}/joininbox.git"

# related issue: https://github.com/openoms/joininbox/issues/102
sudo -u joinmarket git config --global --add safe.directory /home/joinmarket/joininbox
runuser joinmarket -c "git config --global --add safe.directory /home/joinmarket/joininbox"

cd /home/joinmarket/joininbox || exit 1

if [ $# -lt 3 ] || [ "$3" = tag ]; then
# use the latest tag by default
tag=$(git tag | sort -V | tail -1)
# reset to the last release # be aware this is alphabetical (use one digit versions)
sudo -u joinmarket git reset --hard ${tag}
runuser joinmarket -c "git reset --hard ${tag}"
else
if [ $# -gt 2 ] && [ "$3" != commit ]; then
# reset to named commit if given
sudo -u joinmarket git reset --hard $3
runuser joinmarket -c "git reset --hard $3"
fi
fi

echo "# Checking which key signed the last commit"
lastCommit=$(sudo -u joinmarket git log --show-signature --oneline | head -n6)
lastCommit=$(runuser joinmarket -c "git log --show-signature --oneline | head -n6")
echo ${lastCommit}
if echo "${lastCommit}" | grep 13C688DB5B9C745DE4D2E4545BFB77609B081B65; then
PGPsigner="openoms"
Expand All @@ -408,8 +408,8 @@ else
exit 1
fi

command="sudo -u joinmarket bash /home/joinmarket/joininbox/scripts/verify.git.sh \
${PGPsigner} ${PGPpubkeyLink} ${PGPpubkeyFingerprint}"
command="runuser joinmarket -c \"/home/joinmarket/joininbox/scripts/verify.git.sh \
\"${PGPsigner}\" \"${PGPpubkeyLink}\" \"${PGPpubkeyFingerprint}\"\""
echo "running: ${command}"
chmod 777 /dev/shm
${command} || exit 1
Expand Down Expand Up @@ -607,7 +607,7 @@ echo "#########################"
echo "# Download Bitcoin Core"
echo "#########################"
echo
sudo -u joinmarket /home/joinmarket/install.bitcoincore.sh downloadCoreOnly || exit 1
runuser joinmarket -c "/home/joinmarket/install.bitcoincore.sh downloadCoreOnly" || exit 1

echo
echo "######################"
Expand All @@ -623,7 +623,7 @@ if [ "$4" = "without-qt" ]; then
qtgui="false"
sed -i "s/^qtgui=.*/qtgui=false/g" /home/joinmarket/joinin.conf
fi
sudo -u joinmarket /home/joinmarket/install.joinmarket.sh -i install -q $qtgui || exit 1
runuser joinmarket -c "/home/joinmarket/install.joinmarket.sh -i install -q $qtgui" || exit 1

echo "###################"
echo "# bootstrap.service"
Expand Down
19 changes: 12 additions & 7 deletions scripts/jam-remote/install.jam.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# https://github.com/joinmarket-webui/jam

USERNAME=jam
WEBUI_VERSION=0.1.5
WEBUI_VERSION="4d0479e"
REPO=joinmarket-webui/jam
HOME_DIR=/home/${USERNAME}
APP_DIR=webui
Expand Down Expand Up @@ -46,7 +46,7 @@ if [ "$1" = "on" ]; then

echo "# Creating the ${USERNAME} user"
echo
sudo adduser --disabled-password --gecos "" ${USERNAME}
sudo adduser --system --group --home /home/${USERNAME} ${USERNAME}

# install nodeJS
bash ${SOURCEDIR}/bonus.nodejs.sh on
Expand All @@ -57,10 +57,10 @@ if [ "$1" = "on" ]; then
sudo -u $USERNAME git clone https://github.com/$REPO

cd jam || exit 1
sudo -u $USERNAME git reset --hard v${WEBUI_VERSION}
sudo -u $USERNAME git reset --hard ${WEBUI_VERSION}

sudo -u $USERNAME bash ${SOURCEDIR}/../verify.git.sh \
"${PGPsigner}" "${PGPpubkeyLink}" "${PGPpubkeyFingerprint}" "v${WEBUI_VERSION}" || exit 1
#sudo -u $USERNAME bash ${SOURCEDIR}/../verify.git.sh \
# "${PGPsigner}" "${PGPpubkeyLink}" "${PGPpubkeyFingerprint}" "v${WEBUI_VERSION}" || exit 1

cd $HOME_DIR || exit 1
sudo -u $USERNAME mv jam $APP_DIR
Expand Down Expand Up @@ -134,10 +134,15 @@ if [ "$1" = "update" ]; then
echo "FAIL - npm install did not run correctly, aborting"
exit 1
fi

sudo -u $USERNAME npm run build
echo "*** JAM UPDATED to $version ***"
fi

if ! sudo -u $USERNAME npm install; then
echo "FAIL - npm install did not run correctly, aborting"
exit 1
fi
sudo -u $USERNAME npm run build

else
echo "*** JAM NOT INSTALLED ***"
fi
Expand Down

0 comments on commit 09d012b

Please sign in to comment.