Skip to content

Commit fdbd1b1

Browse files
authored
Linux install cleanup (#15)
* Prompt systemd users for service install option. * Rename appsettings before copy, restart service if already installed.
1 parent 84d8fcd commit fdbd1b1

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

install.sh

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,13 @@
11
#!/usr/bin/env bash
2+
service_exists() {
3+
local n=$1
4+
if [[ $(systemctl list-units --all -t service --full --no-legend "$n.service" | cut -f1 -d' ') == $n.service ]]; then
5+
return 0
6+
else
7+
return 1
8+
fi
9+
}
10+
211
echo Beginning cypher node install
312
tmp_dir=$(mktemp -d -t ci-XXXXXXXXXX)
413
echo "Temporary directory ${tmp_dir} created"
@@ -11,6 +20,9 @@ echo "Extracting $tmp_dir/cypher.zip"
1120

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

23+
# Rename appsettings.json to appsettings.default.json
24+
mv $tmp_dir/cypher/appsettings.json $tmp_dir/cypher/appsettings.default.json
25+
1426
if [ ! -d $HOME/.cypher ]
1527
then
1628
echo "Creating $HOME/.cypher"
@@ -39,6 +51,25 @@ echo "Cleaning up temporary directory ${tmp_dir}"
3951

4052
rm -rf $tmp_dir
4153

54+
if [ -d "/run/systemd/system/" ]
55+
then
56+
if ! service_exists cypnode; then
57+
echo "cypnode.service not detected"
58+
59+
while true; do
60+
read -p "Would you like to install cynode as a service?" yn
61+
case $yn in
62+
[Yy]* ) curl -s https://raw.githubusercontent.com/cypher-network/cypher/$version/create-service.sh | bash; break;;
63+
[Nn]* ) break;;
64+
* ) echo "Please answer yes or no.";;
65+
esac
66+
done
67+
else
68+
echo "cynode.service already installed, restarting..."
69+
systemctl restart cypnode.service
70+
fi
71+
fi
72+
4273
if grep -q "$HOME/.cypher/bin" ~/.profile
4374
then
4475
:

0 commit comments

Comments
 (0)