Commit 842b5754 authored by Jondy Zhao's avatar Jondy Zhao

Add user slaproot used by slapos node

parent 2e7a6da6
...@@ -112,7 +112,30 @@ Be sure the configure scrip report successfully, otherwise fix the problem and r ...@@ -112,7 +112,30 @@ Be sure the configure scrip report successfully, otherwise fix the problem and r
</section> </section>
<section><title>Background Jobs</title> <section><title>Background Jobs</title>
<para>After run Configure SlapOS, then a cron job will run in the background which used to release software and create instance periodically.</para> <para>After run Configure SlapOS, then a cron job will run in the background which used to release software and create instance periodically. Open Cygwin Terminal, type the following command to check these jobs:
<programlisting>
# List all cron tabs
crontab -l
# Check cron works
tail /var/log/messages
# Edit cron tasks
crontab -e
# Stop cron
pid=$(ps -ef | grep "/usr/sbin/cron" | gawk '{ print $2; }') &amp;&amp; kill $pid
# Start cron
/usr/sbin/cron
disown -h
</programlisting>
</para>
</section>
<section><title>Known issues</title>
<para>service slapos-re6stnet cound't be stop, except kill all the openvpn in the windows task manager by manual, or:
<programlisting>
TASKKILL /F /IM openvpn.exe
net stop slapos-re6stnet
</programlisting>
</para>
</section> </section>
</chapter> </chapter>
...@@ -224,13 +247,23 @@ cd /opt ...@@ -224,13 +247,23 @@ cd /opt
tar czf slapos.tar.gz slapos/ tar czf slapos.tar.gz slapos/
mv slapos.tar.gz slapos/ mv slapos.tar.gz slapos/
</programlisting> </programlisting>
Then build babeld for cygwin, we need use the sources in the slapos.package.git, they are patched for cygwin: Then build babeld and openvpn for cygwin, we need use the sources in the slapos.package.git, they are patched for cygwin:
<programlisting> <programlisting>
cd /opt/git/slapos.package/windows/babeld cd /opt/git/slapos.package/windows/babeld
make WINVER=XP make WINVER=XP
cp babeld.exe /usr/bin cp babeld.exe /usr/bin
cd /opt/git/slapos.package/windows/openvpn
libtoolize
aclocal -I m4
autoheader
automake --add-missing
autoreconf
ac_cv_type_socklen_t=yes IFCONFIG="C:/WINDOWS/system32" LDFLAGS="-liphlpapi -lws2_32" CFLAGS="-DWIN32 -DCYGWIN -D__USE_W32_SOCKETS -D__INSIDE_CYGWIN_NET__ -DWIN32_LEAN_AND_MEAN -D_WIN32_WINNT=0x0503 -g" OPENSSL_CRYPTO_CFLAGS=-I/usr/include OPENSSL_CRYPTO_LIBS="-L/usr/lib -lcrypto" OPENSSL_SSL_CFLAGS=-I/usr/include OPENSSL_SSL_LIBS="-L/usr/lib -lssl" ./configure --disable-lzo --disable-pkcs11 --disable-plugin-auth-pam --disable-plugin-down-root
make
cp src/openvpn/.libs/openvpn.exe /usr/bin
</programlisting> </programlisting>
Now downlaod openvpn 2.3 for your window version, and install it. Now downlaod openvpn 2.3 for your window version, and install it. We need OpenVPN Tap-Windows Drivers files.
</para> </para>
<para> <para>
Then generate user-guide.html from using-slapos-in-windows.xml, generally you need not do this, just copy this file (you're looking now) to /opt/git/slapos.package/windows/docs. If you require want to generate the document by your self, make sure docbook-utils package installed in the Cygwin. Refer to <xref linkend="package-docbook-utils"/> to know what about docbook-utils. Then generate user-guide.html from using-slapos-in-windows.xml, generally you need not do this, just copy this file (you're looking now) to /opt/git/slapos.package/windows/docs. If you require want to generate the document by your self, make sure docbook-utils package installed in the Cygwin. Refer to <xref linkend="package-docbook-utils"/> to know what about docbook-utils.
......
...@@ -80,7 +80,7 @@ Name: "{group}\User Guide"; Filename: "{app}\user-guide.html"; ...@@ -80,7 +80,7 @@ Name: "{group}\User Guide"; Filename: "{app}\user-guide.html";
[Run] [Run]
Filename: "{app}\setup-cygwin.bat"; Parameters: """{app}"""; StatusMsg: "Installing Cygwin..."; Flags: runhidden; Filename: "{app}\setup-cygwin.bat"; Parameters: """{app}"""; StatusMsg: "Installing Cygwin..."; Flags: runhidden;
Filename: "{app}\cygwin\bin\bash.exe"; Parameters: "--login -i /etc/slapos/scripts/post-install.sh"; WorkingDir: "{app}\cygwin\bin"; Description: "Configure Cygwin"; StatusMsg: "Configure Cygwin..."; Flags: skipifdoesntexist; Filename: "{app}\cygwin\bin\bash.exe"; Parameters: "--login -i /etc/slapos/scripts/post-install.sh"; WorkingDir: "{app}\cygwin\bin"; Description: "Configure Cygwin"; StatusMsg: "Configure Cygwin..."; Flags: skipifdoesntexist;
Filename: "{app}\cygwin\autorebase.bat"; WorkingDir: "{app}\cygwin"; Flags: skipifdoesntexist; Filename: "{app}\cygwin\autorebase.bat"; WorkingDir: "{app}\cygwin"; Flags: skipifdoesntexist runhidden;
[UninstallRun] [UninstallRun]
Filename: "{app}\cygwin\bin\bash.exe"; Parameters: "--login -i /etc/slapos/scripts/pre-uninstall.sh"; WorkingDir: "{app}\cygwin\bin"; Flags: skipifdoesntexist; Filename: "{app}\cygwin\bin\bash.exe"; Parameters: "--login -i /etc/slapos/scripts/pre-uninstall.sh"; WorkingDir: "{app}\cygwin\bin"; Flags: skipifdoesntexist;
......
...@@ -10,6 +10,8 @@ ...@@ -10,6 +10,8 @@
# #
# * Check IPv6 protocol and install it if require # * Check IPv6 protocol and install it if require
# #
# * Create user slaproot who owns Administrator group rights
#
# * Configure and start cygwin service: cygserver, syslog-ng, sshd # * Configure and start cygwin service: cygserver, syslog-ng, sshd
# #
# * config: Create node and client configure file by parameters ca/key # * config: Create node and client configure file by parameters ca/key
...@@ -44,14 +46,12 @@ ...@@ -44,14 +46,12 @@
# startup Run slapos-configure.sh on windows startup # startup Run slapos-configure.sh on windows startup
# runner Install web runner for this node # runner Install web runner for this node
# #
export PATH=/usr/local/bin:/usr/bin:/usr/sbin:/sbin:/bin:$PATH source $(/usr/bin/dirname $0)/slapos-include.sh
source $(dirname $0)/slapos-include.sh
check_administrator_right || show_error_exit
if [[ ! ":$PATH" == :/opt/slapos/bin: ]] ; then if [[ ! ":$PATH" == :/opt/slapos/bin: ]] ; then
for profile in ~/.bash_profile ~/.profile ; do for profile in ~/.bash_profile ~/.profile ; do
grep -q "export PATH=/opt/slapos/bin:" $profile || \ grep -q "export PATH=/opt/slapos/bin:" $profile ||
echo "export PATH=/opt/slapos/bin:$$PATH" >> $profile echo "export PATH=/opt/slapos/bin:\${PATH}" >> $profile
done done
fi fi
...@@ -69,9 +69,21 @@ fi ...@@ -69,9 +69,21 @@ fi
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/downloads
mkdir -p /etc/slapos/scripts mkdir -p /etc/slapos/scripts
mkdir -p /etc/re6stnet mkdir -p /etc/re6stnet
# -----------------------------------------------------------
# Create account: slaproot
# -----------------------------------------------------------
if ! csih_privileged_account_exists $slapos_administrator
then
csih_create_privileged_user $slapos_administrator
else
csih_account_has_necessary_privileges $slapos_administrator
fi
# ----------------------------------------------------------- # -----------------------------------------------------------
# Configure cygwin services: cygserver syslog-ng sshd # Configure cygwin services: cygserver syslog-ng sshd
# ----------------------------------------------------------- # -----------------------------------------------------------
......
#! /bin/bash #! /bin/bash
export PATH=/usr/local/bin:/usr/bin:/usr/sbin:/sbin:/bin:$PATH
if ! source /usr/share/csih/cygwin-service-installation-helper.sh ; then
echo "Error: Download the csih package at first, I need this file:"
echo " /usr/share/csih/cygwin-service-installation-helper.sh"
exit 1
fi
# Check Administrator rights
csih_get_system_and_admins_ids
if [[ ! " $(id -G) " == *\ $csih_ADMINSUID\ * ]] ; then
echo
echo "You haven't right to run this script. "
echo "Please login as Administrator to run it, or right-click this script"
echo "then click Run as administrator."
echo
exit 1
fi
# ====================================================================== # ======================================================================
# Constants # Constants
...@@ -25,72 +42,10 @@ slaprunner_startup_file=/etc/slapos/scripts/slap-runner.html ...@@ -25,72 +42,10 @@ slaprunner_startup_file=/etc/slapos/scripts/slap-runner.html
slapos_run_key='\HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run' slapos_run_key='\HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run'
slapos_run_entry=slapos-configure slapos_run_entry=slapos-configure
slapos_administrator=slaproot
# ====================================================================== # ======================================================================
# Routine: get_system_and_admins_gids # Routine: check_cygwin_service
# Get the ADMINs ids from /etc/group and /etc/passwd
# ======================================================================
function get_system_and_admins_ids() {
ret=0
for fname in /etc/passwd /etc/group; do
if ls -ld "${fname}" | grep -Eq '^-r..r..r..'; then
true
else
echo "The file $fname is not readable by all."
echo "Please run 'chmod +r $fname'."
echo
ret=1
fi
done
[ ! -r /etc/passwd -o ! -r /etc/group ] && return 1;
ADMINSGID=$(sed -ne '/^[^:]*:S-1-5-32-544:.*:/{s/[^:]*:[^:]*:\([0-9]*\):.*$/\1/p;q}' /etc/group)
SYSTEMGID=$(sed -ne '/^[^:]*:S-1-5-18:.*:/{s/[^:]*:[^:]*:\([0-9]*\):.*$/\1/p;q}' /etc/group)
if [ -z "$ADMINSGID" -o -z "$SYSTEMGID" ]; then
echo "It appears that you do not have correct entries for the"
echo "ADMINISTRATORS and/or SYSTEM sids in /etc/group."
echo
echo "Use the 'mkgroup' utility to generate them"
echo " mkgroup -l > /etc/group"
warning_for_etc_file group
ret=1;
fi
ADMINSUID=$(sed -ne '/^[^:]*:[^:]*:[0-9]*:[0-9]*:[^:]*,S-1-5-32-544:.*:/{s/[^:]*:[^:]*:\([0-9]*\):.*$/\1/p;q}' /etc/passwd)
SYSTEMUID=$(sed -ne '/^[^:]*:[^:]*:[0-9]*:[0-9]*:[^:]*,S-1-5-18:.*:/{s/[^:]*:[^:]*:\([0-9]*\):.*$/\1/p;q}' /etc/passwd)
if [ -z "$ADMINSUID" -o -z "$SYSTEMUID" ]; then
echo "It appears that you do not have correct entries for the"
echo "ADMINISTRATORS and/or SYSTEM sids in /etc/passwd."
echo
echo "Use the 'mkpasswd' utility to generate it"
echo " mkpasswd -l > /etc/passwd."
warning_for_etc_file passwd
ret=1;
fi
return "${ret}"
} # === get_system_and_admins_ids() === #
# ======================================================================
# Routine: check_administrator_right
# Check script run as Administrator or not
# ======================================================================
function check_administrator_right()
{
get_system_and_admins_ids || exit 1
groups=" $(id -G) "
if [[ ! $groups == *\ $ADMINSGID\ * ]] ; then
echo
echo "You haven't right to run this script $0. "
echo "Please login as Administrator to run it, or right-click this script and"
echo "then click Run as administrator."
echo
return 1
fi
} # === check_administrator_right() === #
# ======================================================================
# Routine: check_administrator_right
# Check cygwin service is install or not, running state, and run by # Check cygwin service is install or not, running state, and run by
# which account # which account
# ====================================================================== # ======================================================================
...@@ -302,30 +257,6 @@ function start_cygwin_service() ...@@ -302,30 +257,6 @@ function start_cygwin_service()
[[ "$state" == "Running" ]] || return 1 [[ "$state" == "Running" ]] || return 1
} # === start_cygwin_service() === # } # === start_cygwin_service() === #
#
# Query the parameter, usage:
#
# query_parameter ACTUAL EXCPETED MESSAGE
#
function query_parameter()
{
if [[ X$1 == X || $1 == "*" || $1 == "all" ]] ; then
return 1
fi
if [[ $1 == "?" || $1 == "query" ]] ; then
read -n 1 -p $3 user_ack
if [[ X$user_ack == X[Yy] ]] ; then
return 1
else
return 0
fi
fi
if [[ $1 == $2 ]] ; then
return 1
fi
return 0
}
# ====================================================================== # ======================================================================
# Routine: create_template_configure_file # Routine: create_template_configure_file
# Generate the template file for node and client # Generate the template file for node and client
......
#! /bin/bash #! /bin/bash
export PATH=/usr/local/bin:/usr/bin:/usr/sbin:/sbin:/bin:$PATH source $(/usr/bin/dirname $0)/slapos-include.sh
source $(dirname $0)/slapos-include.sh
check_administrator_right || show_error_exit
# ----------------------------------------------------------- # -----------------------------------------------------------
# Check all the configure files # Check all the configure files
......
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