Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.package
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Boxiang Sun
slapos.package
Commits
d7a0af70
Commit
d7a0af70
authored
Jul 19, 2013
by
Jondy Zhao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refine the process of create slapos-webrunner instance
parent
af65d002
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
108 additions
and
106 deletions
+108
-106
windows/docs/using-slapos-in-windows.xml
windows/docs/using-slapos-in-windows.xml
+1
-1
windows/scripts/slapos-include.sh
windows/scripts/slapos-include.sh
+41
-80
windows/scripts/slapos-node.sh
windows/scripts/slapos-node.sh
+66
-25
No files found.
windows/docs/using-slapos-in-windows.xml
View file @
d7a0af70
...
@@ -102,7 +102,7 @@ Then waiting for configure script finished. Be sure the configure scrip report s
...
@@ -102,7 +102,7 @@ Then waiting for configure script finished. Be sure the configure scrip report s
</section>
</section>
<section><title>
SlapOS Node
</title>
<section><title>
SlapOS Node
</title>
<para>
It's used to format slapos node, release software and create instance, you an run it at any time.
</para>
<para>
It's used to
create instance of slapos webrunner,
format slapos node, release software and create instance, you an run it at any time.
</para>
<para>
Click Start -> SlapOS -> SlapOS Node, if the current user isn't Administrator, Right click SlapOS Node, then Run As Administrator.
</para>
<para>
Click Start -> SlapOS -> SlapOS Node, if the current user isn't Administrator, Right click SlapOS Node, then Run As Administrator.
</para>
<para>
Be sure the scrip reports successfully, otherwise fix the problem and run it again.
</para>
<para>
Be sure the scrip reports successfully, otherwise fix the problem and run it again.
</para>
</section>
</section>
...
...
windows/scripts/slapos-include.sh
View file @
d7a0af70
...
@@ -98,14 +98,14 @@ function check_network_configure()
...
@@ -98,14 +98,14 @@ function check_network_configure()
function
check_node_configure
()
function
check_node_configure
()
{
{
csih_inform
"Checking slapos node configure ..."
csih_inform
"Checking slapos node configure ..."
[[
!
-r
$node_certificate_file
]]
&&
[[
!
-r
$node_certificate_file
]]
&&
csih_error_multi
"Computer certificate file
$node_certificate_file
"
\
csih_error_multi
"Computer certificate file
$node_certificate_file
"
\
"doesn't exists, or you haven't right to visit."
"doesn't exists, or you haven't right to visit."
openssl x509
-noout
-in
$node_certificate_file
||
return
1
openssl x509
-noout
-in
$node_certificate_file
||
return
1
openssl rsa
-noout
-in
$node_key_file
-check
||
return
1
openssl rsa
-noout
-in
$node_key_file
-check
||
return
1
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_multi
"Invalid computer id '
$computer_guid
' specified."
\
csih_error_multi
"Invalid computer id '
$computer_guid
' specified."
\
"It should look like 'COMP-XXXX'"
"It should look like 'COMP-XXXX'"
csih_inform
"Check slapos node configure Over."
csih_inform
"Check slapos node configure Over."
...
@@ -242,7 +242,7 @@ slapos_check_and_create_privileged_user()
...
@@ -242,7 +242,7 @@ slapos_check_and_create_privileged_user()
csih_PRIVILEGED_USERNAME
=
"
${
username
}
"
csih_PRIVILEGED_USERNAME
=
"
${
username
}
"
if
!
csih_privileged_account_exists
"
$csih_PRIVILEGED_USERNAME
"
if
!
csih_privileged_account_exists
"
$csih_PRIVILEGED_USERNAME
"
then
then
username_in_sam
=
no
username_in_sam
=
no
dos_var_empty
=
$(
/usr/bin/cygpath
-w
${
LOCALSTATEDIR
}
/empty
)
dos_var_empty
=
$(
/usr/bin/cygpath
-w
${
LOCALSTATEDIR
}
/empty
)
...
@@ -273,7 +273,7 @@ slapos_check_and_create_privileged_user()
...
@@ -273,7 +273,7 @@ slapos_check_and_create_privileged_user()
fi
fi
/usr/bin/rm
-f
"
${
tmpfile1
}
"
/usr/bin/rm
-f
"
${
tmpfile1
}
"
done
done
csih_PRIVILEGED_PASSWORD
=
"
${
_password
}
"
csih_PRIVILEGED_PASSWORD
=
"
${
_password
}
"
csih_inform
"User '
${
username
}
' has been created with password '
${
_password
}
'."
csih_inform
"User '
${
username
}
' has been created with password '
${
_password
}
'."
csih_inform
"If you change the password, please remember also to change the"
csih_inform
"If you change the password, please remember also to change the"
...
@@ -323,7 +323,7 @@ slapos_check_and_create_privileged_user()
...
@@ -323,7 +323,7 @@ slapos_check_and_create_privileged_user()
ret
=
1
ret
=
1
fi
fi
fi
fi
if
!
csih_check_program_or_warn /usr/bin/editrights editrights
if
!
csih_check_program_or_warn /usr/bin/editrights editrights
then
then
csih_warning
"The 'editrights' program cannot be found or is not executable."
csih_warning
"The 'editrights' program cannot be found or is not executable."
...
@@ -345,7 +345,7 @@ slapos_check_and_create_privileged_user()
...
@@ -345,7 +345,7 @@ slapos_check_and_create_privileged_user()
fi
# ! username_in_sam
fi
# ! username_in_sam
# we just created the user, so of course it's in the local SAM,
# we just created the user, so of course it's in the local SAM,
# and mkpasswd -l is appropriate
# and mkpasswd -l is appropriate
pwd_entry
=
"
$(
/usr/bin/mkpasswd
-l
-u
"
${
username
}
"
| /usr/bin/sed
-n
-e
'/^'
${
username
}
'/s?\(^[^:]*:[^:]*:[^:]*:[^:]*:[^:]*:\).*?\1'
${
LOCALSTATEDIR
}
'/empty:/bin/false?p'
)
"
pwd_entry
=
"
$(
/usr/bin/mkpasswd
-l
-u
"
${
username
}
"
| /usr/bin/sed
-n
-e
'/^'
${
username
}
'/s?\(^[^:]*:[^:]*:[^:]*:[^:]*:[^:]*:\).*?\1'
${
LOCALSTATEDIR
}
'/empty:/bin/false?p'
)
"
/usr/bin/grep
-Eiq
"^
${
username
}
:"
"
${
SYSCONFDIR
}
/passwd"
&&
username_in_passwd
=
yes
&&
/usr/bin/grep
-Eiq
"^
${
username
}
:"
"
${
SYSCONFDIR
}
/passwd"
&&
username_in_passwd
=
yes
&&
/usr/bin/grep
-Fiq
"
${
pwd_entry
}
"
"
${
SYSCONFDIR
}
/passwd"
&&
entry_in_passwd
=
yes
/usr/bin/grep
-Fiq
"
${
pwd_entry
}
"
"
${
SYSCONFDIR
}
/passwd"
&&
entry_in_passwd
=
yes
...
@@ -381,80 +381,39 @@ function create_template_configure_file()
...
@@ -381,80 +381,39 @@ function create_template_configure_file()
}
# === create_template_configure_file() === #
}
# === create_template_configure_file() === #
# ======================================================================
# ======================================================================
# Routine:
create
_slapos_webrunner_instance
# Routine:
get
_slapos_webrunner_instance
#
Create one instance of slapos webrunner in local computer
#
Get instance connection information and create slaprunner startup file
# ======================================================================
# ======================================================================
function
create
_slapos_webrunner_instance
()
function
get
_slapos_webrunner_instance
()
{
{
local
_
title
local
_
guid
=
$1
local
_
guid
local
_
title
=
$2
local
_feature_code
=
"#-*- SlapOS Web Runner JavaScript Boot Code -*-#"
local
_feature_code
=
"#-*- SlapOS Web Runner JavaScript Boot Code -*-#"
local
_re6stnet_ipv6
local
_patch_file
=
/etc/slapos/patches/slapos-cookbook-inotifyx.patch
local
_url
local
_url
local
_ret
=
0
echo
Checking SlapOS Webruner ...
if
grep
-q
-F
"
${
_feature_code
}
"
${
slaprunner_startup_file
}
;
then
csih_inform
"Trying to get connection information of SlapOS WebRunner instance ..."
/opt/slapos/bin/slapos request
${
client_configure_file
}
\
echo
"Find feature code
${
_feature_code
}
in the
${
slaprunner_startup_file
}
"
${
_title
}
slaposwebrunner
--node
computer_guid
=
${
_guid
}
||
return
1
echo
"Check SlapOS Webrunner OK."
# Connection parameters of instance are:
else
# {'backend_url': 'http://[2001:67c:1254:45::c5d5]:50000',
# 'cloud9-url': 'http://localhost:9999',
echo
Installing SlapOS Webrunner ...
# 'password_recovery_code': 'e2d01c14',
# 'ssh_command': 'ssh 2001:67c:1254:45::c5d5 -p 2222',
_guid
=
$(
grep
"CN=COMP"
$node_certificate_file
|
\
# 'url': 'http://softinst39090.host.vifib.net/'}
sed
-e
"s/^.*, CN=//g"
|
sed
-e
"s%/emailAddress.*
\$
%%g"
)
_url
=
$(
/opt/slapos/bin/slapos request
${
client_configure_file
}
\
[[
"
${
_guid
}
"
==
COMP-+
([
0-9]
)
]]
||
${
_title
}
slaposwebrunner
--node
computer_guid
=
${
_guid
}
|
\
csih_error
"Invalid computer id '
${
_guid
}
' specified."
grep
backend_url |
sed
-e
"s/^.*': '//g"
-e
"s/',.*
$/
/g"
)
echo
Got computer guid:
${
_guid
}
if
[[
-n
"
${
_url
}
"
]]
;
then
_title
=
"SlapOS-Node-Runner-In-
${
_guid
}
"
csih_inform
"SlapOS WebRunner URL:
${
_url
}
"
if
[[
-r
$re6stnet_configure_file
]]
;
then
if
grep
-q
-F
"
${
_feature_code
}
"
${
slaprunner_startup_file
}
;
then
_re6stnet_ipv6
=
$(
grep
"Your subnet"
$re6stnet_configure_file
|
\
csih_inform
"Find feature code
${
_feature_code
}
in the
${
slaprunner_startup_file
}
"
sed
-e
"s/^.*subnet: //g"
-e
"s/
\/
80 (CN.*
\$
/1/g"
)
echo
"Check SlapOS Webrunner OK."
if
[[
-n
"
${
_re6stnet_ipv6
}
"
]]
;
then
else
echo
"Re6stnet address in this computer:
${
_re6stnet_ipv6
}
"
csih_inform
"Generate SlapOS WebRunner startup file
${
slaprunner_startup_file
}
"
netsh interface ipv6 show addr
$slapos_ifname
level
=
normal |
\
cat
<<
EOF
>
${
slaprunner_startup_file
}
grep
-q
"
${
_re6stnet_ipv6
}
\$
"
||
\
netsh interface ipv6 add addr
$slapos_ifname
${
_re6stnet_ipv6
}
fi
fi
/opt/slapos/bin/slapos node format
-cv
--now
||
\
csih_error
"Failed to run slapos format."
echo
"Supply slapwebrunner in the computer
${
_guid
}
"
/opt/slapos/bin/slapos supply slaposwebrunner
${
_guid
}
echo
"Request an instance
${
_title
}
..."
while
true
;
do
/opt/slapos/bin/slapos node software
--verbose
# Apply patches to slapos.cookbook for inotifix
if
[[
-r
${
_patch_file
}
]]
;
then
for
x
in
$(
find /opt/slapgrid/
-name
slapos.cookbook-
*
.egg
)
;
do
echo
Apply patch
${
_patch_file
}
at
$x
cd
$x
patch
-f
--dry-run
-p1
<
${
_patch_file
}
>
/dev/null
&&
\
patch
-p1
<
${
_patch_file
}
done
fi
/opt/slapos/bin/slapos node instance
--verbose
/opt/slapos/bin/slapos node report
--verbose
# Connection parameters of instance are:
# {'backend_url': 'http://[2001:67c:1254:45::c5d5]:50000',
# 'cloud9-url': 'http://localhost:9999',
# 'password_recovery_code': 'e2d01c14',
# 'ssh_command': 'ssh 2001:67c:1254:45::c5d5 -p 2222',
# 'url': 'http://softinst39090.host.vifib.net/'}
_url
=
$(
/opt/slapos/bin/slapos request
${
client_configure_file
}
\
${
_title
}
slaposwebrunner
--node
computer_guid
=
${
_guid
}
|
\
grep
backend_url |
sed
-e
"s/^.*': '//g"
-e
"s/',.*
$/
/g"
)
[[
-n
"
${
_url
}
"
]]
&&
echo
"SlapOS Web Runner URL:
${
_url
}
"
&&
break
done
cat
<<
EOF
>
$slaprunner_startup_file
<html>
<html>
<head><title>SlapOS Web Runner</title>
<head><title>SlapOS Web Runner</title>
<script LANGUAGE="JavaScript">
<script LANGUAGE="JavaScript">
...
@@ -469,8 +428,10 @@ function openwin() {
...
@@ -469,8 +428,10 @@ function openwin() {
<!--
$feature_code
-->
<!--
$feature_code
-->
</html>
</html>
EOF
EOF
echo
SlapOS Webrunner boot file
$slaprunner_startup_file
generated.
fi
echo
Install Web Runner OK.
else
echo
csih_error_multi
"Request return true, but I can't find connection information,"
\
"something is wrong with slapos webrunner software."
fi
fi
}
# === create_slapos_webrunner_instance() === #
return
${
_ret
}
}
# === get_slapos_webrunner_instance() === #
windows/scripts/slapos-node.sh
View file @
d7a0af70
#! /bin/bash
#! /bin/bash
source
$(
/usr/bin/dirname
$0
)
/slapos-include.sh
source
$(
/usr/bin/dirname
$0
)
/slapos-include.sh
echo
echo
""
echo
"Start slapos-node script ..."
csih_inform
"Start slapos-node script ..."
echo
echo
""
declare
computer_guid
# -----------------------------------------------------------
# -----------------------------------------------------------
# Check all the configure files
# Check all the configure files
# -----------------------------------------------------------
# -----------------------------------------------------------
check_network_configure
||
exit
1
check_network_configure
check_node_configure
||
exit
1
check_node_configure
check_client_configure
||
exit
1
check_client_configure
check_cron_configure
check_cron_configure
check_re6stnet_configure
check_re6stnet_configure
# -----------------------------------------------------------
# -----------------------------------------------------------
# Check cygwin services used by slapos
# Check cygwin services used by slapos
# -----------------------------------------------------------
# -----------------------------------------------------------
check_cygwin_service cygserver
||
exit
1
check_cygwin_service cygserver
check_cygwin_service syslog-ng
||
exit
1
check_cygwin_service syslog-ng
check_cygwin_service sshd
check_cygwin_service sshd
check_cygwin_service cron
check_cygwin_service cron
check_re6stnet_needed
&&
check_cygwin_service re6stnet
check_re6stnet_needed
&&
check_cygwin_service re6stnet
# -----------------------------------------------------------
# -----------------------------------------------------------
#
Create instance of slap web runner
#
Get computer reference and re6stnet network
# -----------------------------------------------------------
# -----------------------------------------------------------
create_slapos_webrunner_instance
||
exit
1
computer_guid
=
$(
grep
"CN=COMP"
${
node_certificate_file
}
|
\
sed
-e
"s/^.*, CN=//g"
|
sed
-e
"s%/emailAddress.*
\$
%%g"
)
[[
"
${
computer_guid
}
"
==
COMP-+
([
0-9]
)
]]
||
csih_error_multi
"
${
computer_guid
}
is invalid computer guid."
\
"It should like 'COMP-XXXX', edit
${
node_certificate_file
}
"
\
"to fix it."
csih_inform
"Got computer reference id:
${
computer_guid
}
"
# -----------------------------------------------------------
# -----------------------------------------------------------
#
Format slapos node
#
Get re6stnet network
# -----------------------------------------------------------
# -----------------------------------------------------------
echo
"Formating SlapOS Node ..."
if
[[
-r
${
re6stnet_configure_file
}
]]
;
then
/opt/slapos/bin/slapos node format
-cv
--now
||
exit
1
_addr6
=
$(
grep
"Your subnet"
${
re6stnet_configure_file
}
|
\
sed
-e
"s/^.*subnet: //g"
-e
"s/
\/
80 (CN.*
\$
/1/g"
)
if
[[
-n
"
${
_addr6
}
"
]]
;
then
csih_inform
"Re6stnet address in this computer:
${
_addr6
}
"
netsh interface ipv6 show addr
${
slapos_ifname
}
level
=
normal |
\
grep
-q
"
${
_addr6
}
\$
"
||
\
netsh interface ipv6 add addr
${
slapos_ifname
}
${
_addr6
}
fi
fi
# -----------------------------------------------------------
# -----------------------------------------------------------
#
Release softwar
e
#
Format slapos nod
e
# -----------------------------------------------------------
# -----------------------------------------------------------
echo
"Releasing software ..."
csih_inform
"Formating SlapOS Node ..."
/opt/slapos/bin/slapos node software
--verbose
/opt/slapos/bin/slapos node format
-cv
--now
||
csih_error
"Run slapos node format failed. "
# -----------------------------------------------------------
# -----------------------------------------------------------
#
Instance software
#
Request an instance of slapos webrunner
# -----------------------------------------------------------
# -----------------------------------------------------------
echo
"Creating instance ..."
csih_inform
"Supply slaposwebrunner in the computer
${
computer_guid
}
"
/opt/slapos/bin/slapos node instance
--verbose
/opt/slapos/bin/slapos supply slaposwebrunner
${
computer_guid
}
_title
=
"SlapOS-WebRunner-In-
${
computer_guid
}
"
csih_inform
"Request slaposwebrunner instance as
${
_title
}
"
/opt/slapos/bin/slapos request
${
client_configure_file
}
\
${
_title
}
slaposwebrunner
--node
computer_guid
=
${
computer_guid
}
# -----------------------------------------------------------
# -----------------------------------------------------------
#
Send
report
#
Enter loop to release software, create instance,
report
# -----------------------------------------------------------
# -----------------------------------------------------------
echo
"Sending report ..."
_patch_file
=
/etc/slapos/patches/slapos-cookbook-inotifyx.patch
/opt/slapos/bin/slapos node report
--verbose
while
true
;
do
csih_inform
"Releasing software ..."
/opt/slapos/bin/slapos node software
--verbose
||
continue
if
[[
-r
${
_patch_file
}
]]
;
then
for
_x
in
$(
find /opt/slapgrid/
-name
slapos.cookbook-
*
.egg
)
;
do
patch
-d
${
_x
}
-f
--dry-run
-p1
<
${
_patch_file
}
>
/dev/null
&&
csih_inform
"Apply patch
${
_patch_file
}
on
${
_x
}
"
&&
patch
-d
${
_x
}
-p1
<
${
_patch_file
}
)
done
fi
csih_inform
"Creating instance ..."
/opt/slapos/bin/slapos node instance
--verbose
||
continue
csih_inform
"Sending report ..."
/opt/slapos/bin/slapos node report
--verbose
||
continue
get_slapos_webrunner_instance
${
computer_guid
}
${
_title
}
&&
break
done
echo
""
csih_inform
"Run slapos-node script successfully."
echo
""
echo
echo
"Run slapos-node script successfully."
echo
read
-n
1
-t
60
-p
"Press any key to exit..."
read
-n
1
-t
60
-p
"Press any key to exit..."
exit
0
exit
0
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment