Skip to content

Commit

Permalink
Linux install cleanup (#15)
Browse files Browse the repository at this point in the history
* Prompt systemd users for service install option.

* Rename appsettings before copy, restart service if already installed.
  • Loading branch information
0xn3bs committed Jan 24, 2021
1 parent 84d8fcd commit fdbd1b1
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions install.sh
@@ -1,4 +1,13 @@
#!/usr/bin/env bash
service_exists() {
local n=$1
if [[ $(systemctl list-units --all -t service --full --no-legend "$n.service" | cut -f1 -d' ') == $n.service ]]; then
return 0
else
return 1
fi
}

echo Beginning cypher node install
tmp_dir=$(mktemp -d -t ci-XXXXXXXXXX)
echo "Temporary directory ${tmp_dir} created"
Expand All @@ -11,6 +20,9 @@ echo "Extracting $tmp_dir/cypher.zip"

unzip -o $tmp_dir/cypher.zip -d $tmp_dir/cypher

# Rename appsettings.json to appsettings.default.json
mv $tmp_dir/cypher/appsettings.json $tmp_dir/cypher/appsettings.default.json

if [ ! -d $HOME/.cypher ]
then
echo "Creating $HOME/.cypher"
Expand Down Expand Up @@ -39,6 +51,25 @@ echo "Cleaning up temporary directory ${tmp_dir}"

rm -rf $tmp_dir

if [ -d "/run/systemd/system/" ]
then
if ! service_exists cypnode; then
echo "cypnode.service not detected"

while true; do
read -p "Would you like to install cynode as a service?" yn
case $yn in
[Yy]* ) curl -s https://raw.githubusercontent.com/cypher-network/cypher/$version/create-service.sh | bash; break;;
[Nn]* ) break;;
* ) echo "Please answer yes or no.";;
esac
done
else
echo "cynode.service already installed, restarting..."
systemctl restart cypnode.service
fi
fi

if grep -q "$HOME/.cypher/bin" ~/.profile
then
:
Expand Down

0 comments on commit fdbd1b1

Please sign in to comment.