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
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Nicolas Wavrant
slapos.package
Commits
a102426b
Commit
a102426b
authored
Jul 04, 2013
by
Jondy Zhao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refine slapos configure scripts
parent
33654f24
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
875 additions
and
668 deletions
+875
-668
windows/scripts/slapos-all-in-one.iss
windows/scripts/slapos-all-in-one.iss
+14
-13
windows/scripts/slapos-configure.sh
windows/scripts/slapos-configure.sh
+282
-493
windows/scripts/slapos-include.sh
windows/scripts/slapos-include.sh
+547
-0
windows/scripts/slapos-node.sh
windows/scripts/slapos-node.sh
+31
-162
windows/scripts/slapos.iss
windows/scripts/slapos.iss
+1
-0
No files found.
windows/scripts/slapos-all-in-one.iss
View file @
a102426b
...
...
@@ -44,23 +44,24 @@ Source: "opt\images\manager.ico"; DestDir: "{app}\cygwin\etc\slapos\images";
Source: "setup.exe"; DestDir: "{app}";
Source: "opt\git\slapos.package\windows\scripts\setup-cygwin.bat"; DestDir: "{app}";
Source: "opt\git\slapos.package\windows\scripts\ip"; DestDir: "{app}\cygwin\bin";
Permissions: readexec;
Source: "opt\git\slapos.package\windows\scripts\useradd"; DestDir: "{app}\cygwin\bin";
Permissions: readexec;
Source: "opt\git\slapos.package\windows\scripts\usermod"; DestDir: "{app}\cygwin\bin";
Permissions: readexec;
Source: "opt\git\slapos.package\windows\scripts\groupadd"; DestDir: "{app}\cygwin\bin";
Permissions: readexec;
Source: "opt\git\slapos.package\windows\scripts\brctl"; DestDir: "{app}\cygwin\bin";
Permissions: readexec;
Source: "opt\git\slapos.package\windows\scripts\tunctl"; DestDir: "{app}\cygwin\bin";
Permissions: readexec;
Source: "opt\git\slapos.package\windows\scripts\cyg_wscript"; DestDir: "{app}\cygwin\usr\local\bin";
Permissions: readexec;
Source: "opt\git\slapos.package\windows\babeld\babeld.exe"; DestDir: "{app}\cygwin\bin";
Permissions: readexec;
Source: "opt\git\slapos.package\windows\openvpn\src\openvpn\.libs\openvpn.exe"; DestDir: "{app}\cygwin\bin";
Permissions: readexec;
Source: "opt\openvpn\bin\*.exe"; DestDir: "{app}\cygwin\bin";
Permissions: readexec;
Source: "opt\openvpn\bin\*.dll"; DestDir: "{app}\cygwin\bin";
Permissions: readexec;
Source: "opt\git\slapos.package\windows\scripts\ip"; DestDir: "{app}\cygwin\bin";
Source: "opt\git\slapos.package\windows\scripts\useradd"; DestDir: "{app}\cygwin\bin";
Source: "opt\git\slapos.package\windows\scripts\usermod"; DestDir: "{app}\cygwin\bin";
Source: "opt\git\slapos.package\windows\scripts\groupadd"; DestDir: "{app}\cygwin\bin";
Source: "opt\git\slapos.package\windows\scripts\brctl"; DestDir: "{app}\cygwin\bin";
Source: "opt\git\slapos.package\windows\scripts\tunctl"; DestDir: "{app}\cygwin\bin";
Source: "opt\git\slapos.package\windows\scripts\cyg_wscript"; DestDir: "{app}\cygwin\usr\local\bin";
Source: "opt\git\slapos.package\windows\babeld\babeld.exe"; DestDir: "{app}\cygwin\bin";
Source: "opt\git\slapos.package\windows\openvpn\src\openvpn\.libs\openvpn.exe"; DestDir: "{app}\cygwin\bin";
Source: "opt\openvpn\bin\*.exe"; DestDir: "{app}\cygwin\bin";
Source: "opt\openvpn\bin\*.dll"; DestDir: "{app}\cygwin\bin";
Source: "opt\openvpn\bin\addtap.bat"; DestDir: "{app}\cygwin\bin";
Source: "opt\openvpn\bin\deltapall.bat"; DestDir: "{app}\cygwin\bin";
Source: "opt\openvpn\driver\*"; DestDir: "{app}\cygwin\etc\slapos\driver";
Source: "opt\git\slapos.package\windows\scripts\slapos-include.sh"; DestDir: "{app}\cygwin\etc\slapos\scripts";
Source: "opt\git\slapos.package\windows\scripts\slapos-node.sh"; DestDir: "{app}\cygwin\etc\slapos\scripts";
Source: "opt\git\slapos.package\windows\scripts\post-install.sh"; DestDir: "{app}\cygwin\etc\slapos\scripts";
Source: "opt\git\slapos.package\windows\scripts\build-slapos.sh"; DestDir: "{app}\cygwin\etc\slapos\scripts";
...
...
windows/scripts/slapos-configure.sh
View file @
a102426b
...
...
@@ -8,13 +8,13 @@
#
# * Install msloop network adapter, named to re6stnet-lo
#
# *
ipv6: Ipv6 configu
re
# *
Check IPv6 protocol and install it if requi
re
#
# *
re6stnet: Install re6stnet and register to nexedi re6stnet if it hasn't
# *
Configure and start cygwin service: cygserver, syslog-ng, sshd
#
# *
node: Create node
configure file by parameters ca/key
# *
config: Create node and client
configure file by parameters ca/key
#
# *
client: Create client configure file by parameters ca/key
# *
re6stnet: Install re6stnet and register to nexedi re6stnet if required
#
# * cron: create cron configure file
#
...
...
@@ -22,230 +22,58 @@
#
# Usage:
#
# ./slapos-configure
# ./slapos-configure [--install | --query | --overwrite | --uninstall]
# [ * | re6stnet | taps | config | cron | startup | runner]
#
export
PATH
=
/usr/local/bin:/usr/bin:
$PATH
# ======================================================================
# Routine: get_system_and_admins_gids
# Get the ADMINs ids from /etc/group and /etc/passwd
# ======================================================================
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() === #
#-------------------------------------------------
# Common functions
#-------------------------------------------------
# The action option:
#
# Return connection name by line, and replace space with '%'
# --install Install only when the item hasn't been installed
# --query Interactive to install all the item
# --overwite Overwrite the item even it has been installed
# --uninstall Remove the configure item
#
function
get_all_connections
()
{
netsh interface ipv6 show interface |
\
grep
"^[ 0-9]
\+
"
|
\
sed
-e
"s/^[ 0-9]
\+
[a-zA-Z]
\+
//"
-e
"s/^
\s
*//"
-e
"s/ /%/g"
}
# Default is --install
#
# Check all the connection names, and compare the original connection
# list, return the new connection name
# The configure item option:
#
# If nothing found, return empty
# If more than one, return the first one
# * All the configure item
# re6stnet Install re6stent and dependencies
# taps Install OpenVPN Tap-Windows Driver for re6stnet
# config Generate slapos node and client configure files
# cron Generate cron file and start cron job
# startup Run slapos-configure.sh on windows startup
# runner Install web runner for this node
#
function
get_new_connection
()
{
original_connections
=
"
$*
"
current_connections
=
$(
get_all_connections
)
for
name
in
$current_connections
;
do
[[
!
"
$original_connections
"
==
*
[
\
]
$name
[
\
]
*
]]
&&
\
echo
${
name
//%/
}
&&
return
0
done
}
source
$(
dirname
$0
)
/slapos-include.sh
check_administrator_right
#
# Remove all ipv4/ipv6 addresses in the connection re6stnet-lo
#
function
reset_connection
()
{
ifname
=
${
1
-re6stnet-lo
}
for
addr
in
$(
netsh interface ipv6 show address
$ifname
level
=
normal |
\
grep
"^Manual"
|
\
sed
-e
"s/^
\(\w\+\s\+\)\{
4
\}
//"
)
;
do
netsh interface ipv6 del address
$ifname
$addr
if
[[
!
":
$PATH
"
==
:/opt/slapos/bin:
]]
;
then
for
profile
in
~/.bash_profile ~/.profile
;
do
grep
-q
"export PATH=/opt/slapos/bin:"
$profile
||
\
echo
"export PATH=/opt/slapos/bin:
$$
PATH"
>>
$profile
done
netsh interface ip
set
address
$ifname
source
=
dhcp
# for addr in $(netsh interface ip show address $ifname | \
# grep "IP Address:" | \
# sed -e "s/IP Address://") ; do
# netsh interface del address $ifname $addr
# done
}
#
# Transfer connection name to GUID
#
function
connection2guid
()
{
ifname
=
${
1
-re6stnet-lo
}
#
# This command doesn't work in the Windows 7, Window 8, maybe
# Vista. Because no guid information in these platforms.
#
# netsh interface ipv6 show interface $ifname | \
# grep "^GUID\s*:" | \
# sed -e "s/^GUID\s*:\s*//"
#
# So we use getmac to repleace it:
getmac /fo list /v |
grep
-A3
"^Connection Name: *
$ifname
\$
"
\
|
grep
"^Transport Name:"
|
sed
-e
"s/^.*Tcpip_//g"
}
#
# Show error message and waiting for user to press any key quit
#
function
show_error_exit
()
{
msg
=
${
1
-Failed to configure Slapos Node in this computer.
}
echo
$msg
read
-n
1
-p
"Press any key to exit..."
exit
1
}
function
check_service_state
()
{
service_name
=
$1
service_state
=
$(
cygrunsrv
--query
$service_name
|
sed
-n
-e
's/^Current State[ :]*//p'
)
echo
Cygwin
$service_name
service state:
$service_state
if
[[
!
x
$service_state
==
"xRunning"
]]
;
then
echo
Starting
$service_name
service ...
net start
$service_name
||
show_error_exit
"Failed to start
$service_name
service"
echo
Start
$service_name
service OK.
else
echo
Cygwin
$service_name
service is running.
fi
}
#
# Check ipv6 connection by default ipv6 route
#
function
check_ipv6_connection
()
{
netsh interface ipv6 show route |
grep
-q
" ::/0 "
}
#
# 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
}
#-------------------------------------------------
# Check adminsitrator rights
#-------------------------------------------------
get_system_and_admins_ids
||
show_error_exit
"Failed to get uids of system and amdinistrator account."
id
|
grep
-q
"
$ADMINSUID
(Administrators)"
||
show_error_exit
"Error: Administrator right required to run this script."
fi
for
myprofile
in
~/.bash_profile ~/.profile
;
do
grep
-q
"export CYGWIN=server"
$myprofile
||
echo
"export CYGWIN=server"
>>
$myprofile
grep
-q
"export PATH=/opt/slapos/bin:"
$myprofile
||
echo
"export PATH=/opt/slapos/bin:
$$
PATH"
>>
$myprofile
done
# cygrunsrv
# devcon
# openssl
# export WINDIR
#-------------------------------------------------
# Constants
#-------------------------------------------------
slapos_client_home
=
~/.slapos
client_configure_file
=
$slapos_client_home
/slapos.cfg
client_certificate_file
=
$slapos_client_home
/certificate
client_key_file
=
$slapos_client_home
/key
client_template_file
=
/etc/slapos/slapos-client.cfg.example
url_client_template_file
=
http://git.erp5.org/gitweb/slapos.core.git/blob_plain/HEAD:/slapos-client.cfg.example
node_certificate_file
=
/etc/opt/slapos/ssl/computer.crt
node_key_file
=
/etc/opt/slapos/ssl/computer.key
node_config_file
=
/etc/opt/slapos/slapos.cfg
node_template_file
=
/etc/slapos/slapos.cfg.example
url_node_template_file
=
http://git.erp5.org/gitweb/slapos.core.git/blob_plain/HEAD:/slapos.cfg.example
slapos_ifname
=
re6stnet-lo
# Hope it will not confilct with original network in the local machine
ipv4_local_network
=
10.201.67.0/24
slapos_runner_file
=
/etc/slapos/scripts/slap-runner.html
slaprunner_cfg
=
http://git.erp5.org/gitweb/slapos.git/blob_plain/refs/heads/cygwin-0:/software/slaprunner/software.cfg
netdrive_reporter_cfg
=
http://git.erp5.org/gitweb/slapos.git/blob_plain/refs/heads/cygwin-0:/software/netdrive-reporter/software.cfg
wordpress_cfg
=
http://git.erp5.org/gitweb/slapos.git/blob_plain/refs/heads/cygwin:/software/wordpress/software.cfg
#-------------------------------------------------
# -----------------------------------------------------------
# Create paths
#-------------------------------------------------
# -----------------------------------------------------------
mkdir
-p
/etc/opt/slapos/ssl/partition_pki
mkdir
-p
$slapos_client_home
mkdir
-p
/opt/slapos/log
mkdir
-p
/etc/slapos/scripts
mkdir
-p
/etc/re6stnet
#-------------------------------------------------
# Configure cygwin server services
#-------------------------------------------------
echo
Checking cygserver service ...
# -----------------------------------------------------------
# Configure cygwin services: cygserver syslog-ng sshd
# -----------------------------------------------------------
echo
echo
Starting configure cygwin services ...
echo
cygrunsrv
--query
cygserver
>
/dev/null 2>&1
if
((
$?
))
;
then
echo
Run cygserver-config ...
...
...
@@ -266,15 +94,16 @@ else
echo
The syslog-ng service has been installed.
fi
check_service_state syslog-ng
echo
echo
Configure cygwin services OK.
echo
#-------------------------------------------------
# Configure slapos network
#-------------------------------------------------
#
# Add msloop network adapter, ane name it as "re6stnet-lo"
#
echo
Checking slapos network adapter:
$slapos_ifname
...
# -----------------------------------------------------------
# Install network connection used by slapos node
# -----------------------------------------------------------
echo
echo
Starting configure slapos network ...
echo
original_connections
=
$(
echo
$(
get_all_connections
))
if
[[
!
"
$original_connections
"
==
*
[
\
]
$slapos_ifname
[
\
]
*
]]
;
then
echo
Installing slapos network adapter ...
...
...
@@ -283,174 +112,145 @@ if [[ ! " $original_connections " == *[\ ]$slapos_ifname[\ ]* ]] ; then
[[
"X
$connection_name
"
==
"X"
]]
&&
\
show_error_exit
"Add msloop network adapter failed."
echo
netsh interface
set
interface
name
=
"
$connection_name
"
newname
=
"
$slapos_ifname
"
netsh interface
set
interface
name
=
"
$connection_name
"
newname
=
"
$slapos_ifname
"
||
\
show_error_exit
"Failed to rename connection to
$slapos_ifname
."
interface_guid
=
$(
connection2guid
$slapos_ifname
)
||
\
show_error_exit
"Failed to get guid of interface:
$slapos_ifname
."
fi
#ip -4 addr add $ipv4_local_network dev $slapos_ifname
# reset_connection $slapos_ifname
echo
SlapOS network adapter OK.
echo
Slapos ipv4_local_network is
$ipv4_local_network
echo
" Slapos ipv4_local_network is
$ipv4_local_network
"
echo
" If it confilcts with your local network, change it in the file:"
echo
"
$(
dirname
$0
)
/slapos-include.sh"
echo
echo
Configure slapos network OK.
echo
#-------------------------------------------------
# Generate slapos node configure file
#-------------------------------------------------
# -----------------------------------------------------------
# Check IPv6 protocol, install it if it isn't installed
# -----------------------------------------------------------
echo
echo
Starting configure IPv6 protocol ...
echo
netsh interface ipv6 show interface
>
/dev/null
||
\
netsh interface ipv6
install
||
\
show_error_exit
"Failed to install IPv6 protocol."
echo
echo
Configure IPv6 protocol OK.
echo
# -----------------------------------------------------------
# config: Generate slapos node and client configure file
# -----------------------------------------------------------
echo
echo
Starting configure section config ...
echo
[[
-r
$node_template_file
&&
-r
$client_template_file
]]
||
\
create_template_configure_file
||
\
show_error_exit
"Failed to create template configure file."
echo
Checking computer certificate file ...
if
[[
!
-f
$node_certificate_file
]]
;
then
read
-p
"Where is computer certificate file (/computer.crt): "
certificate_fil
e
[[
X
$certificate_file
==
X
]]
&&
certificate_file
=
/computer.crt
[[
!
-
f
"
$certificate_fil
e
"
]]
&&
\
show_error_exit
"C
ertificate file
$certificate_fil
e
doesn't exists."
echo
"Copy certificate from
$
certificate_fil
e
to
$node_certificate_file
"
certificate_file
=
$(
cygpath
-u
$certificate_fil
e
)
cp
$
certificate_fil
e
$node_certificate_file
read
-p
"Where is computer certificate file (/computer.crt): "
filenam
e
[[
-z
$filenname
]]
&&
filename
=
"/computer.crt"
[[
!
-
r
"
$filenam
e
"
]]
&&
\
show_error_exit
"C
omputer certificate file
$filenam
e
doesn't exists."
echo
"Copy certificate from
$
filenam
e
to
$node_certificate_file
"
filename
=
$(
cygpath
-u
$filenam
e
)
cp
$
filenam
e
$node_certificate_file
else
echo
Found computer certificate file:
$node_certificate_file
echo
"Found computer certificate file:
$node_certificate_file
"
fi
openssl x509
-noout
-in
$node_certificate_file
||
\
show_error_exit
"Invalid computer certificate:
$node_certificate_file
."
echo
Check computer certificate OK.
echo
Checking computer guid ...
computer_id
=
$(
grep
CN
=
COMP
$node_certificate_file
|
sed
-e
"s/^.*, CN=//g"
|
sed
-e
"s%/emailAddress.*
\$
%%g"
)
[[
"
$computer_id
"
==
COMP-+
([
0-9]
)
]]
||
\
show_error_exit
"Invalid computer id specified."
echo
Computer GUID is:
$computer_id
echo
Checking computer key file ...
if
[[
!
-f
$node_key_file
]]
;
then
read
-p
"Where is computer key file (/computer.key): "
key_fil
e
[[
X
$key_file
==
X
]]
&&
key_file
=
/computer.key
[[
!
-f
"
$
key_fil
e
"
]]
&&
\
show_error_exit
"Key file
$
key_fil
e
doesn't exists."
echo
"Copy key from
$
key_fil
e
to
$node_key_file
"
key_file
=
$(
cygpath
-u
$key_fil
e
)
cp
$
key_fil
e
$node_key_file
read
-p
"Where is computer key file (/computer.key): "
filenam
e
[[
-z
$filename
]]
&&
filename
=
"/computer.key"
[[
!
-f
"
$
filenam
e
"
]]
&&
\
show_error_exit
"Key file
$
filenam
e
doesn't exists."
echo
"Copy key from
$
filenam
e
to
$node_key_file
"
filename
=
$(
cygpath
-u
$filenam
e
)
cp
$
filenam
e
$node_key_file
else
echo
Found computer key file:
$node_key_file
echo
"Found computer key file:
$node_key_file
"
fi
openssl rsa
-noout
-in
$node_key_file
-check
||
\
show_error_exit
"Invalid computer key:
$node_key_file
."
echo
Check computer key OK.
show_error_exit
"Invalid node key:
$node_key_file
."
# Create node configure file, replace interface_name with guid of
# re6stnet-lo
echo
Checking computer configure file ...
if
[[
!
-f
$node_config_file
]]
;
then
[[
-f
$node_template_file
]]
||
\
(
cd
/etc/slapos
;
wget
$url_node_template_file
-O
$node_template_file
)
||
\
show_error_exit
"Download slapos.cfg.example failed."
echo
"Copy computer configure file from
$node_template_file
to
$node_config_file
"
cp
$node_template_file
$node_config_file
fi
interface_guid
=
$(
connection2guid
$slapos_ifname
)
||
\
[[
-z
$interface_guid
]]
&&
\
interface_guid
=
$(
sed
-n
-e
"s/^
\\
sinterface_name
\\
s*=
\\
s*//p"
$node_config_file
)
[[
-z
$interface_guid
]]
&&
\
interface_guid
=
$(
connection2guid
$slapos_ifname
)
[[
-z
$interface_guid
]]
&&
\
show_error_exit
"Failed to get guid of interface:
$slapos_ifname
."
computer_guid
=
$(
grep
"CN=COMP"
$node_certificate_file
|
\
sed
-e
"s/^.*, CN=//g"
|
sed
-e
"s%/emailAddress.*
\$
%%g"
)
[[
"
$computer_guid
"
==
COMP-+
([
0-9]
)
]]
||
\
show_error_exit
"Invalid computer id '
$computer_guid
' specified."
echo
"Computer configuration information:"
echo
" interface name:
$slapos_ifname
"
echo
" GUID:
$interface_guid
"
echo
" ipv4_local_network:
$ipv4_local_network
"
echo
" computer_id:
$computer_id
"
# generate /etc/slapos/slapos.cfg
echo
" computer_id:
$computer_guid
"
sed
-i
-e
"s%^
\\
s*interface_name.*
$%
interface_name =
$interface_guid
%"
\
-e
"s%^#
\?\\
s*ipv6_interface.*
$%
# ipv6_interface =%g"
\
-e
"s%^ipv4_local_network.*
$%
ipv4_local_network =
$ipv4_local_network
%"
\
-e
"s%^computer_id.*
$%
computer_id =
$computer_id
%"
\
-e
"s%^computer_id.*
$%
computer_id =
$computer_
gu
id
%"
\
$node_config_file
echo
Check computer configure file OK.
#-------------------------------------------------
# Generate slapos client configure file
#-------------------------------------------------
echo
Checking client certificate file ...
if
[[
!
-f
$client_certificate_file
]]
;
then
read
-p
"Where is client certificate file (/certificate): "
certificate_fil
e
[[
X
$certificate_file
==
X
]]
&&
certificate_file
=
/certificate
[[
!
-f
"
$
certificate_fil
e
"
]]
&&
\
show_error_exit
"C
ertificate file
$certificate_fil
e
doesn't exists."
echo
"Copy client certificate from
$
certificate_fil
e
to
$client_certificate_file
"
certificate_file
=
$(
cygpath
-u
$
certificate_fil
e
)
cp
$
certificate_fil
e
$client_certificate_file
read
-p
"Where is client certificate file (/certificate): "
filenam
e
[[
-z
$filename
]]
&&
certificate_file
=
"/certificate"
[[
!
-f
"
$
filenam
e
"
]]
&&
\
show_error_exit
"C
lient certificate file
$filenam
e
doesn't exists."
echo
"Copy client certificate from
$
filenam
e
to
$client_certificate_file
"
certificate_file
=
$(
cygpath
-u
$
filenam
e
)
cp
$
filenam
e
$client_certificate_file
fi
openssl x509
-noout
-in
$client_certificate_file
||
\
show_error_exit
"Invalid client certificate:
$client_certificate_file
."
echo
Check client certificate Ok.
echo
Checking client key file ...
if
[[
!
-f
$client_key_file
]]
;
then
read
-p
"Where is client key file (/key): "
key_fil
e
[[
X
$key_file
==
X
]]
&&
key_file
=
/key
[[
!
-f
"
$
key_fil
e
"
]]
&&
\
show_error_exit
"Key file
$
key_fil
e
doesn't exists."
echo
"Copy client key from
$
key_fil
e
to
$client_key_file
"
key_file
=
$(
cygpath
-u
$
key_fil
e
)
cp
$
key_fil
e
$client_key_file
read
-p
"Where is client key file (/key): "
filenam
e
[[
-z
$filename
]]
&&
key_file
=
"/key"
[[
!
-f
"
$
filenam
e
"
]]
&&
\
show_error_exit
"Key file
$
filenam
e
doesn't exists."
echo
"Copy client key from
$
filenam
e
to
$client_key_file
"
key_file
=
$(
cygpath
-u
$
filenam
e
)
cp
$
filenam
e
$client_key_file
fi
openssl rsa
-noout
-in
$client_key_file
-check
||
\
show_error_exit
"Invalid client key:
$client_key_file
."
echo
Checking computer key OK.
echo
Checking client configure file ...
if
[[
!
-f
$client_configure_file
]]
;
then
cat
<<
EOF
>
$client_configure_file
[slapos]
master_url = https://slap.vifib.com/
[slapconsole]
# Put here retrieved certificate from SlapOS Master.
# Beware: put certificate from YOUR account, not the one from your node.
# You (as identified person from SlapOS Master) will request an instance, node your node.
# Conclusion: node certificate != person certificate.
cert_file = certificate file location coming from your slapos master account
key_file = key file location coming from your slapos master account
# Below are softwares maintained by slapos.org and contributors
alias =
apache_frontend http://git.erp5.org/gitweb/slapos.git/blob_plain/HEAD:/software/apache-frontend/software.cfg
dokuwiki http://git.erp5.org/gitweb/slapos.git/blob_plain/refs/tags/slapos-0.158:/software/dokuwiki/software.cfg
drupal http://git.erp5.org/gitweb/slapos.git/blob_plain/refs/tags/slapos-0.151:/software/erp5/software.cfg
erp5 http://git.erp5.org/gitweb/slapos.git/blob_plain/refs/tags/slapos-0.143:/software/erp5/software.cfg
erp5_branch http://git.erp5.org/gitweb/slapos.git/blob_plain/refs/heads/erp5:/software/erp5/software.cfg
fengoffice http://git.erp5.org/gitweb/slapos.git/blob_plain/refs/tags/slapos-0.158:/software/fengoffice/software.cfg
kumofs http://git.erp5.org/gitweb/slapos.git/blob_plain/refs/tags/slapos-0.141:/software/kumofs/software.cfg
kvm http://git.erp5.org/gitweb/slapos.git/blob_plain/refs/tags/slapos-0.156:/software/kvm/software.cfg
maarch http://git.erp5.org/gitweb/slapos.git/blob_plain/refs/tags/slapos-0.159:/software/maarch/software.cfg
mariadb http://git.erp5.org/gitweb/slapos.git/blob_plain/refs/tags/slapos-0.152:/software/mariadb/software.cfg
memcached http://git.erp5.org/gitweb/slapos.git/blob_plain/refs/tags/slapos-0.82:/software/memcached/software.cfg
mysql http://git.erp5.org/gitweb/slapos.git/blob_plain/refs/tags/slapos-0.65:/software/mysql-5.1/software.cfg
opengoo http://git.erp5.org/gitweb/slapos.git/blob_plain/refs/tags/slapos-0.158:/software/opengoo/software.cfg
postgresql http://git.erp5.org/gitweb/slapos.git/blob_plain/refs/tags/slapos-0.157:/software/postgres/software.cfg
slaposwebrunner http://git.erp5.org/gitweb/slapos.git/blob_plain/refs/heads/cygwin-0:/software/slaprunner/software.cfg
slaposwebrunner_lite http://git.erp5.org/gitweb/slapos.git/blob_plain/refs/heads/cygwin-0:/software/slaprunner-lite/software.cfg
wordpress http://git.erp5.org/gitweb/slapos.git/blob_plain/refs/heads/cygwin:/software/wordpress/software.cfg
xwiki http://git.erp5.org/gitweb/slapos.git/blob_plain/refs/tags/slapos-0.46:/software/xwiki/software.cfg
zabbixagent http://git.erp5.org/gitweb/slapos.git/blob_plain/refs/tags/slapos-0.162:/software/zabbix-agent/software.cfg
netdrive_reporter http://git.erp5.org/gitweb/slapos.git/blob_plain/refs/heads/cygwin-0:/software/netdrive-reporter/software.cfg
demoapp http://git.erp5.org/gitweb/slapos.git/blob_plain/refs/heads/cygwin-0:/software/demoapp/software.cfg
EOF
echo
"Client configure file
$client_config_file
created."
echo
"Copy client configure file from
$client_template_file
to
$client_config_file
"
cp
$client_template_file
$client_config_file
fi
echo
Client configuration information:
echo
client certificate file:
$client_certificate_file
echo
client key file:
$client_key_file
echo
echo
"Client configuration information:"
echo
" client certificate file:
$client_certificate_file
"
echo
" client key file:
$client_key_file
"
sed
-i
-e
"s%^cert_file.*
$%
cert_file =
$client_certificate_file
%"
\
-e
"s%^key_file.*
$%
key_file =
$client_key_file
%"
\
$client_configure_file
echo
Check client configure file OK.
#-------------------------------------------------
# Re6stnet
#-------------------------------------------------
echo
echo
Configure section config OK.
echo
# Check ipv6, install it if it isn't installed.
echo
Checking ipv6 protocol ...
netsh interface ipv6 show interface
>
/dev/null
||
netsh interface ipv6
install
||
\
show_error_exit
"Failed to install ipv6 protocol."
echo
IPv6 protocol has been installed.
# -----------------------------------------------------------
# re6stnet: Install required packages and register to nexedi
# -----------------------------------------------------------
echo
echo
Starting configure section re6stnet ...
echo
# miniupnpc is required by re6stnet
echo
Checking miniupnpc ...
if
[[
!
-d
/opt/miniupnpc
]]
;
then
[[
-f
/miniupnpc.tar.gz
]]
||
show_error_exit
"No package found: /miniupnpc.tar.gz"
...
...
@@ -466,7 +266,6 @@ else
echo
Check miniupnpc OK.
fi
# pyOpenSSL is required by re6stnet
echo
Checking pyOpenSSL ...
if
[[
!
-d
/opt/pyOpenSSL
]]
;
then
[[
-f
/pyOpenSSL.tar.gz
]]
||
show_error_exit
"No package found: /pyOpenSSL.tar.gz"
...
...
@@ -481,7 +280,6 @@ else
echo
Check pyOpenSSL OK.
fi
# Install re6stnet
echo
Checking re6stnet ...
if
[[
!
-d
/opt/re6stnet
]]
;
then
echo
"Installing re6stnet ..."
...
...
@@ -500,64 +298,83 @@ else
echo
Check re6stnet OK.
fi
echo
Checking re6stent configuration ...
mkdir
-p
/etc/re6stnet
cd
/etc/re6stnet
if
[[
!
-f
re6stnet.conf
]]
;
then
echo
Register to http://re6stnet.nexedi.com ...
echo
Checking re6stnet configuration ...
if
[[
!
-r
$re6stnet_configure_file
]]
;
then
echo
"Registering to http://re6stnet.nexedi.com ..."
cd
$(
dirname
$re6stnet_configure_file
)
# Your subnet: 2001:67c:1254:e:19::/80 (CN=917529/32)
mysubnet
=
$(
re6st-conf
--registry
http://re6stnet.nexedi.com/
--anonymous
|
grep
"^Your subnet:"
)
\
||
show_error_exit
"Register to nexedi re6stnet failed"
echo
Register OK.
echo
echo
$mysubnet
echo
echo
Write subnet information to re6stnet.conf
echo
"#
$mysubnet
"
>>
re6stnet.conf
echo
Write
"table 0"
to re6stnet.conf
echo
"table 0"
>>
re6stnet.conf
echo
"ovpnlog"
>>
re6stnet.conf
echo
"interface
$slapos_ifname
"
>>
re6stnet.conf
echo
"main-interface
$slapos_ifname
"
>>
re6stnet.conf
echo
"log
$(
cygpath
-m
/var/log/re6stnet
)
"
subnet
=
$(
re6st-conf
--registry
http://re6stnet.nexedi.com/
--anonymous
|
\
grep
"^Your subnet:"
)
||
\
show_error_exit
"Register to nexedi re6stnet failed"
[[
-r
re6stnet.conf
]]
||
\
show_error_exit
"No
$re6stnet_configure_file
found."
echo
Register re6stnet OK.
echo
"Write information to re6stnet.conf:"
echo
" #
$subnet
"
echo
" table 0"
echo
" ovpnlog"
echo
" main-interface
$slapos_ifname
"
echo
" interface
$slapos_ifname
"
echo
" log
$(
cygpath
-m
/var/log/re6stnet
)
"
echo
-e
"#
$subnet
\n
table 0
\n
ovpnlog"
\
"
\n
main-interface
$slapos_ifname
\n
interface
$slapos_ifname
"
\
"
\n
log
$(
cygpath
-m
/var/log/re6stnet
)
"
\
>>
$re6stnet_configure_file
fi
# Run re6stnet if no native ipv6
if
check_re6stnet_needed
;
then
check_re6stnet_configure
||
exit
1
if
[[
!
-r
${
re6stnet_cgywin_script
}
]]
;
then
cat
<<
EOF
> /
${
re6stnet_cgywin_script
}
$(
cygpath
-w
/bin/bash.exe
)
--login -c 'python %*'
EOF
chmod
+x
${
re6stnet_cgywin_script
}
fi
if
!
cygrunsrv
--query
$re6stnet_service_name
>
/dev/null 2>&1
;
then
cygrunsrv
-I
$re6stnet_service_name
-c
$(
dirname
$re6stnet_configure_file
)
\
-p
$(
which re6stnet
)
-a
"@re6stnet.conf"
-d
"CYGWIN re6stnet"
||
\
show_error_exit
"Failed to install cygwin service
$re6stnet_service_name
."
fi
check_cygwin_service
$re6stnet_service_name
||
exit
1
echo
"You can check log files in the /var/log/re6stnet/*.log"
else
echo
"Native IPv6 found, no re6stnet required."
fi
[[
!
-f
re6stnet.conf
]]
&&
\
show_error_exit
"Failed to register to nexedi re6stnet: no /etc/re6stnet/re6stnet.conf found."
grep
-q
"^table 0"
re6stnet.conf
||
\
show_error_exit
"Error: no parameter 'table 0' found in the /etc/re6stnet/re6stnet.conf"
grep
-q
"^# Your subnet: "
re6stnet.conf
||
\
show_error_exit
"Error: no subnet found in the /etc/re6stnet/re6stnet.conf"
echo
Check re6stnet configuration OK.
echo
#-------------------------------------------------
# Create openvpn tap-windows drivers used by re6stnet
#-------------------------------------------------
echo
echo
Configure section re6stnet OK.
echo
# -----------------------------------------------------------
# taps: Install openvpn tap-windows drivers used by re6stnet
# -----------------------------------------------------------
#
# Adding tap-windows driver will break others, so we add all drivers
# here. Get re6stnet client count, then remove extra drivers and add
# required drivers.
#
echo
echo
Installing OpenVPN Tap-Windows Driver
...
echo
Starting configure section taps
...
echo
original_connections
=
$(
echo
$(
get_all_connections
))
client_count
=
$(
sed
-n
-e
"s/^client-count *//p"
/etc/re6stnet/re6stnet.conf
)
client_count
=
$(
sed
-n
-e
"s/^client-count *//p"
$re6stnet_configure_file
)
[[
-z
$client_count
]]
&&
client_count
=
10
echo
Re6stnet client count
=
$client_count
echo
" Client count:
$client_count
"
re6stnet_name_list
=
"re6stnet-tcp re6stnet-udp"
for
((
i
=
1
;
i<
=
client_count
;
i
=
i+1
))
;
do
re6stnet_name_list
=
"
$re6stnet_name_list
re6stnet
$i
"
done
for
re6stnet_ifname
in
$re6stnet_name_list
;
do
echo
Checking interface
$re6stnet_ifname
...
if
[[
!
"
$original_connections
"
==
*
[
\
]
$re6stnet_ifname
[
\
]
*
]]
;
then
echo
Installing interface
$re6stnet_ifname
...
ip vpntap add dev
$re6stnet_ifname
||
show_error_exit
"Failed to install openvpn tap-windows driver."
echo
Interface
$re6stnet_ifname
installed.
for
name
in
$re6stnet_name_list
;
do
echo
"Checking interface
$name
..."
if
[[
!
"
$original_connections
"
==
*
[
\
]
$name
[
\
]
*
]]
;
then
echo
"Installing interface
$name
..."
ip vpntap add dev
$name
||
\
show_error_exit
"Failed to install OpenVPN Tap-Windows Driver."
echo
"Interface
$name
installed."
else
echo
$re6stnet_ifname
has been installed.
echo
"
$name
has been installed."
fi
done
#
...
...
@@ -565,96 +382,56 @@ done
#
# ip vpntap del dev re6stnet-x
#
echo
echo
Configure section taps OK.
echo
#-------------------------------------------------
# IPv6 Connection
#-------------------------------------------------
echo
"Checking native IPv6 ..."
check_ipv6_connection
# Run re6stnet if no native ipv6
if
((
$?
))
;
then
re6stnet_script
=
/etc/re6stnet/ovpn-cygwin.bat
service_name
=
slapos-re6stnet
echo
No native IPv6.
echo
Check re6stnet network ...
which re6stnet
>
/dev/null 2>&1
||
show_error_exit
"Error: no re6stnet installed, please run Configure SlapOS first."
if
[[
!
-f
${
re6stnet_script
}
]]
;
then
cat
<<
EOF
> /
${
re6stnet_script
}
$(
cygpath
-w
/bin/bash.exe
)
--login -c 'python %*'
EOF
fi
chmod
+x
${
re6stnet_script
}
# re6st-conf --registry http://re6stnet.nexedi.com/ --is-needed
cygrunsrv
--query
$service_name
>
/dev/null 2>&1
if
((
$?
))
;
then
[[
-d
/var/log/re6stnet
]]
||
mkdir
-p
/var/log/re6stnet
echo
"Install slapos-re6stnet service ..."
cygrunsrv
-I
$service_name
-c
/etc/re6stnet
-p
$(
which re6stnet
)
-a
"@re6stnet.conf"
||
\
show_error_exit
"Failed to install
$service_name
service."
echo
"Cygwin
$service_name
service installed."
# echo "Waiting re6stent network work ..."
# while true ; do
# check_ipv6_connection && break
# done
fi
service_state
=
$(
cygrunsrv
--query
$service_name
|
sed
-n
-e
's/^Current State[ :]*//p'
)
if
[[
!
x
$service_state
==
"xRunning"
]]
;
then
echo
"Starting
$service_name
service ..."
cygrunsrv
--start
$service_name
||
show_error_exit
"Failed to start
$service_name
service."
service_state
=
$(
cygrunsrv
--query
$service_name
|
sed
-n
-e
's/^Current State[ :]*//p'
)
fi
[[
x
$service_state
==
"xRunning"
]]
||
show_error_exit
"Failed to start
$service_name
service."
echo
Cygwin
$service_name
service is running.
echo
"You can check log files in the /var/log/re6stnet/*.log"
echo
echo
"re6stnet network OK."
else
echo
"Native IPv6 Found."
fi
#-------------------------------------------------
# Create instance of Web Runner
#-------------------------------------------------
slaprunner_title
=
"SlapOS-Node-Runner-In-
$computer_id
"
grep
-q
"window.location.href"
$slapos_runner_file
if
((
$?
))
;
then
echo
echo
Installing Web Runner ...
echo
# -----------------------------------------------------------
# runner: Create instance of slap web runner
# -----------------------------------------------------------
echo
echo
Starting configure section runner ...
echo
slaprunner_title
=
"SlapOS-Node-Runner-In-
$computer_guid
"
feature_code
=
"#-*- SlapOS Web Runner JavaScript Boot Code -*-#"
if
!
grep
-q
-F
"
$feature_code
"
$slapos_runner_file
;
then
echo
Installing SlapOS Web Runner ...
re6stnet_ipv6
=
$(
cat
/etc/re6stnet/re6stnet.conf |
grep
"Your subnet"
|
\
if
[[
-r
$re6stnet_configure_file
]]
;
then
re6stnet_ipv6
=
$(
grep
"Your subnet"
$re6stnet_configure_file
|
\
sed
-e
"s/^.*subnet: //g"
-e
"s/
\/
80 (CN.*
\$
/1/g"
)
if
[[
!
-z
$re6stnet_ipv6
]]
;
then
echo
"Re6stnet address in this computer:
$re6stnet_ipv6
"
netsh interface ipv6 show addr
$slapos_ifname
level
=
normal |
grep
-q
$re6stnet_ipv6
||
\
netsh interface ipv6 show addr
$slapos_ifname
level
=
normal |
\
grep
-q
$re6stnet_ipv6
||
\
netsh interface ipv6 add addr
$slapos_ifname
$re6stnet_ipv6
echo
Run slapformat ...
/opt/slapos/bin/slapos node format
-cv
--now
||
fi
fi
/opt/slapos/bin/slapos node format
-cv
--now
||
\
show_error_exit
"Failed to run slapos format."
echo
echo
"Supply
$slaprunner_cfg
in the computer
$computer_id
"
/opt/slapos/bin/slapos supply
$slaprunner_cfg
$computer_id
echo
"Supply
$slaprunner_cfg
in the computer
$computer_guid
"
/opt/slapos/bin/slapos supply
$slaprunner_cfg
$computer_guid
echo
"Request an instance
$slaprunner_title
..."
patch_file
=
/etc/slapos/patches/slapos-cookbook-inotifyx.patch
while
true
;
do
/opt/slapos/bin/slapos node software
--verbose
# Apply patches to slapos.cookbook for inotifix
if
[[
-
f
$patch_file
]]
;
then
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
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
/opt/slapos/bin/slapos request
$client_config_file
$slaprunner_title
$slaprunner_cfg
--node
computer_guid
=
$computer_id
&&
break
sleep
5
/opt/slapos/bin/slapos request
$client_config_file
$slaprunner_title
\
$slaprunner_cfg
--node
computer_guid
=
$computer_guid
&&
break
sleep
3
done
# Connection parameters of instance are:
# {'backend_url': 'http://[2001:67c:1254:45::c5d5]:50000',
...
...
@@ -662,10 +439,12 @@ if (( $? )) ; then
# 'password_recovery_code': 'e2d01c14',
# 'ssh_command': 'ssh 2001:67c:1254:45::c5d5 -p 2222',
# 'url': 'http://softinst39090.host.vifib.net/'}
slaprunner_url
=
$(
/opt/slapos/bin/slapos request
$client_config_file
$slaprunner_title
$slaprunner_cfg
--node
computer_guid
=
$computer_id
|
\
slaprunner_url
=
$(
/opt/slapos/bin/slapos request
$client_config_file
\
$slaprunner_title
$slaprunner_cfg
--node
computer_guid
=
$computer_guid
|
\
grep
backend_url |
sed
-e
"s/^.*': '//g"
-e
"s/',.*
$/
/g"
)
echo
Got node runner url:
$slaprunner_url
[[
-z
$slaprunner_url
]]
&&
show_error_exit
"Failed to create instance of SlapOS Web Runner."
echo
"SlapOS Web Runner URL:
$slaprunner_url
"
[[
-z
$slaprunner_url
]]
&&
\
show_error_exit
"Failed to create instance of SlapOS Web Runner."
cat
<<
EOF
>
$slapos_runner_file
<html>
...
...
@@ -679,69 +458,79 @@ function openwin() {
</script>
</head>
<body onload="openwin()"/>
<!--
$feature_code
-->
</html>
EOF
echo
Generate file:
$slapos_runner_file
echo
SlapOS Web Runner boot file
$slapos_runner_file
generated.
echo
echo
Install Web Runner OK.
echo
fi
echo
echo
Configure section runner OK.
echo
#-------------------------------------------------
# Configure crontab
#-------------------------------------------------
crontab_file
=
/var/cron/tabs/
$(
whoami
)
if
[[
!
-f
$crontab_file
]]
;
then
# -----------------------------------------------------------
# tab: Install cron service and create crontab
# -----------------------------------------------------------
echo
echo
Starting configure section cron ...
echo
crontab_file
=
"/var/cron/tabs/
${
USER
}
"
if
[[
!
-r
$crontab_file
]]
;
then
cat
<<
EOF
>
$crontab_file
SHELL=/bin/bash
PATH=/usr/local/bin:/usr/bin:/usr/sbin:/sbin:/bin
MAILTO=""
# Run "Installation/Destruction of Software Releases" and "Deploy/Start/Stop Partitions" once per minute
* * * * *
Administrator
/opt/slapos/bin/slapos node software --verbose --logfile=/opt/slapos/log/slapos-node-software.log > /dev/null 2>&1
* * * * *
Administrator
/opt/slapos/bin/slapos node instance --verbose --logfile=/opt/slapos/log/slapos-node-instance.log > /dev/null 2>&1
* * * * *
${
USER
}
/opt/slapos/bin/slapos node software --verbose --logfile=/opt/slapos/log/slapos-node-software.log > /dev/null 2>&1
* * * * *
${
USER
}
/opt/slapos/bin/slapos node instance --verbose --logfile=/opt/slapos/log/slapos-node-instance.log > /dev/null 2>&1
# Run "Destroy Partitions to be destroyed" once per hour
0 * * * *
Administrator
/opt/slapos/bin/slapos node report --maximal_delay=3600 --verbose --logfile=/opt/slapos/log/slapos-node-report.log > /dev/null 2>&1
0 * * * *
${
USER
}
/opt/slapos/bin/slapos node report --maximal_delay=3600 --verbose --logfile=/opt/slapos/log/slapos-node-report.log > /dev/null 2>&1
# Run "Check/add IPs and so on" once per hour
0 * * * * Administrator /opt/slapos/bin/slapos node format >> /opt/slapos/log/slapos-node-format.log 2>&1
# Make sure we have only good network routes if we use VPN
# * * * * * root if [ -f /etc/opt/slapos/openvpn-needed ]; then ifconfig tapVPN | grep "Scope:Global" > /dev/null ;if [
$?
= 0 ]; then ROUTES=
$(
ip
-6
r l |
grep
default |
awk
'{print $5}'
)
; for GW in
$ROUTES
; do if [ !
$GW
= tapVPN ]; then /sbin/ip -6 route del default dev
$GW
> /dev/null 2>&1;fi ;done ;fi ;fi
0 * * * *
${
USER
}
/opt/slapos/bin/slapos node format >> /opt/slapos/log/slapos-node-format.log 2>&1
EOF
echo
Cron file
$crontab_file
created.
fi
echo
Checking cron job ...
ps
-ef
|
grep
-q
"/usr/sbin/cron"
if
((
$?
))
;
then
echo
echo
cat
$crontab_file
||
show_error_exit
"No crob tab found."
echo
echo
if
ps
-ef
|
grep
-q
"/usr/sbin/cron"
;
then
echo
"The cron job is running."
else
echo
Starting cron job ...
/usr/sbin/cron &
((
$?
))
&&
show_error_exit
"Failed to
run cron-config
"
((
$?
))
&&
show_error_exit
"Failed to
start cron job.
"
disown
-h
echo
The cron job started.
else
echo
The cron job is running.
echo
"The cron job started."
fi
echo
echo
Configure section cron OK.
echo
#-------------------------------------------------
# Add slapos-configure to windows startup item
#-------------------------------------------------
slapos_run_key
=
'\HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run'
slapos_run_entry
=
slapos-configure
slapos_run_script
=
/etc/slapos/scripts/slapos-configure.sh
echo
Checking startup item ...
# -----------------------------------------------------------
# startup: Start slapos-configure when windows startup
# -----------------------------------------------------------
echo
echo
Starting configure section startup ...
echo
slapos_run_script
=
$(
cygpath
-a
$0
)
regtool
-q
get
"
$slapos_run_key
\\
$slapos_run_entry
"
||
\
regtool
-q
set
"
$slapos_run_key
\\
$slapos_run_entry
"
\
"
\"
$(
cygpath
-w
/usr/bin/bash
)
\"
--login -i
$slapos_run_script
"
||
\
show_error_exit
"Failed to add slapos-configure.sh as windows startup item."
echo
Startup item
"
$slapos_run_key
\\
$slapos_run_entry
"
:
$(
regtool get
"
$slapos_run_key
\\
$slapos_run_entry
"
)
echo
"Windows startup item:"
echo
"
$slapos_run_key
\\
$slapos_run_entry
= "
\
$(
regtool get
"
$slapos_run_key
\\
$slapos_run_entry
"
)
echo
echo
Configure section startup OK.
echo
echo
SlapOS Node configure
successfully.
echo
Configure SlapOS
successfully.
read
-n
1
-t
60
-p
"Press any key to exit..."
exit
0
windows/scripts/slapos-include.sh
0 → 100755
View file @
a102426b
#! /bin/bash
#
export
PATH
=
/usr/local/bin:/usr/bin:/usr/sbin:/sbin:/bin:
$PATH
# ======================================================================
# Constants
# ======================================================================
slapos_client_home
=
~/.slapos
client_configure_file
=
$slapos_client_home
/slapos.cfg
client_certificate_file
=
$slapos_client_home
/certificate
client_key_file
=
$slapos_client_home
/key
client_template_file
=
/etc/slapos/slapos-client.cfg.example
node_certificate_file
=
/etc/opt/slapos/ssl/computer.crt
node_key_file
=
/etc/opt/slapos/ssl/computer.key
node_config_file
=
/etc/opt/slapos/slapos.cfg
node_template_file
=
/etc/slapos/slapos.cfg.example
slapos_ifname
=
re6stnet-lo
# Change it if it confilcts with your local network
ipv4_local_network
=
10.201.67.0/24
re6stnet_configure_file
=
/etc/re6stnet/re6stnet.conf
re6stnet_cygwin_script
=
/etc/re6stnet/ovpn-cygwin.bat
re6stnet_service_name
=
slapos-re6stnet
slaprunner_startup_file
=
/etc/slapos/scripts/slap-runner.html
slapos_run_key
=
'\HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run'
slapos_run_entry
=
slapos-configure
# ======================================================================
# Routine: get_system_and_admins_gids
# 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
==
*
\
$ADMINGUID
\
*
]]
;
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
exit
1
fi
}
# === check_administrator_right() === #
# ======================================================================
# Routine: check_administrator_right
# Check cygwin service is install or not, running state, and run by
# which account
# ======================================================================
function
check_cygwin_service
()
{
ret
=
0
name
=
$1
echo
Checking cygwin service
$name
...
if
[
!
-e
/usr/bin/cygrunsrv.exe
]
;
then
echo
"Error: Download the cygrunsrv package to start the
$name
daemon as a service."
exit
1
fi
if
[[
!
cygrunsrv
--query
$name
>
/dev/null 2>&1
]]
;
then
echo
"Error: No cygwin service
$name
installed, please run Configure SlapOS to install it."
return
1
fi
account
=
"
$(
cygrunsrv
-VQ
$name
|
sed
-n
-e
's/^Account[ :]*//p'
)
"
state
=
$(
cygrunsrv
--query
$name
|
sed
-n
-e
's/^Current State[ :]*//p'
)
[[
"
$state
"
==
"Running"
]]
||
cygrunsrv
--start
$name
state
=
$(
cygrunsrv
--query
$name
|
sed
-n
-e
's/^Current State[ :]*//p'
)
cygrunsrv
--query
--verbose
$name
echo
Check cygwin service
$name
OVER.
[[
"
$state
"
==
"Running"
]]
||
ret
=
1
return
"
${
ret
}
"
}
# === check_cygwin_service() === #
# ======================================================================
# Routine: check_network_configure
# Check slapos network configure
# ======================================================================
function
check_network_configure
()
{
echo
Checking slapos network ...
original_connections
=
$(
echo
$(
get_all_connections
))
if
[[
!
"
$original_connections
"
==
*
[
\
]
$slapos_ifname
[
\
]
*
]]
;
then
echo
"Error: No connection name
$slapos_ifname
found, please "
echo
"run Configure SlapOS to install it."
return
1
fi
echo
Check slapos network Over.
}
# === check_network_configure() === #
# ======================================================================
# Routine: check_node_configure
# Check slapos node configure
# ======================================================================
function
check_node_configure
()
{
echo
Checking slapos node configure ...
[[
!
-r
$node_certificate_file
]]
&&
\
(
echo
"Computer certificate file
$node_certificate_file
"
;
echo
"doesn't exists, or you haven't right to visit."
)
&&
\
return
1
openssl x509
-noout
-in
$node_certificate_file
||
return
1
openssl rsa
-noout
-in
$node_key_file
-check
||
return
1
computer_guid
=
$(
grep
"CN=COMP"
$node_certificate_file
|
\
sed
-e
"s/^.*, CN=//g"
|
sed
-e
"s%/emailAddress.*
\$
%%g"
)
[[
!
"
$computer_guid
"
==
COMP-+
([
0-9]
)
]]
&&
\
(
echo
"Invalid computer id '
$computer_guid
' specified."
;
echo
"It should look like 'COMP-XXXX'"
)
&&
\
return
1
echo
Check slapos node configure Over.
}
# === check_node_configure() === #
# ======================================================================
# Routine: check_client_configure
# Check slapos client configure
# ======================================================================
function
check_client_configure
()
{
echo
Checking slapos client confiure ...
echo
Check slapos client configure Over.
}
# === check_client_configure() === #
# ======================================================================
# Routine: check_cron_configure
# Check slapos cron configure
# ======================================================================
function
check_cron_configure
()
{
echo
Checking slapos cron confiure ...
echo
Check slapos cron configure Over.
}
# === check_cron_configure() === #
# ======================================================================
# Routine: check_re6stnet_configure
# Check slapos re6stnet configure
# ======================================================================
function
check_re6stnet_configure
()
{
echo
Checking slapos re6stnet confiure ...
!
which re6stnet
>
/dev/null 2>&1
&&
\
echo
"No re6stnet installed, please run Configure SlapOS first."
&&
\
return
1
echo
Check slapos re6stnet configure Over.
}
# === check_re6stnet_configure() === #
# ======================================================================
# Routine: check_re6stnet_needed
# Check re6stnet required or not
# ======================================================================
function
check_re6stnet_needed
()
{
# This doesn't work in the cygwin now, need hack ip script
# re6st-conf --registry http://re6stnet.nexedi.com/ --is-needed
netsh interface ipv6 show route |
grep
-q
" ::/0 "
return
!
$?
}
# === check_re6stnet_needed() === #
# ======================================================================
# Routine: get_all_connections
# Return all connection names line by line, and replace space with '%'
# ======================================================================
function
get_all_connections
()
{
netsh interface ipv6 show interface |
\
grep
"^[ 0-9]
\+
"
|
\
sed
-e
"s/^[ 0-9]
\+
[a-zA-Z]
\+
//"
-e
"s/^
\s
*//"
-e
"s/ /%/g"
}
# === get_all_connections() === #
# ======================================================================
# Routine: get_new_connection
# Check all the connection names, and compare the original connection
# list, return the new connection name
#
# Note: If nothing found, return empty
# If more than one, return the first one
# ======================================================================
function
get_new_connection
()
{
original_connections
=
"
$*
"
current_connections
=
$(
get_all_connections
)
for
name
in
$current_connections
;
do
[[
!
"
$original_connections
"
==
*
[
\
]
$name
[
\
]
*
]]
&&
\
echo
${
name
//%/
}
&&
return
0
done
}
# === get_new_connections() === #
# ======================================================================
# Routine: reset_slapos_connection
# Remove all ipv4/ipv6 addresses in the connection re6stnet-lo
# ======================================================================
function
reset_slapos_connection
()
{
ifname
=
${
1
-re6stnet-lo
}
for
addr
in
$(
netsh interface ipv6 show address
$ifname
level
=
normal |
\
grep
"^Manual"
|
\
sed
-e
"s/^
\(\w\+\s\+\)\{
4
\}
//"
)
;
do
netsh interface ipv6 del address
$ifname
$addr
done
netsh interface ip
set
address
$ifname
source
=
dhcp
# for addr in $(netsh interface ip show address $ifname | \
# grep "IP Address:" | \
# sed -e "s/IP Address://") ; do
# netsh interface del address $ifname $addr
# done
}
# === reset_slapos_connection() === #
# ======================================================================
# Routine: connection2guid
# Transfer connection name to GUID
# ======================================================================
function
connection2guid
()
{
ifname
=
${
1
-re6stnet-lo
}
#
# This command doesn't work in the Windows 7, Window 8, maybe
# Vista. Because no guid information in these platforms.
#
# netsh interface ipv6 show interface $ifname | \
# grep "^GUID\s*:" | \
# sed -e "s/^GUID\s*:\s*//"
#
# So we use getmac to repleace it:
getmac /fo list /v |
grep
-A3
"^Connection Name: *
$ifname
\$
"
\
|
grep
"^Transport Name:"
|
sed
-e
"s/^.*Tcpip_//g"
}
# === connection2guid() === #
# ======================================================================
# Routine: show_error_exit
# Show error message and wait for user to press any key to exit
# ======================================================================
function
show_error_exit
()
{
echo
${
1
-Error
:
run Configure Slapos failed.
}
read
-n
1
-p
"Press any key to exit..."
exit
1
}
# === show_error_exit() === #
# ======================================================================
# Routine: start_cygwin_service
# Start cygwin service if required
# ======================================================================
function
start_cygwin_service
()
{
name
=
$1
state
=
$(
cygrunsrv
--query
$name
|
sed
-n
-e
's/^Current State[ :]*//p'
)
[[
"
$state
"
==
"Running"
]]
||
net start
$name
state
=
$(
cygrunsrv
--query
$name
|
sed
-n
-e
's/^Current State[ :]*//p'
)
[[
"
$state
"
==
"Running"
]]
||
return
1
}
# === 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
# Generate the template file for node and client
# ======================================================================
function
create_template_configure_file
()
{
cat
<<
EOF
>
$client_template_file
[slapos]
master_url = https://slap.vifib.com/
[slapconsole]
# Put here retrieved certificate from SlapOS Master.
# Beware: put certificate from YOUR account, not the one from your node.
# You (as identified person from SlapOS Master) will request an instance, node your node.
# Conclusion: node certificate != person certificate.
cert_file = certificate file location coming from your slapos master account
key_file = key file location coming from your slapos master account
# Below are softwares maintained by slapos.org and contributors
alias =
apache_frontend http://git.erp5.org/gitweb/slapos.git/blob_plain/HEAD:/software/apache-frontend/software.cfg
dokuwiki http://git.erp5.org/gitweb/slapos.git/blob_plain/refs/tags/slapos-0.158:/software/dokuwiki/software.cfg
drupal http://git.erp5.org/gitweb/slapos.git/blob_plain/refs/tags/slapos-0.151:/software/erp5/software.cfg
erp5 http://git.erp5.org/gitweb/slapos.git/blob_plain/refs/tags/slapos-0.143:/software/erp5/software.cfg
erp5_branch http://git.erp5.org/gitweb/slapos.git/blob_plain/refs/heads/erp5:/software/erp5/software.cfg
fengoffice http://git.erp5.org/gitweb/slapos.git/blob_plain/refs/tags/slapos-0.158:/software/fengoffice/software.cfg
kumofs http://git.erp5.org/gitweb/slapos.git/blob_plain/refs/tags/slapos-0.141:/software/kumofs/software.cfg
kvm http://git.erp5.org/gitweb/slapos.git/blob_plain/refs/tags/slapos-0.156:/software/kvm/software.cfg
maarch http://git.erp5.org/gitweb/slapos.git/blob_plain/refs/tags/slapos-0.159:/software/maarch/software.cfg
mariadb http://git.erp5.org/gitweb/slapos.git/blob_plain/refs/tags/slapos-0.152:/software/mariadb/software.cfg
memcached http://git.erp5.org/gitweb/slapos.git/blob_plain/refs/tags/slapos-0.82:/software/memcached/software.cfg
mysql http://git.erp5.org/gitweb/slapos.git/blob_plain/refs/tags/slapos-0.65:/software/mysql-5.1/software.cfg
opengoo http://git.erp5.org/gitweb/slapos.git/blob_plain/refs/tags/slapos-0.158:/software/opengoo/software.cfg
postgresql http://git.erp5.org/gitweb/slapos.git/blob_plain/refs/tags/slapos-0.157:/software/postgres/software.cfg
slaposwebrunner http://git.erp5.org/gitweb/slapos.git/blob_plain/refs/heads/cygwin-0:/software/slaprunner/software.cfg
slaposwebrunner_lite http://git.erp5.org/gitweb/slapos.git/blob_plain/refs/heads/cygwin-0:/software/slaprunner-lite/software.cfg
wordpress http://git.erp5.org/gitweb/slapos.git/blob_plain/refs/heads/cygwin:/software/wordpress/software.cfg
xwiki http://git.erp5.org/gitweb/slapos.git/blob_plain/refs/tags/slapos-0.46:/software/xwiki/software.cfg
zabbixagent http://git.erp5.org/gitweb/slapos.git/blob_plain/refs/tags/slapos-0.162:/software/zabbix-agent/software.cfg
netdrive_reporter http://git.erp5.org/gitweb/slapos.git/blob_plain/refs/heads/cygwin-0:/software/netdrive-reporter/software.cfg
demoapp http://git.erp5.org/gitweb/slapos.git/blob_plain/refs/heads/cygwin-0:/software/demoapp/software.cfg
EOF
cat
<<
EOF
>
$node_template_file
[slapos]
# Replace computer_id by the unique identifier of your computer on vifib.net,
# starting by COMP-
computer_id = COMP-12345
master_url = https://slap.vifib.com/
key_file = /etc/opt/slapos/ssl/computer.key
cert_file = /etc/opt/slapos/ssl/computer.crt
certificate_repository_path = /etc/opt/slapos/ssl/partition_pki
software_root = /opt/slapgrid
instance_root = /srv/slapgrid
[slapformat]
# Replace by your network interface like eth0, eth1, slapbr0...
interface_name = interfacename
# Change "create_tap" into "true" if you need to host KVM services
create_tap = false
partition_amount = 10
computer_xml = /opt/slapos/slapos.xml
log_file = /opt/slapos/log/slapos-node-format.log
partition_base_name = slappart
user_base_name = slapuser
tap_base_name = slaptap
# You can choose any other local network which does not conflict with your
# current machine configuration
ipv4_local_network = 10.0.0.0/16
# Comment this if you are using native IPv6 and don't want to use SlapOS tunnel
ipv6_interface = tapVPN
[networkcache]
# Define options for binary cache, used to download already compiled software.
download-binary-cache-url = http://www.shacache.org/shacache
download-cache-url = https://www.shacache.org/shacache
download-binary-dir-url = http://www.shacache.org/shadir
# Configuration to Upload Configuration for Binary cache
#upload-binary-dir-url = https://www.shacache.org/shadir
#upload-binary-cache-url = https://www.shacache.org/shacache
#signature_private_key_file = /etc/opt/slapos/shacache/signature.key
#signature_certificate_file = /etc/opt/slapos/shacache/signature.cert
#upload-cache-url = https://www.shacache.org/shacache
#shacache-cert-file = /etc/opt/slapos/shacache/shacache.cert
#shacache-key-file = /etc/opt/slapos/shacache/shacache.key
#upload-binary-dir-url = https://www.shacache.org/shadir
#upload-binary-cache-url = https://www.shacache.org/shacache
#upload-dir-url = https://www.shacache.org/shadir
#shadir-cert-file = /etc/opt/slapos/shacache/shacache.cert
#shadir-key-file = /etc/opt/slapos/shacache/shacache.key
# List of signatures of uploaders we trust:
# Romain Courteaud
# Sebastien Robin
# Kazuhiko Shiozaki
# Cedric de Saint Martin
# Yingjie Xu
# Gabriel Monnerat
# Łukasz Nowak
# Test Agent Signature
signature-certificate-list =
-----BEGIN CERTIFICATE-----
MIIB4DCCAUkCADANBgkqhkiG9w0BAQsFADA5MQswCQYDVQQGEwJGUjEZMBcGA1UE
CBMQRGVmYXVsdCBQcm92aW5jZTEPMA0GA1UEChMGTmV4ZWRpMB4XDTExMDkxNTA5
MDAwMloXDTEyMDkxNTA5MDAwMlowOTELMAkGA1UEBhMCRlIxGTAXBgNVBAgTEERl
ZmF1bHQgUHJvdmluY2UxDzANBgNVBAoTBk5leGVkaTCBnzANBgkqhkiG9w0BAQEF
AAOBjQAwgYkCgYEApYZv6OstoqNzxG1KI6iE5U4Ts2Xx9lgLeUGAMyfJLyMmRLhw
boKOyJ9Xke4dncoBAyNPokUR6iWOcnPHtMvNOsBFZ2f7VA28em3+E1JRYdeNUEtX
Z0s3HjcouaNAnPfjFTXHYj4um1wOw2cURSPuU5dpzKBbV+/QCb5DLheynisCAwEA
ATANBgk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YMBaAFNuxsc77Z6/JSKPo
yloHNm9zF9yqMAwGA1UdEwQFMAMBAf8wDQYJKoZIhvcNAQEFBQADgYEAl4hBaJy1
cgiNV2+Z5oNTrHgmzWvSY4duECOTBxeuIOnhql3vLlaQmo0p8Z4c13kTZq2s3nhd
Loe5mIHsjRVKvzB6SvIaFUYq/EzmHnqNdpIGkT/Mj7r/iUs61btTcGUCLsUiUeci
Vd0Ozh79JSRpkrdI8R/NRQ2XPHAo+29TT70=
-----END CERTIFICATE-----
-----BEGIN CERTIFICATE-----
MIIB9jCCAV+gAwIBAgIJAKRvzcy7OH0UMA0GCSqGSIb3DQEBBQUAMBMxETAPBgNV
BAMMCENPTVAtNzcyMCAXDTEyMDgxMDE1NDI1MVoYDzIxMTIwNzE3MTU0MjUxWjAT
MREwDwYDVQQDDAhDT01QLTc3MjCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEA
o7aipd6MbnuGDeR1UJUjuMLQUariAyQ2l2ZDS6TfOwjHiPw/mhzkielgk73kqN7A
sUREx41eTcYCXzTq3WP3xCLE4LxLg1eIhd4nwNHj8H18xR9aP0AGjo4UFl5BOMa1
mwoyBt3VtfGtUmb8whpeJgHhqrPPxLoON+i6fIbXDaUCAwEAAaNQME4wHQYDVR0O
BBYEFEfjy3OopT2lOksKmKBNHTJE2hFlMB8GA1UdIwQYMBaAFEfjy3OopT2lOksK
mKBNHTJE2hFlMAwGA1UdEwQFMAMBAf8wDQYJKoZIhvcNAQEFBQADgYEAaNRx6YN2
M/p3R8/xS6zvH1EqJ3FFD7XeAQ52WuQnKSREzuw0dsw12ClxjcHiQEFioyTiTtjs
5pW18Ry5Ie7iFK4cQMerZwWPxBodEbAteYlRsI6kePV7Gf735Y1RpuN8qZ2sYL6e
x2IMeSwJ82BpdEI5niXxB+iT0HxhmR+XaMI=
-----END CERTIFICATE-----
# List of URL(s) which shouldn't be downloaded from binary cache.
# Any URL beginning by a blacklisted URL will be blacklisted as well.
download-from-binary-cache-url-blacklist =
http://git.erp5.org/gitweb/slapos.git/blob_plain/HEAD
http://git.erp5.org/gitweb/slapos.git/blob_plain/refs/heads
/
# List of URL(s) which shouldn't be uploaded into binary cache.
# Any URL beginning by a blacklisted URL will be blacklisted as well.
upload-to-binary-cache-url-blacklist =
http://git.erp5.org/gitweb/slapos.git/blob_plain/HEAD
http://git.erp5.org/gitweb/slapos.git/blob_plain/refs/heads
/
EOF
}
# === create_template_configure_file() === #
windows/scripts/slapos-node.sh
View file @
a102426b
#! /bin/bash
export
PATH
=
/usr/local/bin:/usr/bin:
$PATH
# ======================================================================
# Routine: get_system_and_admins_gids
# Get the ADMINs ids from /etc/group and /etc/passwd
# ======================================================================
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() === #
#
# Check ipv6 connection by default ipv6 route
#
function
check_ipv6_connection
()
{
netsh interface ipv6 show route |
grep
-q
" ::/0 "
}
#
# Check cygwin service
#
function
check_cygwin_service
()
{
service_name
=
$1
echo
Checking
$1
service ...
if
[
!
-e
/usr/bin/cygrunsrv.exe
]
;
then
show_error_exit
"No cygserver found, please install the cygrunsrv package first."
fi
service_account
=
"
$(
cygrunsrv
-VQ
$service_name
|
sed
-n
-e
's/^Account[ :]*//p'
)
"
||
\
show_error_exit
"No
$1
service install, please run Configure SlapOS to install it."
service_state
=
$(
cygrunsrv
--query
$service_name
|
sed
-n
-e
's/^Current State[ :]*//p'
)
if
[[
!
x
$service_state
==
"xRunning"
]]
;
then
echo
"Cygwin service
$1
currnt state is
$service_state
, try to use"
echo
" cygrunsrv --start
$1
to start this service"
cygrunsrv
--start
$1
||
show_error_exit
"Failed to start service
$1
"
echo
Cygwin
$1
service is running.
fi
echo
Check
$1
service OVER.
}
#
# Show error message and waiting for user to press any key quit
#
function
show_error_exit
()
{
msg
=
${
1
-Failed to configure Slapos Node in this computer.
}
echo
$msg
read
-n
1
-p
"Press any key to exit..."
exit
1
}
#-------------------------------------------------
# Check adminsitrator rights
#-------------------------------------------------
get_system_and_admins_ids
||
show_error_exit
"Failed to get uids of system and amdinistrator account."
id
|
grep
-q
"
$ADMINSUID
(Administrators)"
||
show_error_exit
"Error: Administrator right required to run this script."
#-------------------------------------------------
# Constants
#-------------------------------------------------
slapos_ifname
=
re6stnet-lo
#-------------------------------------------------
# Check cygserver, syslog-ng
#-------------------------------------------------
check_cygwin_service cygserver
check_cygwin_service syslog-ng
#-------------------------------------------------
# IPv6 Connection
#-------------------------------------------------
echo
"Checking native IPv6 ..."
check_ipv6_connection
# Run re6stnet if no native ipv6
if
((
$?
))
;
then
echo
"No native IPv6."
echo
Check re6stnet network ...
which re6stnet
>
/dev/null 2>&1
||
show_error_exit
"Error: no re6stnet installed, please run Configure SlapOS first."
service_name
=
slapos-re6stnet
# re6st-conf --registry http://re6stnet.nexedi.com/ --is-needed
cygrunsrv
--query
$service_name
>
/dev/null 2>&1
if
((
$?
))
;
then
[[
-d
/var/log/re6stnet
]]
||
mkdir
-p
/var/log/re6stnet
echo
"Install slapos-re6stnet service ..."
cygrunsrv
-I
$service_name
-c
/etc/re6stnet
-p
$(
which re6stnet
)
-a
"@re6stnet.conf"
||
\
show_error_exit
"Failed to install
$service_name
service."
echo
"Cygwin
$service_name
service installed."
# echo "Waiting re6stent network work ..."
# while true ; do
# check_ipv6_connection && break
# done
fi
service_state
=
$(
cygrunsrv
--query
$service_name
|
sed
-n
-e
's/^Current State[ :]*//p'
)
if
[[
!
x
$service_state
==
"xRunning"
]]
;
then
echo
"Starting
$service_name
service ..."
cygrunsrv
--start
$service_name
||
show_error_exit
"Failed to start
$service_name
service."
service_state
=
$(
cygrunsrv
--query
$service_name
|
sed
-n
-e
's/^Current State[ :]*//p'
)
fi
[[
x
$service_state
==
"xRunning"
]]
||
show_error_exit
"Failed to start
$service_name
service."
echo
Cygwin
$service_name
service is running.
echo
"You can check log files in the /var/log/re6stnet/*.log"
echo
echo
"re6stnet network OK."
else
echo
"Native IPv6 Found."
fi
#-------------------------------------------------
# Format slapos node, need root right
#-------------------------------------------------
[[
-f
/etc/opt/slapos/slapos.cfg
]]
||
\
show_error_exit
"Error: no node configure file found, please run Configure SlapOS first."
source
$(
dirname
$0
)
/slapos-include.sh
check_administrator_right
# -----------------------------------------------------------
# Check all the configure files
# -----------------------------------------------------------
check_network_configure
||
exit
1
check_node_configure
||
exit
1
check_client_configure
||
exit
1
check_cron_configure
check_re6stnet_configure
# -----------------------------------------------------------
# Check cygwin services used by slapos
# -----------------------------------------------------------
check_cygwin_service cygserver
||
exit
1
check_cygwin_service syslog-ng
||
exit
1
check_cygwin_service sshd
check_cygwin_service cron
check_re6stnet_needed
&&
check_cygwin_service re6stnet
# -----------------------------------------------------------
# Format slapos node
# -----------------------------------------------------------
echo
"Formating SlapOS Node ..."
/opt/slapos/bin/slapos node format
-cv
--now
||
\
show_error_exit
"Failed to run slapos format."
/opt/slapos/bin/slapos node format
-cv
--now
||
exit
1
#-------------------------------------------------
#
----------
-------------------------------------------------
# Release software
#-------------------------------------------------
# -----------------------------------------------------------
echo
"Releasing software ..."
/opt/slapos/bin/slapos node software
--verbose
#-------------------------------------------------
#
----------
-------------------------------------------------
# Instance software
#-------------------------------------------------
#
----------
-------------------------------------------------
echo
"Creating instance ..."
/opt/slapos/bin/slapos node instance
--verbose
#-------------------------------------------------
#
----------
-------------------------------------------------
# Send report
#-------------------------------------------------
#
----------
-------------------------------------------------
echo
"Sending report ..."
/opt/slapos/bin/slapos node report
--verbose
...
...
windows/scripts/slapos.iss
View file @
a102426b
...
...
@@ -55,6 +55,7 @@ Source: "opt\openvpn\bin\addtap.bat"; DestDir: "{app}\cygwin\bin";
Source: "opt\openvpn\bin\deltapall.bat"; DestDir: "{app}\cygwin\bin";
Source: "opt\openvpn\driver\*"; DestDir: "{app}\cygwin\etc\slapos\driver";
Source: "opt\git\slapos.package\windows\scripts\slapos-include.sh"; DestDir: "{app}\cygwin\etc\slapos\scripts";
Source: "opt\git\slapos.package\windows\scripts\slapos-node.sh"; DestDir: "{app}\cygwin\etc\slapos\scripts";
Source: "opt\git\slapos.package\windows\scripts\post-install.sh"; DestDir: "{app}\cygwin\etc\slapos\scripts";
Source: "opt\git\slapos.package\windows\scripts\build-slapos.sh"; DestDir: "{app}\cygwin\etc\slapos\scripts";
...
...
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