Commit 23a7d2a2 authored by Jondy Zhao's avatar Jondy Zhao

Let user press any key to exit after configure node or client

parent a3ca8db5
...@@ -77,7 +77,7 @@ Name: "{group}\SlapOS"; Filename: "{app}\cygwin\etc\slapos\desktop\index.html"; ...@@ -77,7 +77,7 @@ Name: "{group}\SlapOS"; Filename: "{app}\cygwin\etc\slapos\desktop\index.html";
Name: "{group}\Node Manager"; Filename: "{app}\cygwin\etc\slapos\node\index.html"; WorkingDir: "{app}\cygwin\etc\slapos\node"; IconFilename: "{app}\cygwin\etc\slapos\images\manager.ico"; Name: "{group}\Node Manager"; Filename: "{app}\cygwin\etc\slapos\node\index.html"; WorkingDir: "{app}\cygwin\etc\slapos\node"; IconFilename: "{app}\cygwin\etc\slapos\images\manager.ico";
Name: "{group}\Configure Client"; Filename: "{app}\cygwin\bin\bash.exe"; Parameters: "--login -i /etc/slapos/scripts/slapos-client-config.sh"; WorkingDir: "{app}\cygwin\etc\slapos\scripts"; IconFilename: "{app}\cygwin\etc\slapos\images\configure.ico"; Name: "{group}\Configure Client"; Filename: "{app}\cygwin\bin\bash.exe"; Parameters: "--login -i /etc/slapos/scripts/slapos-client-config.sh"; WorkingDir: "{app}\cygwin\etc\slapos\scripts"; IconFilename: "{app}\cygwin\etc\slapos\images\configure.ico";
Name: "{group}\Configure Node"; Filename: "{app}\cygwin\bin\bash.exe"; Parameters: "--login -i /etc/slapos/scripts/slapos-node-config.sh"; WorkingDir: "{app}\cygwin\etc\slapos\scripts"; IconFilename: "{app}\cygwin\etc\slapos\images\node.ico"; Name: "{group}\Configure Node"; Filename: "{app}\cygwin\bin\bash.exe"; Parameters: "--login -i /etc/slapos/scripts/slapos-node-config.sh"; WorkingDir: "{app}\cygwin\etc\slapos\scripts"; IconFilename: "{app}\cygwin\etc\slapos\images\node.ico";
Name: "{group}\Command Console"; Filename: "{app}\cygwin\bin\bash.exe"; Parameters: "--login -i /opt/slapos/bin/slapconsole /etc/opt/slapos/slapos.cfg"; WorkingDir: "{app}\cygwin\etc\slapos\scripts"; IconFilename: "{app}\cygwin\etc\slapos\images\terminal.ico"; Name: "{group}\Command Console"; Filename: "{app}\cygwin\bin\bash.exe"; Parameters: "--login -i -c ""/opt/slapos/bin/slapconsole /etc/opt/slapos/slapos.cfg"""; WorkingDir: "{app}\cygwin\etc\slapos\scripts"; IconFilename: "{app}\cygwin\etc\slapos\images\terminal.ico";
Name: "{group}\Update Center"; Filename: "{app}\cygwin\bin\bash.exe"; Parameters: "--login -i /etc/slapos/scripts/build-slapos.sh"; WorkingDir: "{app}\cygwin\etc\slapos\scripts"; IconFilename: "{app}\cygwin\etc\slapos\images\updater.ico"; Name: "{group}\Update Center"; Filename: "{app}\cygwin\bin\bash.exe"; Parameters: "--login -i /etc/slapos/scripts/build-slapos.sh"; WorkingDir: "{app}\cygwin\etc\slapos\scripts"; IconFilename: "{app}\cygwin\etc\slapos\images\updater.ico";
Name: "{group}\User Guide"; Filename: "{app}\user-guide.html"; Name: "{group}\User Guide"; Filename: "{app}\user-guide.html";
Name: "{group}\Read Me"; Filename: "{app}\Readme.txt"; Name: "{group}\Read Me"; Filename: "{app}\Readme.txt";
......
...@@ -4,9 +4,20 @@ ...@@ -4,9 +4,20 @@
# #
# Usage: # Usage:
# #
# ./slapos-client-config # ./slapos-client-config certificate_file key_file
# #
#
# Show error message and waiting for user to press any key quit
#
function show_error_exit()
{
msg=${1-Configure node failed.}
echo $msg
read -n 1 -t 15 -p "Press any key to exit..."
exit 1
}
slapos_client_home=~/.slapos slapos_client_home=~/.slapos
client_configure_file=$slapos_client_home/slapos.cfg client_configure_file=$slapos_client_home/slapos.cfg
client_certificate_file=$slapos_client_home/certificate client_certificate_file=$slapos_client_home/certificate
...@@ -32,7 +43,7 @@ if [[ -f "$1" ]] ; then ...@@ -32,7 +43,7 @@ if [[ -f "$1" ]] ; then
elif [[ ! -f $client_certificate_file ]] ; then elif [[ ! -f $client_certificate_file ]] ; then
read -p "Where is certificate file: " certificate_file read -p "Where is certificate file: " certificate_file
[[ ! -f "$certificate_file" ]] && \ [[ ! -f "$certificate_file" ]] && \
echo "Certificate file $certificate_file doesn't exists." && exit 1 show_error_exit "Certificate file $certificate_file doesn't exists."
echo "Copy certificate from $certificate_file to $client_certificate_file" echo "Copy certificate from $certificate_file to $client_certificate_file"
cp $certificate_file $client_certificate_file cp $certificate_file $client_certificate_file
fi fi
...@@ -43,7 +54,7 @@ if [[ -f "$2" ]] ; then ...@@ -43,7 +54,7 @@ if [[ -f "$2" ]] ; then
elif [[ ! -f $client_key_file ]] ; then elif [[ ! -f $client_key_file ]] ; then
read -p "Where is key file: " key_file read -p "Where is key file: " key_file
[[ ! -f "$key_file" ]] && \ [[ ! -f "$key_file" ]] && \
echo "Key file $key_file doesn't exists." && exit 1 show_error_exit "Key file $key_file doesn't exists."
echo "Copy key from $key_file to $client_key_file" echo "Copy key from $key_file to $client_key_file"
cp $key_file $client_key_file cp $key_file $client_key_file
fi fi
...@@ -51,10 +62,14 @@ fi ...@@ -51,10 +62,14 @@ fi
if [[ ! -f $client_configure_file ]] ; then if [[ ! -f $client_configure_file ]] ; then
[[ -f $template_configure_file ]] || \ [[ -f $template_configure_file ]] || \
(cd /etc/slapos; wget http://git.erp5.org/gitweb/slapos.core.git/blob_plain/HEAD:/slapos-client.cfg.example) || \ (cd /etc/slapos; wget http://git.erp5.org/gitweb/slapos.core.git/blob_plain/HEAD:/slapos-client.cfg.example) || \
(echo "Download slapos-client.cfg.example failed."; exit 1) show_error_exit "Download slapos-client.cfg.example failed."
cp $template_configure_file $client_configure_file cp $template_configure_file $client_configure_file
fi fi
sed -i -e "s%^cert_file.*$%cert_file = $client_certificate_file%" \ sed -i -e "s%^cert_file.*$%cert_file = $client_certificate_file%" \
-e "s%^key_file.*$%key_file = $client_key_file%" \ -e "s%^key_file.*$%key_file = $client_key_file%" \
$client_configure_file $client_configure_file
echo SlapOS Client configure successfully.
read -n -t 10 -p "Press any key to exit..."
exit 0
...@@ -77,6 +77,17 @@ function connection2guid() ...@@ -77,6 +77,17 @@ function connection2guid()
sed -e "s/^GUID\s*:\s*//" sed -e "s/^GUID\s*:\s*//"
} }
#
# Show error message and waiting for user to press any key quit
#
function show_error_exit()
{
msg=${1-Configure node failed.}
echo $msg
read -n 1 -t 15 -p "Press any key to exit..."
exit 1
}
node_certificate_file=/etc/opt/slapos/ssl/computer.crt node_certificate_file=/etc/opt/slapos/ssl/computer.crt
node_key_file=/etc/opt/slapos/ssl/computer.key node_key_file=/etc/opt/slapos/ssl/computer.key
node_config_file=/etc/opt/slapos/slapos.cfg node_config_file=/etc/opt/slapos/slapos.cfg
...@@ -98,8 +109,7 @@ if [[ ! " $original_connections " == *[\ ]$slapos_ifname[\ ]* ]] ; then ...@@ -98,8 +109,7 @@ if [[ ! " $original_connections " == *[\ ]$slapos_ifname[\ ]* ]] ; then
devcon install $WINDIR\\inf\\netloop.inf *MSLOOP devcon install $WINDIR\\inf\\netloop.inf *MSLOOP
connection_name=$(get_new_connection $original_connections) connection_name=$(get_new_connection $original_connections)
[[ "X$connection_name" == "X" ]] && \ [[ "X$connection_name" == "X" ]] && \
echo "Add msloop network adapter failed." && \ show_error_exit "Add msloop network adapter failed."
exit 1
echo echo
netsh interface set interface name="$connection_name" newname="$slapos_ifname" netsh interface set interface name="$connection_name" newname="$slapos_ifname"
fi fi
...@@ -128,7 +138,7 @@ else ...@@ -128,7 +138,7 @@ else
read -p "computer id: " computer_id read -p "computer id: " computer_id
fi fi
[[ "$computer_id" == COMP-+([0-9]) ]] || \ [[ "$computer_id" == COMP-+([0-9]) ]] || \
(echo "Invalid computer id specified."; exit 1) show_error_exit "Invalid computer id specified."
if [[ -f "$2" ]] ; then if [[ -f "$2" ]] ; then
echo "Copy certificate from $2 to $node_certificate_file" echo "Copy certificate from $2 to $node_certificate_file"
...@@ -136,7 +146,7 @@ if [[ -f "$2" ]] ; then ...@@ -136,7 +146,7 @@ if [[ -f "$2" ]] ; then
elif [[ ! -f $node_certificate_file ]] ; then elif [[ ! -f $node_certificate_file ]] ; then
read -p "Where is certificate file: " certificate_file read -p "Where is certificate file: " certificate_file
[[ ! -f "$certificate_file" ]] && \ [[ ! -f "$certificate_file" ]] && \
echo "Certificate file $certificate_file doesn't exists." && exit 1 show_error_exit "Certificate file $certificate_file doesn't exists."
echo "Copy certificate from $certificate_file to $node_certificate_file" echo "Copy certificate from $certificate_file to $node_certificate_file"
cp $certificate_file $node_certificate_file cp $certificate_file $node_certificate_file
fi fi
...@@ -147,7 +157,7 @@ if [[ -f "$3" ]] ; then ...@@ -147,7 +157,7 @@ if [[ -f "$3" ]] ; then
elif [[ ! -f $node_key_file ]] ; then elif [[ ! -f $node_key_file ]] ; then
read -p "Where is key file: " key_file read -p "Where is key file: " key_file
[[ ! -f "$key_file" ]] && \ [[ ! -f "$key_file" ]] && \
echo "Key file $key_file doesn't exists." && exit 1 show_error_exit "Key file $key_file doesn't exists."
echo "Copy key from $key_file to $node_key_file" echo "Copy key from $key_file to $node_key_file"
cp $key_file $node_key_file cp $key_file $node_key_file
fi fi
...@@ -164,7 +174,7 @@ ip -4 addr add $ipv4_local_network dev $slapos_ifname ...@@ -164,7 +174,7 @@ ip -4 addr add $ipv4_local_network dev $slapos_ifname
if [[ ! -f $node_config_file ]] ; then if [[ ! -f $node_config_file ]] ; then
[[ -f $node_template_file ]] || \ [[ -f $node_template_file ]] || \
(cd /etc/slapos; wget http://git.erp5.org/gitweb/slapos.core.git/blob_plain/HEAD:/slapos.cfg.example) || \ (cd /etc/slapos; wget http://git.erp5.org/gitweb/slapos.core.git/blob_plain/HEAD:/slapos.cfg.example) || \
(echo "Download slapos.cfg.example failed."; exit 1) show_error_exit "Download slapos.cfg.example failed."
cp $node_template_file $node_config_file cp $node_template_file $node_config_file
fi fi
...@@ -176,6 +186,16 @@ sed -i -e "s%^\\s*interface_name.*$%interface_name = $interface_guid%" \ ...@@ -176,6 +186,16 @@ sed -i -e "s%^\\s*interface_name.*$%interface_name = $interface_guid%" \
-e "s%^computer_id.*$%computer_id = $computer_id%" \ -e "s%^computer_id.*$%computer_id = $computer_id%" \
$node_config_file $node_config_file
# Config slapproxy
if [[ $(grep -q "^\[slapproxy\]" $node_config_file) ]] ; then
echo "
[slapproxy]
host = 127.0.0.1
port = 28080
database_uri = /var/lib/slapproxy.db
" >> $node_config_file
fi
# #
# Re6stnet # Re6stnet
# #
...@@ -230,7 +250,8 @@ cd /etc/re6stnet ...@@ -230,7 +250,8 @@ cd /etc/re6stnet
if [[ ! -f re6stnet.conf ]] ; then if [[ ! -f re6stnet.conf ]] ; then
re6st-conf --registry http://re6stnet.nexedi.com/ re6st-conf --registry http://re6stnet.nexedi.com/
fi fi
[[ ! -f re6stnet.conf ]] && echo "Register to nexedi re6stnet failed" && exit 1 [[ ! -f re6stnet.conf ]] && show_error_exit "Register to nexedi re6stnet failed"
grep -q "^table " re6stnet.conf || echo "table 0" >> re6stnet.conf
# #
# Add run item when windows startup # Add run item when windows startup
...@@ -246,6 +267,8 @@ echo "Add ${init_script}.sh as Windows startup item." ...@@ -246,6 +267,8 @@ echo "Add ${init_script}.sh as Windows startup item."
regtool -q set "$run_key\\$slapos_run_entry" \ regtool -q set "$run_key\\$slapos_run_entry" \
"\"$(cygpath -w /usr/bin/bash)\" --login -i ${init_script}.sh" || \ "\"$(cygpath -w /usr/bin/bash)\" --login -i ${init_script}.sh" || \
echo "Add startup item failed." show_error_exit "Add startup item failed."
echo SlapOS Node configure successfully.
read -n -t 10 -p "Press any key to exit..."
exit 0 exit 0
...@@ -70,7 +70,7 @@ Name: "{group}\SlapOS"; Filename: "{app}\cygwin\etc\slapos\desktop\index.html"; ...@@ -70,7 +70,7 @@ Name: "{group}\SlapOS"; Filename: "{app}\cygwin\etc\slapos\desktop\index.html";
Name: "{group}\Node Manager"; Filename: "{app}\cygwin\etc\slapos\node\index.html"; WorkingDir: "{app}\cygwin\etc\slapos\node"; IconFilename: "{app}\cygwin\etc\slapos\images\manager.ico"; Name: "{group}\Node Manager"; Filename: "{app}\cygwin\etc\slapos\node\index.html"; WorkingDir: "{app}\cygwin\etc\slapos\node"; IconFilename: "{app}\cygwin\etc\slapos\images\manager.ico";
Name: "{group}\Configure Client"; Filename: "{app}\cygwin\bin\bash.exe"; Parameters: "--login -i /etc/slapos/scripts/slapos-client-config.sh"; WorkingDir: "{app}\cygwin\etc\slapos\scripts"; IconFilename: "{app}\cygwin\etc\slapos\images\configure.ico"; Name: "{group}\Configure Client"; Filename: "{app}\cygwin\bin\bash.exe"; Parameters: "--login -i /etc/slapos/scripts/slapos-client-config.sh"; WorkingDir: "{app}\cygwin\etc\slapos\scripts"; IconFilename: "{app}\cygwin\etc\slapos\images\configure.ico";
Name: "{group}\Configure Node"; Filename: "{app}\cygwin\bin\bash.exe"; Parameters: "--login -i /etc/slapos/scripts/slapos-node-config.sh"; WorkingDir: "{app}\cygwin\etc\slapos\scripts"; IconFilename: "{app}\cygwin\etc\slapos\images\node.ico"; Name: "{group}\Configure Node"; Filename: "{app}\cygwin\bin\bash.exe"; Parameters: "--login -i /etc/slapos/scripts/slapos-node-config.sh"; WorkingDir: "{app}\cygwin\etc\slapos\scripts"; IconFilename: "{app}\cygwin\etc\slapos\images\node.ico";
Name: "{group}\Command Console"; Filename: "{app}\cygwin\bin\bash.exe"; Parameters: "--login -i /opt/slapos/bin/slapconsole /etc/opt/slapos/slapos.cfg"; WorkingDir: "{app}\cygwin\etc\slapos\scripts"; IconFilename: "{app}\cygwin\etc\slapos\images\terminal.ico"; Name: "{group}\Command Console"; Filename: "{app}\cygwin\bin\bash.exe"; Parameters: "--login -i -c ""/opt/slapos/bin/slapconsole /etc/opt/slapos/slapos.cfg"""; WorkingDir: "{app}\cygwin\etc\slapos\scripts"; IconFilename: "{app}\cygwin\etc\slapos\images\terminal.ico";
Name: "{group}\Update Center"; Filename: "{app}\cygwin\bin\bash.exe"; Parameters: "--login -i /etc/slapos/scripts/build-slapos.sh"; WorkingDir: "{app}\cygwin\etc\slapos\scripts"; IconFilename: "{app}\cygwin\etc\slapos\images\updater.ico"; Name: "{group}\Update Center"; Filename: "{app}\cygwin\bin\bash.exe"; Parameters: "--login -i /etc/slapos/scripts/build-slapos.sh"; WorkingDir: "{app}\cygwin\etc\slapos\scripts"; IconFilename: "{app}\cygwin\etc\slapos\images\updater.ico";
Name: "{group}\User Guide"; Filename: "{app}\user-guide.html"; Name: "{group}\User Guide"; Filename: "{app}\user-guide.html";
Name: "{group}\Read Me"; Filename: "{app}\Readme.txt"; Name: "{group}\Read Me"; Filename: "{app}\Readme.txt";
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment