Commit c870bb95 authored by Jondy Zhao's avatar Jondy Zhao

remove sshd service

slapos-configure do not user $WINDIR
remove /var/empty before uninstall slapos node
parent b633fdd0
......@@ -9,16 +9,16 @@
#
# * Remove virtual netcards installed by re6stnet
#
# * Remove service cron, cygserver and syslog-ng
# * Remove service cron, cygserver syslog-ng re6stnet
#
# * Remove slapos configure script from windows startup item
# * Remove account/group added by slapos configure script
#
# * Remove instance root /srv/slapgrid
# * Remove instance and software root /srv/slapgrid /opt/slapgrid
#
# Required:
# grep gawk TASKKILL
#
export PATH=/usr/local/bin:/usr/bin:/usr/sbin:/sbin:/bin:$PATH
source $(/usr/bin/dirname $0)/slapos-include.sh
function slapos_kill_process()
{
......@@ -31,29 +31,11 @@ function slapos_kill_process()
}
readonly -f slapos_kill_process
#
# Declare variables
#
declare -r slapos_prefix=
declare -r slapos_administrator=${slapos_prefix:-slap}root
declare -r slapos_user_basename=${slapos_prefix:-slap}user
declare -r slapos_ifname=${slapos_prefix}re6stnet-lo
declare -r re6stnet_service_name=${slapos_prefix}re6stnet
declare -r cron_service_name=${slapos_prefix}cron
declare -r ssh_service_name=${slapos_prefix}ssh
declare -r syslog_service_name=${slapos_prefix}syslog-ng
declare -r cygserver_service_name=${slapos_prefix}cygserver
#
# Remove services installed by cygwin,
#
echo "Try to stop service ${re6stnet_service_name} ..."
net stop ${re6stnet_service_name} ||
slapos_kill_process /usr/bin/openvpn
for name in ${re6stnet_service_name} ${cron_service_name} \
${ssh_service_name} ${syslog_service_name} \
${cygserver_service_name} ; do
${syslog_service_name} ${cygserver_service_name} ; do
echo "Removing ervice $name"
cygrunsrv -R $name && echo OK.
done
......@@ -73,9 +55,32 @@ slapos_kill_process /usr/bin/python2.7
echo "Removing network connection ${slapos_ifname}"
ipwin remove *msloop ${slapos_ifname} && echo OK.
#
# Remove configure files
#
echo Removing /etc/opt/slapos
rm -rf /etc/opt/slapos/ && echo OK.
echo Removing ~/.slapos
rm -rf ~/.slapos && echo OK.
#
# Remove crontab
#
_filename=/var/cron/tabs/${slapos_administrator}
echo "Removing ${_filename}"
rm -rf ${_filename} && echo OK.
#
# Remove default instance root and software root, because it belong to
# slapuser, and would not be removed by the windows uninstaller.
#
[[ -f /srv/slapgrid ]] && echo "Removing /srv/slapgrid" && rm -rf /srv/slapgrid && echo OK.
[[ -f /opt/slapgrid ]] && echo "Removing /opt/slapgrid" && rm -rf /opt/slapgrid && echo OK.
#
# Remove users installed by slapos
#
[[ -f /var/empty ]] && echo "Removing /var/empty" && rm -rf /var/empty && echo OK.
for _name in $(NET USER) ; do
if [[ "${_name}" == ${slapos_user_basename}* ]] ; then
echo "Removing user: ${_name}"
......@@ -100,27 +105,6 @@ done
echo "Creating /etc/group ..."
mkgroup -l > /etc/group && echo OK.
#
# Remove configure files
#
echo Removing /etc/opt/slapos
rm -rf /etc/opt/slapos/ && echo OK.
echo Removing ~/.slapos
rm -rf ~/.slapos && echo OK.
#
# Remove crontab
#
_filename=/var/cron/tabs/${slapos_administrator}
echo "Removing ${_filename}"
rm -rf ${_filename} && echo OK.
#
# Remove default instance root, because it belong to slapuser, and
# would be removed by the windows uninstaller.
#
[[ -f /srv/slapgrid ]] && echo Removing /srv/slapgrid && rm -rf /srv/slapgrid && echo OK.
echo
echo Run pre-uninstall script complete.
echo
......
......@@ -134,12 +134,10 @@ if [[ ! ":$PATH" == :/opt/slapos/bin: ]] ; then
fi
csih_check_program_or_error /usr/bin/cygrunsrv cygserver
csih_check_program_or_error /usr/bin/ssh-host-config ssh
csih_check_program_or_error /usr/bin/syslog-ng-config syslog-ng
csih_check_program_or_error /usr/bin/openssl openssl
csih_check_program_or_error /usr/bin/ipwin slapos-patches
csih_check_program_or_error /usr/bin/slapos-cron-config slapos-patches
[[ -z "$WINDIR" ]] && csih_error "missing environment variable WINDIR"
# -----------------------------------------------------------
# Create paths
......@@ -196,30 +194,6 @@ else
fi
check_cygwin_service ${syslog_service_name}
if ! cygrunsrv --query ${sshd_service_name} > /dev/null 2>&1 ; then
if csih_is_vista && [[ -z "${csih_PRIVILEGED_PASSWORD}" ]] ; then
slapos_request_password ${_administrator} "Install sshd service need the password of ${_administrator}."
fi
csih_inform "run ssh-host-config ..."
/usr/bin/ssh-host-config --yes --cygwin ntsec --port 22002 \
--user ${_administrator} --pwd ${csih_PRIVILEGED_PASSWORD} ||
csih_error "Failed to run ssh-host-config"
if csih_is_vista ; then
[[ ${sshd_service_name} == "sshd" ]] ||
cygrunsrv -I ${sshd_service_name} -d "CYGWIN ${sshd_service_name}" -p /usr/sbin/sshd \
-a "-D" -y tcpip -e "CYGWIN=ntsec" -u "${_administrator}" -w "${csih_PRIVILEGED_PASSWORD}" ||
csih_error "failed to install service ${sshd_service_name}"
else
[[ ${sshd_service_name} == "sshd" ]] ||
cygrunsrv -I ${sshd_service_name} -d "CYGWIN ${sshd_service_name}" -p /usr/sbin/sshd \
-a "-D" -y tcpip -e "CYGWIN=ntsec" ||
csih_error "failed to install service ${sshd_service_name}"
fi
else
csih_inform "the sshd service has been installed"
fi
check_cygwin_service ${sshd_service_name}
# Use slapos-cron-config to configure slapos cron service.
if ! cygrunsrv --query ${cron_service_name} > /dev/null 2>&1 ; then
[[ -x ${slapos_cron_config} ]] ||
......@@ -246,7 +220,7 @@ echo ""
csih_inform "Starting configure slapos network ..."
if ! netsh interface ipv6 show interface | grep -q "\\b${slapos_ifname}\\b" ; then
csih_inform "Installing network interface ${slapos_ifname} ..."
ipwin install $WINDIR\\inf\\netloop.inf *msloop ${slapos_ifname} ||
ipwin install netloop.inf *msloop ${slapos_ifname} ||
csih_error "install network interface ${slapos_ifname} failed"
fi
ip -4 addr add $(echo ${_ipv4_local_network} | sed -e "s%\.0/%.1/%g") dev ${slapos_ifname} ||
......
......@@ -18,7 +18,6 @@ check_re6stnet_configure
# -----------------------------------------------------------
check_cygwin_service ${cygserver_service_name}
check_cygwin_service ${syslog_service_name}
check_cygwin_service ${sshd_service_name}
check_cygwin_service ${cron_service_name}
check_re6stnet_needed && check_cygwin_service ${re6stnet_service_name}
......
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