11#! /usr/bin/env bash
22
3- global_path=" ` cd ..` "
4- exec_path=" /usr/bin/telemetry_service/"
5-
6- create_conf(option){
7- cat > " telemetry_${option} .service" << EOF
8- [Unit]
9- Description="Telemetry service"
10- After=multi-user.target
11- Conflicts=getty@tty1.service
12-
13- [Service]
14- Type=simple
15- ExecStart=/usr/bin/telemetry_service/telemetry_${option}
16- StandardInput=tty-force
17- Restart=always
3+ if [[" ` whoami` " -ne " root" ]] then
4+ echo " You are not root. Please retry."
5+ exit 0
6+ fi
187
19- [Install]
20- WantedBy=multi-user.target
21- exec_path="` cd ..` "
22- conf_path="/usr/bin/telemtry_service/telemetry.srvice"
23- EOF
248
25- cp " telemetry_ ${option} .service " " ${exec_path} / ${option} .service "
26- }
9+ global_path= " ` cd .. ` "
10+ exec_path= " /usr/bin/telemetry_service/ "
2711
2812
2913check_dependencies (){
@@ -48,7 +32,6 @@ setup_service(){
4832 if [$choice == " y" or $choice == " Y" ] then
4933 while true ; do
5034 read -p " Which config may I setup: Server or Client? (S/C for appropriate option)" choice
51-
5235 case $choice in
5336 " S" |" s" ) load_binary(" Server" ) && create_conf(" Server" );;
5437 " C" |" c" ) load_binary(" Client" ) && create_conf(" Client" );;
@@ -57,28 +40,85 @@ setup_service(){
5740 continue ;;
5841 esac
5942 done
43+ fi
44+ }
45+
6046
61- systemctl daemon-reload
47+ create_conf(option){
48+ cat > " telemetry_${option} .service" << EOF
49+ [Unit]
50+ Description="Telemetry service"
51+ After=multi-user.target
52+ Conflicts=getty@tty1.service
53+
54+ [Service]
55+ Type=simple
56+ ExecStart=/usr/bin/telemetry_service/telemetry_${option}
57+ StandardInput=tty-force
58+ Restart=always
6259
63- read -p " Would want you to autorun telemtry service? (y/n or another key)" choice
60+ [Install]
61+ WantedBy=multi-user.target
62+ exec_path="` cd ..` "
63+ conf_path="/usr/bin/telemtry_service/telemetry_${option} .srvice"
64+ EOF
6465
65- if [$choice == " y" or $choice == " Y" ] then
66- systemctl enable telemetry.service
67- else break
68- fi
66+ cp " telemetry_${option} .service" " ${exec_path} /telemetry_${option} .service"
6967
70- systemctl start telemetry.service
71- systemctl status telemetry.service
68+ read -p " Would want you to autorun telemtry service? (y/n or another key)" choice
7269
73- else break
70+ if [$choice == " y" or $choice == " Y" ] then
71+ systemctl enable telemetry.service
72+ else break
73+ fi
74+
75+ read -p " Should service start now? (y/n or another key)" choice
76+
77+ if [$choice == " y" or $choice == " Y" ] then
78+
79+ systemctl start telemetry_${option} .service
80+ systemctl status telemetry_${option} .service
81+ else
82+ echo " You always can do that using next command:\" systemctl start telemetry_${option} .service\" "
7483 fi
84+ systemctl daemon-reload
7585}
7686
7787
7888gen_ciphers (){
7989 cd " $( pwd) /cryptkeys"
80- openssl genpkey -algorithm ed25519 -out ed25519-priv-key.pem
81- openssl pkey -in ed25519key.pem -pubout
90+ openssl ecparam -name c2tnb191v3 -out X9_62.pem
91+ openssl ecparam -in X9_62.pem -genkey -noout -out X9_62-key.pem
92+ openssl ecparam -in X9_62.pem -text -param_enc explicit -noout
93+
94+ openssl req -x509 -new -SHA384 -nodes -key X9_62-key.pem 3650 -out X9_62-cert.pem
95+ openssl x509 -req -SHA384 -extfile v3.ext -days 365 -in X9_62-cert.pem -CA ca.crt -CAkey X9_62-key.pem -CAcreateserial -out X9_62-cert.pem
96+ openssl req -in X9_62-cert.pem -noout -text
97+
98+ openssl ec -in X9_62-key.pem -pubout -out X9_62-pub.pem
99+
100+ # openssl genpkey -algorithm ed25519 -out ed25519-priv-key.pem
101+ # openssl pkey -in ed25519key.pem -pubout
102+ # read -p "Few details are necessary for certificate creating. Please enter CN: " CN
103+ # read -p "Also I need cert owner email: " email
104+ # read -p "And last enter your email (example@service.com): " email
105+ # cat >> "${exec_path}/cryptkeys/openssl.cnf"<< EOF
106+ # [ req ]
107+ # prompt = no
108+ # encrypt_key = no
109+ # default_md = sha512
110+ # distinguished_name = dname
111+ # req_extensions = reqext
112+
113+ # [ dname ]
114+ # CN = ${CN}
115+ # emailAddress = ${email}
116+ #
117+ # [ reqext ]
118+ # subjectAltName = ${altname}
119+ # EOF
120+ # openssl req -new -config openssl.cnf -key privkey.pem -out csr.pem
121+ # openssl req -in csr.pem -noout -text -verify
82122}
83123
84124
0 commit comments