Commit b36f860d authored by Jondy Zhao's avatar Jondy Zhao

slapos-configure:

  add santify check
  add option --computer-certificate
  add option --computer-key
  add option --client-certificate
  add option --client-key
  use ${var_name} format the code
parent 382bf24d
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
# #
function show_usage() function show_usage()
{ {
echo "" echo ""
echo "Usage:" echo "Usage:"
echo "" echo ""
echo " ./slapos-configure [options] [action] [configure item]" echo " ./slapos-configure [options] [action] [configure item]"
...@@ -34,6 +34,11 @@ function show_usage() ...@@ -34,6 +34,11 @@ function show_usage()
echo " -U, --user=XXX slapos administrator, default is slaproot" echo " -U, --user=XXX slapos administrator, default is slaproot"
echo " -P, --password=XXX password of administrator" echo " -P, --password=XXX password of administrator"
echo "" echo ""
echo " --computer-certificate=FILENAME"
echo " --computer-key=FILENAME"
echo " --client-certificate=FILENAME"
echo " --client-key=FILENAME"
echo ""
echo " The action option:" echo " The action option:"
echo "" echo ""
echo " --install Install only when the item hasn't been installed" echo " --install Install only when the item hasn't been installed"
...@@ -62,6 +67,10 @@ echo "" ...@@ -62,6 +67,10 @@ echo ""
# ----------------------------------------------------------- # -----------------------------------------------------------
declare _administrator=${slapos_user} declare _administrator=${slapos_user}
declare _password= declare _password=
declare _computer_certificate=
declare _computer_key=
declare _client_certificate=
declare _client_key=
# ----------------------------------------------------------- # -----------------------------------------------------------
# Command line options # Command line options
...@@ -73,7 +82,7 @@ while test $# -gt 0; do ...@@ -73,7 +82,7 @@ while test $# -gt 0; do
*) optarg= ;; *) optarg= ;;
esac esac
case "$1" in case "$1" in
--password=*) --password=*)
_password=$optarg _password=$optarg
;; ;;
...@@ -88,6 +97,18 @@ while test $# -gt 0; do ...@@ -88,6 +97,18 @@ while test $# -gt 0; do
_administrator=$2 _administrator=$2
shift shift
;; ;;
--computer-certificate=*)
_computer_certificate=$optarg
;;
--computer-key=*)
_computer_key=$optarg
;;
--client-certificate=*)
_client_certificate=$optarg
;;
--client-key=*)
_client_key=$optarg
;;
*) *)
show_usage show_usage
exit 1 exit 1
...@@ -108,19 +129,20 @@ if [[ ! ":$PATH" == :/opt/slapos/bin: ]] ; then ...@@ -108,19 +129,20 @@ if [[ ! ":$PATH" == :/opt/slapos/bin: ]] ; then
echo "export PATH=/opt/slapos/bin:\${PATH}" >> $profile echo "export PATH=/opt/slapos/bin:\${PATH}" >> $profile
done done
fi fi
# cygrunsrv
# ssh-host-config csih_check_program_or_error /usr/bin/cygrunsrv cygserver
# syslog-ng-config csih_check_program_or_error /usr/bin/ssh-host-config ssh
# openssl csih_check_program_or_error /usr/bin/syslog-ng-config syslog-ng
# export WINDIR csih_check_program_or_error /usr/bin/openssl openssl
# ipwin csih_check_program_or_error /usr/bin/ipwin slapos-patches
# slapos_cron_config csih_check_program_or_error /usr/bin/slapos_cron_config slapos-patches
[[ -z "$WINDIR" ]] && csih_error "missing environment variable WINDIR"
# ----------------------------------------------------------- # -----------------------------------------------------------
# Create paths # Create paths
# ----------------------------------------------------------- # -----------------------------------------------------------
mkdir -p /etc/opt/slapos/ssl/partition_pki mkdir -p /etc/opt/slapos/ssl/partition_pki
mkdir -p $slapos_client_home mkdir -p ${slapos_client_home}
mkdir -p /opt/slapos/log mkdir -p /opt/slapos/log
mkdir -p /opt/download-cache mkdir -p /opt/download-cache
mkdir -p /opt/downloads mkdir -p /opt/downloads
...@@ -133,7 +155,7 @@ mkdir -p /etc/re6stnet ...@@ -133,7 +155,7 @@ mkdir -p /etc/re6stnet
# Start seclogon service in the Windows XP # Start seclogon service in the Windows XP
if csih_is_xp ; then if csih_is_xp ; then
echo "Set start property of seclogon to auto" echo "Set start property of seclogon to auto"
sc config seclogon start= auto || sc config seclogon start= auto ||
csih_warning "failed to set seclogon to auto start." csih_warning "failed to set seclogon to auto start."
# In the later, it's RunAs service, and will start by default # In the later, it's RunAs service, and will start by default
fi fi
...@@ -179,18 +201,18 @@ else ...@@ -179,18 +201,18 @@ else
fi fi
check_cygwin_service sshd check_cygwin_service sshd
# Use slapos-cron-config to configure slapos cron service. # Use slapos-cron-config to configure slapos cron service.
if ! cygrunsrv --query cron > /dev/null 2>&1 ; then if ! cygrunsrv --query cron > /dev/null 2>&1 ; then
[[ -x $slapos_cron_config ]] || [[ -x ${slapos_cron_config} ]] ||
csih_error "Couldn't find slapos cron config script: $slapos_cron_config" csih_error "Couldn't find slapos cron config script: ${slapos_cron_config}"
if [[ -z "${csih_PRIVILEGED_PASSWORD}" ]] ; then if [[ -z "${csih_PRIVILEGED_PASSWORD}" ]] ; then
slapos_request_password ${_administrator} "Install cron service need the password of ${_administrator}." slapos_request_password ${_administrator} "Install cron service need the password of ${_administrator}."
fi fi
echo Run slapos-cron-config ... echo Run slapos-cron-config ...
$slapos_cron_config ${_administrator} ${csih_PRIVILEGED_PASSWORD} || ${slapos_cron_config} ${_administrator} ${csih_PRIVILEGED_PASSWORD} ||
csih_error "Failed to run $slapos_cron_config" csih_error "Failed to run ${slapos_cron_config}"
else else
echo The cron service has been installed. echo The cron service has been installed.
fi fi
...@@ -206,12 +228,12 @@ echo ...@@ -206,12 +228,12 @@ echo
echo echo
echo Starting configure slapos network ... echo Starting configure slapos network ...
echo echo
if ! netsh interface ipv6 show interface | grep -q "\\b$slapos_ifname\\b" ; then if ! netsh interface ipv6 show interface | grep -q "\\b${slapos_ifname}\\b" ; then
echo Installing slapos network adapter ... echo Installing slapos network adapter ...
ipwin install $WINDIR\\inf\\netloop.inf *msloop ${slapos_ifname} ipwin install $WINDIR\\inf\\netloop.inf *msloop ${slapos_ifname}
fi fi
ip -4 addr add $(echo ${ipv4_local_network} | sed -e "s%\.0/%.1/%g") dev $slapos_ifname ip -4 addr add $(echo ${ipv4_local_network} | sed -e "s%\.0/%.1/%g") dev ${slapos_ifname}
# reset_connection $slapos_ifname # reset_connection ${slapos_ifname}
echo echo
echo Configure slapos network OK. echo Configure slapos network OK.
echo echo
...@@ -235,11 +257,11 @@ echo ...@@ -235,11 +257,11 @@ echo
echo echo
echo Starting configure section config ... echo Starting configure section config ...
echo echo
[[ -r $node_template_file && -r $client_template_file ]] || \ [[ -r ${node_template_file} && -r ${client_template_file} ]] || \
create_template_configure_file || \ create_template_configure_file || \
csih_error "Failed to create template configure file." csih_error "Failed to create template configure file."
sed -i -e "/^alias/,\$d" $client_template_file sed -i -e "/^alias/,\$d" ${client_template_file}
echo "alias = echo "alias =
apache_frontend http://git.erp5.org/gitweb/slapos.git/blob_plain/refs/heads/cygwin-share:/software/apache-frontend/software.cfg apache_frontend http://git.erp5.org/gitweb/slapos.git/blob_plain/refs/heads/cygwin-share:/software/apache-frontend/software.cfg
erp5 http://git.erp5.org/gitweb/slapos.git/blob_plain/refs/tags/slapos-0.143:/software/erp5/software.cfg erp5 http://git.erp5.org/gitweb/slapos.git/blob_plain/refs/tags/slapos-0.143:/software/erp5/software.cfg
...@@ -248,59 +270,63 @@ echo "alias = ...@@ -248,59 +270,63 @@ echo "alias =
slaposwebrunner http://git.erp5.org/gitweb/slapos.git/blob_plain/refs/heads/cygwin-share:/software/slaprunner-lite/software.cfg slaposwebrunner http://git.erp5.org/gitweb/slapos.git/blob_plain/refs/heads/cygwin-share:/software/slaprunner-lite/software.cfg
wordpress http://git.erp5.org/gitweb/slapos.git/blob_plain/refs/heads/cygwin-share:/software/wordpress/software.cfg wordpress http://git.erp5.org/gitweb/slapos.git/blob_plain/refs/heads/cygwin-share:/software/wordpress/software.cfg
netdrive_reporter http://git.erp5.org/gitweb/slapos.git/blob_plain/refs/heads/cygwin-share:/software/netdrive-reporter/software.cfg" \ netdrive_reporter http://git.erp5.org/gitweb/slapos.git/blob_plain/refs/heads/cygwin-share:/software/netdrive-reporter/software.cfg" \
>> $client_template_file >> ${client_template_file}
if [[ ! -f $node_certificate_file ]] ; then if [[ ! -f ${node_certificate_file} ]] ; then
read -p "Where is computer certificate file $(cygpath -w /computer.crt): " filename _filename=${_computer_certificate}
[[ -z "$filename" ]] && filename="/computer.crt" [[ -z "${_filename}" ]] &&
[[ ! -r "$filename" ]] && \ read -p "Where is computer certificate file $(cygpath -w /computer.crt): " _filename
csih_error "Computer certificate file $filename doesn't exists." [[ -z "${_filename}" ]] && _filename="/computer.crt"
echo "Copy certificate from $filename to $node_certificate_file" [[ ! -r "${_filename}" ]] && \
filename=$(cygpath -u $filename) csih_error "Computer certificate file ${_filename} doesn't exists."
cp $filename $node_certificate_file echo "Copy certificate from ${_filename} to ${node_certificate_file}"
_filename=$(cygpath -u ${_filename})
cp ${_filename} ${node_certificate_file}
else else
echo "Found computer certificate file: $node_certificate_file" echo "Found computer certificate file: ${node_certificate_file}"
fi fi
openssl x509 -noout -in $node_certificate_file || \ openssl x509 -noout -in ${node_certificate_file} || \
csih_error "Invalid computer certificate: $node_certificate_file." csih_error "Invalid computer certificate: ${node_certificate_file}."
if [[ ! -f $node_key_file ]] ; then if [[ ! -f ${node_key_file} ]] ; then
read -p "Where is computer key file $(cygpath -w /computer.key): " filename _filename=${_computer_key}
[[ -z "$filename" ]] && filename="/computer.key" [[ -z "${_filename}" ]] &&
[[ ! -f "$filename" ]] && \ read -p "Where is computer key file $(cygpath -w /computer.key): " _filename
csih_error "Key file $filename doesn't exists." [[ -z "${_filename}" ]] && _filename="/computer.key"
echo "Copy key from $filename to $node_key_file" [[ ! -f "${_filename}" ]] && \
filename=$(cygpath -u $filename) csih_error "Key file ${_filename} doesn't exists."
cp $filename $node_key_file echo "Copy key from ${_filename} to ${node_key_file}"
_filename=$(cygpath -u ${_filename})
cp ${_filename} ${node_key_file}
else else
echo "Found computer key file: $node_key_file" echo "Found computer key file: ${node_key_file}"
fi fi
openssl rsa -noout -in $node_key_file -check || openssl rsa -noout -in ${node_key_file} -check ||
csih_error "Invalid node key: $node_key_file." csih_error "Invalid node key: ${node_key_file}."
if [[ ! -f $node_configure_file ]] ; then if [[ ! -f ${node_configure_file} ]] ; then
echo "Copy computer configure file from $node_template_file to $node_configure_file" echo "Copy computer configure file from ${node_template_file} to ${node_configure_file}"
cp $node_template_file $node_configure_file cp ${node_template_file} ${node_configure_file}
fi fi
interface_guid=$(ipwin guid *msloop $slapos_ifname) || interface_guid=$(ipwin guid *msloop ${slapos_ifname}) ||
csih_error "Failed to get guid of interface: $slapos_ifname." csih_error "Failed to get guid of interface: ${slapos_ifname}."
[[ "$interface_guid" == {*-*-*-*} ]] || [[ "$interface_guid" == {*-*-*-*} ]] ||
csih_error "Invalid interface guid $interface_guid specified." csih_error "Invalid interface guid $interface_guid specified."
computer_guid=$(grep "CN=COMP" $node_certificate_file | \ computer_guid=$(grep "CN=COMP" ${node_certificate_file} | \
sed -e "s/^.*, CN=//g" | sed -e "s%/emailAddress.*\$%%g") sed -e "s/^.*, CN=//g" | sed -e "s%/emailAddress.*\$%%g")
[[ "$computer_guid" == COMP-+([0-9]) ]] || [[ "$computer_guid" == COMP-+([0-9]) ]] ||
csih_error "Invalid computer id '$computer_guid' specified." csih_error "Invalid computer id '$computer_guid' specified."
echo "Computer configuration information:" echo "Computer configuration information:"
echo " interface name: $slapos_ifname" echo " interface name: ${slapos_ifname}"
echo " GUID: $interface_guid" echo " GUID: $interface_guid"
echo " ipv4_local_network: $ipv4_local_network" echo " ipv4_local_network: $ipv4_local_network"
echo " computer_id: $computer_guid" echo " computer_id: $computer_guid"
echo echo
echo " If ipv4_local_network confilcts with your local network, change it" echo " If ipv4_local_network confilcts with your local network, change it"
echo " in the file: $node_configure_file " echo " in the file: ${node_configure_file} "
echo " Or change it in the $(dirname $0)/slapos-include.sh" echo " Or change it in the $(dirname $0)/slapos-include.sh"
echo " and run Configure SlapOS again." echo " and run Configure SlapOS again."
...@@ -308,43 +334,47 @@ sed -i -e "s%^\\s*interface_name.*$%interface_name = $interface_guid%" \ ...@@ -308,43 +334,47 @@ sed -i -e "s%^\\s*interface_name.*$%interface_name = $interface_guid%" \
-e "s%^#\?\\s*ipv6_interface.*$%# ipv6_interface =%g" \ -e "s%^#\?\\s*ipv6_interface.*$%# ipv6_interface =%g" \
-e "s%^ipv4_local_network.*$%ipv4_local_network = $ipv4_local_network%" \ -e "s%^ipv4_local_network.*$%ipv4_local_network = $ipv4_local_network%" \
-e "s%^computer_id.*$%computer_id = $computer_guid%" \ -e "s%^computer_id.*$%computer_id = $computer_guid%" \
$node_configure_file ${node_configure_file}
if [[ ! -f $client_certificate_file ]] ; then if [[ ! -f ${client_certificate_file} ]] ; then
read -p "Where is client certificate file $(cygpath -w /certificate): " filename _filename=${_client_certificate}
[[ -z "$filename" ]] && filename="/certificate" [[ -z "${_filename}" ]] &&
[[ ! -f "$filename" ]] && \ read -p "Where is client certificate file $(cygpath -w /certificate): " _filename
csih_error "Client certificate file $filename doesn't exists." [[ -z "${_filename}" ]] && _filename="/certificate"
echo "Copy client certificate from $filename to $client_certificate_file" [[ ! -f "${_filename}" ]] && \
filename=$(cygpath -u $filename) csih_error "Client certificate file ${_filename} doesn't exists."
cp $filename $client_certificate_file echo "Copy client certificate from ${_filename} to ${client_certificate_file}"
_filename=$(cygpath -u ${_filename})
cp ${_filename} ${client_certificate_file}
fi fi
openssl x509 -noout -in $client_certificate_file || \ openssl x509 -noout -in ${client_certificate_file} || \
csih_error "Invalid client certificate: $client_certificate_file." csih_error "Invalid client certificate: ${client_certificate_file}."
if [[ ! -f $client_key_file ]] ; then if [[ ! -f ${client_key_file} ]] ; then
read -p "Where is client key file $(cygpath -w /key): " filename _filename=${_client_key}
[[ -z "$filename" ]] && filename="/key" [[ -z "${_filename}" ]] &&
[[ ! -f "$filename" ]] && \ read -p "Where is client key file $(cygpath -w /key): " _filename
csih_error "Key file $filename doesn't exists." [[ -z "${_filename}" ]] && _filename="/key"
echo "Copy client key from $filename to $client_key_file" [[ ! -f "${_filename}" ]] && \
filename=$(cygpath -u $filename) csih_error "Key file ${_filename} doesn't exists."
cp $filename $client_key_file echo "Copy client key from ${_filename} to ${client_key_file}"
_filename=$(cygpath -u ${_filename})
cp ${_filename} ${client_key_file}
fi fi
openssl rsa -noout -in $client_key_file -check || \ openssl rsa -noout -in ${client_key_file} -check || \
csih_error "Invalid client key: $client_key_file." csih_error "Invalid client key: ${client_key_file}."
if [[ ! -f $client_configure_file ]] ; then if [[ ! -f ${client_configure_file} ]] ; then
echo "Copy client configure file from $client_template_file to $client_configure_file" echo "Copy client configure file from ${client_template_file} to ${client_configure_file}"
cp $client_template_file $client_configure_file cp ${client_template_file} ${client_configure_file}
fi fi
echo "Client configuration information:" echo "Client configuration information:"
echo " client certificate file: $client_certificate_file" echo " client certificate file: ${client_certificate_file}"
echo " client key file: $client_key_file" echo " client key file: ${client_key_file}"
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 echo
echo Configure section config OK. echo Configure section config OK.
echo echo
...@@ -358,11 +388,11 @@ echo ...@@ -358,11 +388,11 @@ echo
echo Checking miniupnpc ... echo Checking miniupnpc ...
if [[ ! -d /opt/miniupnpc ]] ; then if [[ ! -d /opt/miniupnpc ]] ; then
package=/opt/downloads/miniupnpc.tar.gz _filename=/opt/downloads/miniupnpc.tar.gz
[[ -r $package ]] || csih_error "No package found: $package" [[ -r ${_filename} ]] || csih_error "No package found: ${_filename}"
echo "Installing miniupnpc ..." echo "Installing miniupnpc ..."
cd /opt cd /opt
tar xzf $package --no-same-owner tar xzf ${_filename} --no-same-owner
mv $(ls -d miniupnpc-*) miniupnpc mv $(ls -d miniupnpc-*) miniupnpc
cd miniupnpc cd miniupnpc
make make
...@@ -374,11 +404,11 @@ fi ...@@ -374,11 +404,11 @@ fi
echo Checking pyOpenSSL ... echo Checking pyOpenSSL ...
if [[ ! -d /opt/pyOpenSSL ]] ; then if [[ ! -d /opt/pyOpenSSL ]] ; then
package=/opt/downloads/pyOpenSSL.tar.gz _filename=/opt/downloads/pyOpenSSL.tar.gz
[[ -r $package ]] || csih_error "No package found: $package" [[ -r ${_filename} ]] || csih_error "No package found: ${_filename}"
echo "Installing pyOpenSSL ..." echo "Installing pyOpenSSL ..."
cd /opt cd /opt
tar xzf $package --no-same-owner tar xzf ${_filename} --no-same-owner
mv $(ls -d pyOpenSSL-*) pyOpenSSL mv $(ls -d pyOpenSSL-*) pyOpenSSL
cd pyOpenSSL cd pyOpenSSL
python setup.py install || csih_error "Failed ot install pyOpenSSL." python setup.py install || csih_error "Failed ot install pyOpenSSL."
...@@ -390,10 +420,10 @@ fi ...@@ -390,10 +420,10 @@ fi
echo Checking re6stnet ... echo Checking re6stnet ...
if [[ ! -d /opt/re6stnet ]] ; then if [[ ! -d /opt/re6stnet ]] ; then
echo "Installing re6stnet ..." echo "Installing re6stnet ..."
package=/opt/downloads/re6stnet.tar.gz _filename=/opt/downloads/re6stnet.tar.gz
cd /opt cd /opt
if [[ -r $package ]] ; then if [[ -r ${_filename} ]] ; then
tar xzf $package --no-same-owner tar xzf ${_filename} --no-same-owner
mv $(ls -d re6stnet-*) re6stnet mv $(ls -d re6stnet-*) re6stnet
else else
echo "Clone re6stnet from http://git.erp5.org/repos/re6stnet.git" echo "Clone re6stnet from http://git.erp5.org/repos/re6stnet.git"
...@@ -408,26 +438,26 @@ else ...@@ -408,26 +438,26 @@ else
fi fi
echo Checking re6stnet configuration ... echo Checking re6stnet configuration ...
if [[ ! -r $re6stnet_configure_file ]] ; then if [[ ! -r ${re6stnet_configure_file} ]] ; then
echo "Registering to http://re6stnet.nexedi.com ..." echo "Registering to http://re6stnet.nexedi.com ..."
cd $(dirname $re6stnet_configure_file) cd $(dirname ${re6stnet_configure_file})
# Your subnet: 2001:67c:1254:e:19::/80 (CN=917529/32) # Your subnet: 2001:67c:1254:e:19::/80 (CN=917529/32)
subnet=$(re6st-conf --registry http://re6stnet.nexedi.com/ --anonymous | \ subnet=$(re6st-conf --registry http://re6stnet.nexedi.com/ --anonymous | \
grep "^Your subnet:") || \ grep "^Your subnet:") || \
csih_error "Register to nexedi re6stnet failed" csih_error "Register to nexedi re6stnet failed"
[[ -r re6stnet.conf ]] || \ [[ -r re6stnet.conf ]] || \
csih_error "No $re6stnet_configure_file found." csih_error "No ${re6stnet_configure_file} found."
echo Register re6stnet OK. echo Register re6stnet OK.
echo "Write information to re6stnet.conf:" echo "Write information to re6stnet.conf:"
echo " # $subnet" echo " # $subnet"
echo " table 0" echo " table 0"
echo " ovpnlog" echo " ovpnlog"
echo " main-interface $slapos_ifname" echo " main-interface ${slapos_ifname}"
echo " interface $slapos_ifname" echo " interface ${slapos_ifname}"
echo -e "# $subnet\ntable 0\novpnlog" \ echo -e "# $subnet\ntable 0\novpnlog" \
"\nmain-interface $slapos_ifname\ninterface $slapos_ifname" \ "\nmain-interface ${slapos_ifname}\ninterface ${slapos_ifname}" \
>> $re6stnet_configure_file >> ${re6stnet_configure_file}
fi fi
echo echo
...@@ -452,22 +482,22 @@ if check_re6stnet_needed ; then ...@@ -452,22 +482,22 @@ if check_re6stnet_needed ; then
csih_inform "Disable IPv6 teredo interface ... " csih_inform "Disable IPv6 teredo interface ... "
netsh interface teredo set state disable && csih_inform "OK." netsh interface teredo set state disable && csih_inform "OK."
client_count=$(sed -n -e "s/^client-count *//p" $re6stnet_configure_file) _count=$(sed -n -e "s/^client-count *//p" ${re6stnet_configure_file})
[[ -z "$client_count" ]] && client_count=10 [[ -z "${_count}" ]] && _count=10
echo "Re6stnet client-count: $client_count" echo "Re6stnet client-count: ${_count}"
re6stnet_name_list="re6stnet-tcp re6stnet-udp" _name_list="re6stnet-tcp re6stnet-udp"
for (( i=1; i<=client_count; i=i+1 )) ; do for (( i=1; i<=${_count}; i=i+1 )) ; do
re6stnet_name_list="$re6stnet_name_list re6stnet$i" _name_list="${_name_list} re6stnet$i"
done done
filename=$(cygpath -w $openvpn_tap_driver_inf) _filename=$(cygpath -w ${openvpn_tap_driver_inf})
for name in $re6stnet_name_list ; do for name in ${_name_list} ; do
echo "Checking interface $name ..." echo "Checking interface $name ..."
if ! netsh interface ipv6 show interface | grep -q "\\b$name\\b" ; then if ! netsh interface ipv6 show interface | grep -q "\\b$name\\b" ; then
[[ -r $openvpn_tap_driver_inf ]] || [[ -r ${openvpn_tap_driver_inf} ]] ||
csih_error "Failed to install OpenVPN Tap-Windows Driver, missing driver inf file: $filename" csih_error "Failed to install OpenVPN Tap-Windows Driver, missing driver inf file: ${_filename}"
echo "Installing interface $name ..." echo "Installing interface $name ..."
# ipwin install \"$filename\" $openvpn_tap_driver_hwid $name; || # ipwin install \"${_filename}\" $openvpn_tap_driver_hwid $name; ||
ip vpntap add dev $name || ip vpntap add dev $name ||
csih_error "Failed to install OpenVPN Tap-Windows Driver." csih_error "Failed to install OpenVPN Tap-Windows Driver."
echo "Interface $name installed." echo "Interface $name installed."
...@@ -479,25 +509,25 @@ if check_re6stnet_needed ; then ...@@ -479,25 +509,25 @@ if check_re6stnet_needed ; then
# Run re6stnet if no native ipv6 # Run re6stnet if no native ipv6
check_re6stnet_configure || check_re6stnet_configure ||
csih_error "Failed to configure re6stnet." csih_error "Failed to configure re6stnet."
if ! cygrunsrv --query $re6stnet_service_name >/dev/null 2>&1 ; then if ! cygrunsrv --query ${re6stnet_service_name} >/dev/null 2>&1 ; then
if [[ -z "${csih_PRIVILEGED_PASSWORD}" ]] ; then if [[ -z "${csih_PRIVILEGED_PASSWORD}" ]] ; then
slapos_request_password ${_administrator} "Install re6stnet service need the password of ${_administrator}." slapos_request_password ${_administrator} "Install re6stnet service need the password of ${_administrator}."
fi fi
cygrunsrv -I $re6stnet_service_name -c $(dirname $re6stnet_configure_file) \ cygrunsrv -I ${re6stnet_service_name} -c $(dirname ${re6stnet_configure_file}) \
-p $(which re6stnet) -a "@re6stnet.conf" -d "CYGWIN re6stnet" \ -p $(which re6stnet) -a "@re6stnet.conf" -d "CYGWIN re6stnet" \
-u ${_administrator} -w ${csih_PRIVILEGED_PASSWORD} || -u ${_administrator} -w ${csih_PRIVILEGED_PASSWORD} ||
csih_error "Failed to install $re6stnet_service_name service." csih_error "Failed to install ${re6stnet_service_name} service."
fi fi
echo "You can check log files in the /var/log/re6stnet/*.log" echo "You can check log files in the /var/log/re6stnet/*.log"
if ! check_cygwin_service $re6stnet_service_name ; then if ! check_cygwin_service ${re6stnet_service_name} ; then
csih_inform "Service $re6stnet_service_name is not running. One possible case" csih_inform "Service ${re6stnet_service_name} is not running. One possible case"
csih_inform "is that re6stnet service is shutdown in unusual ways, in this case" csih_inform "is that re6stnet service is shutdown in unusual ways, in this case"
csih_inform "you can fix it by removing '/var/lib/re6stnet'." csih_inform "you can fix it by removing '/var/lib/re6stnet'."
if csih_request "Do you want to let me remove it for you?" ; then if csih_request "Do you want to let me remove it for you?" ; then
rm -rf /var/lib/re6stnet rm -rf /var/lib/re6stnet
fi fi
check_cygwin_service $re6stnet_service_name || check_cygwin_service ${re6stnet_service_name} ||
csih_error "Failed to start $re6stnet_service_name service." csih_error "Failed to start ${re6stnet_service_name} service."
fi fi
else else
echo "Native IPv6 found, no taps required." echo "Native IPv6 found, no taps required."
...@@ -513,10 +543,10 @@ echo ...@@ -513,10 +543,10 @@ echo
echo echo
echo Starting configure section cron ... echo Starting configure section cron ...
echo echo
cron_user=${_administrator} _cron_user=${_administrator}
slapos_crontab_file="/var/cron/tabs/$cron_user" _crontab_file="/var/cron/tabs/${_cron_user}"
if [[ ! -f $slapos_crontab_file ]] ; then if [[ ! -f ${_crontab_file} ]] ; then
cat <<EOF > $slapos_crontab_file cat <<EOF > ${_crontab_file}
SHELL=/bin/bash SHELL=/bin/bash
PATH=/usr/local/bin:/usr/bin:/usr/sbin:/sbin:/bin PATH=/usr/local/bin:/usr/bin:/usr/sbin:/sbin:/bin
MAILTO="" MAILTO=""
...@@ -532,20 +562,20 @@ MAILTO="" ...@@ -532,20 +562,20 @@ MAILTO=""
0 * * * * /opt/slapos/bin/slapos node format >> /opt/slapos/log/slapos-node-format.log 2>&1 0 * * * * /opt/slapos/bin/slapos node format >> /opt/slapos/log/slapos-node-format.log 2>&1
EOF EOF
fi fi
echo Change owner of $slapos_crontab_file to $cron_user echo Change owner of ${_crontab_file} to ${_cron_user}
chown $cron_user $slapos_crontab_file chown ${_cron_user} ${_crontab_file}
echo Change mode of $slapos_crontab_file to 644 echo Change mode of ${_crontab_file} to 644
chmod 644 $slapos_crontab_file chmod 644 ${_crontab_file}
ls -l $slapos_crontab_file ls -l ${_crontab_file}
echo echo
echo Begin of crontab of ${_administrator}: echo Begin of crontab of ${_administrator}:
echo ------------------------------------------------------------ echo ------------------------------------------------------------
cat $slapos_crontab_file || csih_error "No crob tab found." cat ${_crontab_file} || csih_error "No crob tab found."
echo ------------------------------------------------------------ echo ------------------------------------------------------------
echo End of crontab of ${_administrator}. echo End of crontab of ${_administrator}.
echo echo
echo Configure section cron OK. echo Configure section cron OK.
echo echo
......
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