-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathconfigure
More file actions
113 lines (92 loc) · 2.47 KB
/
configure
File metadata and controls
113 lines (92 loc) · 2.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
#!/bin/bash
set -e
# check root
if [ ! "$(id -u)" == "0" ]; then
echo "must be root to run install script"
exit 1
fi
# install requirements that pip needs
apt-get install libleveldb1v5 libleveldb-dev
# source directory
source_dir=$(cd "$(dirname "${BASH_SOURCE[0]}" )"; pwd)
uwallet_config="/etc/uwallet.conf"
function read_config()
{
text=$1
echo `grep -e ^$text $uwallet_config |awk -F\= '{print $2}' | tail -n 1| tr -d ' '`
}
function write_config()
{
sed -i -s "s#$1 =.*#$1 = $2#" $uwallet_config
}
# create config file
if [ ! -f $uwallet_config ]; then
echo "Creating config file"
cp $source_dir"/uwallet.conf.sample" $uwallet_config
fi
# read username
user=$(read_config "username")
if ! [ "$user" ]; then
read -p "username for running daemon (default: uwallet) " -r
if [ $REPLY ]; then
user=$REPLY
else
user="uwallet"
fi
write_config "username" $user
fi
# create user
if ! id -u $user; then
echo "adding user $user"
sudo adduser $user --disabled-password
echo "$user hard nofile 65536" >> /etc/security/limits.conf
echo "$user soft nofile 65536" >> /etc/security/limits.conf
fi
# read path from config
default_path="/var/uwallet-server"
path=$(read_config "path")
if ! [ "$path" ]; then
read -p "Path for database (default: $default_path) " -r
if [ $REPLY ]; then
path=$REPLY
else
path=$default_path
fi
write_config "path" $default_path
fi
mkdir -p $path
# read path from config
default_logfile="/var/log/uwallet.log"
logfile=$(read_config "logfile")
if ! [ "$logfile" ]; then
read -p "Path of logfile (default: $default_logfile) " -r
if [ $REPLY ]; then
logfile=$REPLY
else
logfile=$default_logfile
fi
write_config "logfile" $default_logfile
fi
# set owner
chown -R $user $path
# create log file
logfile=$(read_config "logfile")
if ! [ -f $logfile ]; then
touch $logfile
fi
chown $user $logfile
unetd_user=$(read_config "ulordd_user")
if ! [ "$ulordd_user" ]; then
read -p "rpcuser (from your ulord.conf file): " -r
write_config "ulordd_user" $REPLY
fi
unetd_password=$(read_config "ulordd_password")
if ! [ "$ulordd_password" ]; then
read -p "rpcpassword (from your ulord.conf file): " -r
write_config "ulordd_password" $REPLY
fi
# finish
echo "Configuration written to $uwallet_config."
echo "Please edit this file to finish the configuration."
echo "If you have not done so, please run 'python setup.py install'"
echo "Then, run 'uwallet-server' to start the daemon"