echo"You've chosen one of the free subdomains. Checking availability..."
if curl --fail--silent"https://dyndns.yunohost.org/test/$domain"
then
domain_available=true
else
echo
echo"$domain is not available. Please choose another domain"
echo"You can either use your own custom domain, or freely use a subdomain under one of the following doamains:"
echo" .nohost.me"
echo" .noho.st"
echo" .ynh.fr"
echo"i.e.: example.nohost.me"
read domain
fi
else# own domain
domain_available=true
fi
if (! $domain_available )
then
echo
echo "$domain is not available. Please choose another domain"
echo "You can either use your own custom domain, or freely use a subdomain under one of the following doamains:"
echo " .nohost.me"
echo " .noho.st"
echo " .ynh.fr"
echo "i.e.: example.nohost.me"
read domain
fi
done
echo
echo"Username (used to connect to the user interface and access your apps, must be composed of lowercase letters and numbers only)"
echo"i.e.: jonsnow"
read username
while [ "$username" == "" ] # TODO: test with regex
while[[-z$username]]# TODO: test with regex
do
echo"Please provide a username (used to connect to the user interface and access your apps, must be composed of lowercase letters and numbers only)"
echo"i.e.: jonsnow"
...
...
@@ -104,7 +105,7 @@ function get_hypercube_file() {
echo"Firstname (mandatory, used as your firstname when you send emails)"
echo"i.e.: Jon"
read firstname
while [ "$firstname" == "" ]
while[[-z$firstname]]# TODO: check if there are constraints (min length, etc.)
do
echo"Please provide a firstname (mandatory, used as your firstname when you send emails)"
echo"i.e.: Jon"
...
...
@@ -115,7 +116,7 @@ function get_hypercube_file() {
echo"Lastname (mandatory, used as your lastname when you send emails)"
echo"i.e. Snow"
read lastname
while [ "$lastname" == "" ]
while[[-z$lastname]]# TODO: check if there are constraints (min length, etc.)
do
echo"Please provide a lastname (mandatory, used as your lastname when you send emails)"
echo"i.e. Snow"
...
...
@@ -123,24 +124,25 @@ function get_hypercube_file() {
done
echo
echo "user password (Use a strong password!)"
echo "see https://ssd.eff.org/en/module/creating-strong-passwords for advice"
read -s user_pwd
echo"User password (Use a strong password!)"
echo"See https://ssd.eff.org/en/module/creating-strong-passwords for advice"
read-s user_pwd# TODO: check if there are constranits (emptiness, min length, etc.), maybe ask twice the password
echo
echo "admin password (Use a strong password! This will access the admin screen of your internetcube)"
echo "see https://ssd.eff.org/en/module/creating-strong-passwords for advice"
read -s admin_pwd
echo"Admin password (Use a strong password! This will access the admin screen of your internetcube)"
echo"See https://ssd.eff.org/en/module/creating-strong-passwords for advice"
read-s admin_pwd# TODO: check if there are constraints (emptiness, min length, etc.), maybe ask twice the password
# The following should be automated
# TODO: The following should be automated
# See https://github.com/Neutrinet/scripts/tree/master/vpn for inspiration
# We could download the configuration package from the web interface?
echo
echo"You will now need to enter your neutrinet vpn certificates and credentials"
echo"If you want to reuse certificates from a previous install, you can find everything on that cube as user.crt, user.key, ca-server.crt and credentials in /etc/openvpn/keys"
echo"If you do not have an account yet, please see https://wiki.neutrinet.be/vpn/order"
echo
echo"VPN client certificate (paste all the content of client.crt below and end with a blank line): "
vpn_client_crt=$(sed '/^$/q' | sed '/^$/d')
vpn_client_crt=$(sed'/^$/q' | sed'/^$/d')# TODO: figure out this black magic
echo
echo"VPN client key (paste all the content of client.key below and end with a blank line): "
vpn_client_key=$(sed'/^$/q' | sed'/^$/d')
...
...
@@ -160,11 +162,11 @@ function get_hypercube_file() {
echo
echo"WiFi hotspot name"
echo"i.e.: MyWunderbarNeutralNetwork"
read wifi_ssid
read wifi_ssid# TODO: check if there are constraints + emptiness
echo
echo"WiFi hotspot password"
echo"i.e.: MyWunderbarNeutralNetwork"
read -s wifi_pwd
read-s wifi_pwd# TODO: check if there are constraints + emptiness
echo
create_hypercubefile
...
...
@@ -177,6 +179,10 @@ function create_hypercubefile() {
# Make template file
hypercubefile="install.hypercube"
vpn_client_crt="${vpn_client_crt//$'\n'/\|}"
vpn_client_key="${vpn_client_key//$'\n'/\|}"
vpn_ca_crt="${vpn_ca_crt//$'\n'/\|}"
cat>$hypercubefile<<EOF
{
"vpnclient": {
...
...
@@ -185,12 +191,12 @@ function create_hypercubefile() {
"server_proto": "udp",
"ip6_net": "",
"ip4_addr": "",
"crt_server_ca": "VPN_CA_CRT",
"crt_client": "VPN_CLIENT_CRT",
"crt_client_key": "VPN_CLIENT_KEY",
"crt_server_ca": "$vpn_ca_crt",
"crt_client": "$vpn_client_crt",
"crt_client_key": "$vpn_client_key",
"crt_client_ta": "",
"login_user": "VPN_USERNAME",
"login_passphrase": "VPN_PWD",
"login_user": "$vpn_username",
"login_passphrase": "$vpn_pwd",
"dns0": "89.234.141.66",
"dns1": "2001:913::8",
"openvpn_rm": [
...
...
@@ -204,8 +210,8 @@ function create_hypercubefile() {
]
},
"hotspot": {
"wifi_ssid": "WIFI_SSID",
"wifi_passphrase": "WIFI_PWD",
"wifi_ssid": "$wifi_ssid",
"wifi_passphrase": "$wifi_pwd",
"ip6_net": "",
"ip6_dns0": "2001:913::8",
"ip6_dns1": "2001:910:800::40",
...
...
@@ -215,41 +221,19 @@ function create_hypercubefile() {
"firmware_nonfree": "no"
},
"yunohost": {
"domain": "DOMAIN",
"password": "ADMIN_PWD",
"user": "USERNAME",
"user_firstname": "FIRSTNAME",
"user_lastname": "LASTNAME",
"user_password": "USER_PWD"
"domain": "$domain",
"password": "$admin_pwd",
"user": "$username",
"user_firstname": "$firstname",
"user_lastname": "$lastname",
"user_password": "$user_pwd"
},
"unix": {
"root_password": "ADMIN_PWD",
"root_password": "$admin_pwd",
"lang": "en"
}
}
EOF
# Prepare vars to replace in file
vpn_client_crt="${vpn_client_crt//$'\n'/\\|}"
vpn_client_key="${vpn_client_key//$'\n'/\\|}"
vpn_ca_crt="${vpn_ca_crt//$'\n'/\\|}"
# Replace vars in file
sed -i "s~\"VPN_CLIENT_CRT\"~\"$vpn_client_crt\"~" $hypercubefile
sed -i "s~\"VPN_CLIENT_KEY\"~\"$vpn_client_key\"~" $hypercubefile
sed -i "s~\"VPN_CA_CRT\"~\"$vpn_ca_crt\"~" $hypercubefile
sed -i "s/VPN_USERNAME/$vpn_username/g" $hypercubefile
sed -i "s/VPN_PWD/$vpn_pwd/g" $hypercubefile
sed -i "s/WIFI_SSID/$wifi_ssid/g" $hypercubefile
sed -i "s/WIFI_PWD/$wifi_pwd/g" $hypercubefile
sed -i "s/DOMAIN/$domain/g" $hypercubefile
sed -i "s/USERNAME/$username/g" $hypercubefile
sed -i "s/FIRSTNAME/$firstname/g" $hypercubefile
sed -i "s/LASTNAME/$lastname/g" $hypercubefile
sed -i "s/USER_PWD/$user_pwd/g" $hypercubefile
sed -i "s/ADMIN_PWD/$admin_pwd/g" $hypercubefile
echo"install.hypercube created"
}
...
...
@@ -257,7 +241,7 @@ function get_image() {
echo
echo"What hardware are you installing on? lime/lime2"
# error if no image is found. Alternative is to use a fallback. We can also first check the folder from where it's executed. If there's a correct file there=>ask to use that one? No gpg check needed then. What if multiple images are found?
# check gpg (download it and check it during flashing with the install-sd.sh script)
echo "downloading $board image"
curl -#o "$image.zip" "$YNH_IMG_LOCATION/$image.zip" # This should have the -s option instead of -# if we make it async