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
Xiaowu Zhang
slapos.package
Commits
b0e52529
Commit
b0e52529
authored
Aug 30, 2012
by
Cédric Le Ninivin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cron doesn't include lxc by default, have to be choosen in slapprepare
Slapprepare now propose default parameters
parent
6b4d9629
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
49 additions
and
21 deletions
+49
-21
slapos-node/template/slapos-node.cron.d
slapos-node/template/slapos-node.cron.d
+0
-2
slapprepare/slapprepare/__init__.py
slapprepare/slapprepare/__init__.py
+36
-11
slapprepare/slapprepare/script/slapos
slapprepare/slapprepare/script/slapos
+13
-6
templates/debian/cron.d
templates/debian/cron.d
+0
-2
No files found.
slapos-node/template/slapos-node.cron.d
View file @
b0e52529
...
@@ -7,5 +7,3 @@ MAILTO=root
...
@@ -7,5 +7,3 @@ MAILTO=root
0
0
*
*
*
root
/
opt
/
slapos
/
bin
/
slapgrid
-
ur
--
verbose
--
logfile
=/
opt
/
slapos
/
slapgrid
-
ur
.
log
--
pidfile
=/
opt
/
slapos
/
slapgrid
-
ur
.
pid
/
etc
/
opt
/
slapos
/
slapos
.
cfg
>>
/
opt
/
slapos
/
slapgrid
-
ur
.
log
2
>&
1
0
0
*
*
*
root
/
opt
/
slapos
/
bin
/
slapgrid
-
ur
--
verbose
--
logfile
=/
opt
/
slapos
/
slapgrid
-
ur
.
log
--
pidfile
=/
opt
/
slapos
/
slapgrid
-
ur
.
pid
/
etc
/
opt
/
slapos
/
slapos
.
cfg
>>
/
opt
/
slapos
/
slapgrid
-
ur
.
log
2
>&
1
0
0
*
*
*
root
/
opt
/
slapos
/
bin
/
slapformat
--
verbose
--
log_file
=/
opt
/
slapos
/
slapformat
.
log
-
c
/
etc
/
opt
/
slapos
/
slapos
.
cfg
>>
/
opt
/
slapos
/
slapformat
.
log
2
>&
1
0
0
*
*
*
root
/
opt
/
slapos
/
bin
/
slapformat
--
verbose
--
log_file
=/
opt
/
slapos
/
slapformat
.
log
-
c
/
etc
/
opt
/
slapos
/
slapos
.
cfg
>>
/
opt
/
slapos
/
slapformat
.
log
2
>&
1
#
XXX
:
SlapContainer
*/
5
*
*
*
*
root
if
[
-
x
/
opt
/
slapgrid
/
843
c2b4de8c5579427b072d00ec2ec9e
/
bin
/
slapcontainer
]
;
then
/
opt
/
slapgrid
/
843
c2b4de8c5579427b072d00ec2ec9e
/
bin
/
slapcontainer
--
pid
/
opt
/
slapos
/
slapcontainer
.
pid
/
etc
/
opt
/
slapos
/
slapos
.
cfg
/
opt
/
slapos
/
slapcontainer
.
db
>
/
opt
/
slapos
/
slapcontainer
.
log
2
>&
1
;
fi
slapprepare/slapprepare/__init__.py
View file @
b0e52529
...
@@ -71,12 +71,19 @@ def _call(cmd_args, stdout=None, stderr=None, dry_run=False):
...
@@ -71,12 +71,19 @@ def _call(cmd_args, stdout=None, stderr=None, dry_run=False):
(
str
(
e
),
' '
.
join
(
cmd_args
)))
(
str
(
e
),
' '
.
join
(
cmd_args
)))
# Utility fonction to get yes/no answers
# Utility fonction to get yes/no answers
def
get_yes_no
(
prompt
):
def
get_yes_no
(
prompt
,
default
=
None
):
ok
=
0
if
default
:
while
not
ok
:
def_value
=
'/ Default yes'
answer
=
raw_input
(
prompt
+
" [y,n]: "
)
elif
default
==
False
:
def_value
=
'/ Default no'
else
:
def_value
=
''
while
True
:
answer
=
raw_input
(
prompt
+
" [y,n] %s: "
%
def_value
)
if
answer
.
upper
()
in
[
'Y'
,
'YES'
]:
return
True
if
answer
.
upper
()
in
[
'Y'
,
'YES'
]:
return
True
if
answer
.
upper
()
in
[
'N'
,
'NO'
]:
return
False
if
answer
.
upper
()
in
[
'N'
,
'NO'
]:
return
False
if
not
default
==
None
:
if
answer
==
''
:
return
default
# Return OpenSUSE version if it is SuSE
# Return OpenSUSE version if it is SuSE
def
suse_version
():
def
suse_version
():
...
@@ -260,6 +267,12 @@ log /var/log/openvpn.log""" % dict(
...
@@ -260,6 +267,12 @@ log /var/log/openvpn.log""" % dict(
if
not
dry_run
:
if
not
dry_run
:
open
(
os
.
path
.
join
(
config
.
slapos_configuration
,
'openvpn-needed'
),
'w'
)
open
(
os
.
path
.
join
(
config
.
slapos_configuration
,
'openvpn-needed'
),
'w'
)
# Put file to force VPN if user asked
if
config
.
force_slapcontainer
:
if
not
dry_run
:
open
(
os
.
path
.
join
(
config
.
slapos_configuration
,
'SlapContainer-needed'
),
'w'
)
# Removing line in slapos script activating kvm in virtual
# Removing line in slapos script activating kvm in virtual
if
config
.
virtual
:
if
config
.
virtual
:
if
not
dry_run
:
if
not
dry_run
:
...
@@ -309,21 +322,24 @@ class Config:
...
@@ -309,21 +322,24 @@ class Config:
def
userConfig
(
self
):
def
userConfig
(
self
):
self
.
certificates
=
get_yes_no
(
"Automatically register new computer to Vifib?"
)
self
.
certificates
=
get_yes_no
(
"Automatically register new computer to Vifib?"
,
True
)
if
self
.
certificates
:
if
self
.
certificates
:
self
.
computer_name
=
raw_input
(
"Define a unique name for this computer: "
)
self
.
computer_name
=
raw_input
(
"Define a unique name for this computer: "
)
self
.
partition_amount
=
raw_input
(
"""Number of SlapOS partitions for this computer? """
)
self
.
partition_amount
=
raw_input
(
"""Number of SlapOS partitions for this computer? Default is 20 :"""
)
self
.
virtual
=
get_yes_no
(
"Is this a virtual Machine?"
)
if
self
.
partition_amount
==
''
:
self
.
partition_amount
=
20
self
.
virtual
=
get_yes_no
(
"Is this a virtual Machine?"
,
False
)
if
not
self
.
virtual
:
if
not
self
.
virtual
:
self
.
one_disk
=
not
get_yes_no
(
"Do you want to use SlapOS with a second disk?"
)
self
.
one_disk
=
not
get_yes_no
(
"Do you want to use SlapOS with a second disk?"
,
True
)
else
:
else
:
self
.
one_disk
=
True
self
.
one_disk
=
True
self
.
force_vpn
=
get_yes_no
(
"Do you want to force the use of vpn to provide ipv6?"
)
self
.
force_vpn
=
get_yes_no
(
"Do you want to force the use of vpn to provide ipv6?"
,
True
)
self
.
force_vpn
=
get_yes_no
(
"Do you want to force the use lxc on this computer?"
,
False
)
if
self
.
force_vpn
:
if
self
.
force_vpn
:
self
.
ipv6_interface
=
"tapVPN"
self
.
ipv6_interface
=
"tapVPN"
else
:
else
:
self
.
ipv6_interface
=
""
self
.
ipv6_interface
=
""
self
.
need_ssh
=
get_yes_no
(
"Do you want a remote ssh access?"
)
self
.
need_ssh
=
get_yes_no
(
"Do you want a remote ssh access?"
,
True
)
def
displayUserConfig
(
self
):
def
displayUserConfig
(
self
):
if
self
.
certificates
:
if
self
.
certificates
:
...
@@ -347,7 +363,7 @@ def slapprepare():
...
@@ -347,7 +363,7 @@ def slapprepare():
config
.
userConfig
()
config
.
userConfig
()
print
"
\
n
This your configuration:
\
n
"
print
"
\
n
This your configuration:
\
n
"
config
.
displayUserConfig
()
config
.
displayUserConfig
()
if
get_yes_no
(
"
\
n
Do you confirm?"
):
if
get_yes_no
(
"
\
n
Do you confirm?"
,
True
):
break
break
if
config
.
certificates
:
if
config
.
certificates
:
...
@@ -408,3 +424,12 @@ def slapprepare():
...
@@ -408,3 +424,12 @@ def slapprepare():
print
"Deleting directory: %s"
%
temp_directory
print
"Deleting directory: %s"
%
temp_directory
_call
([
'rm'
,
'-rf'
,
temp_directory
])
_call
([
'rm'
,
'-rf'
,
temp_directory
])
sys
.
exit
(
return_code
)
sys
.
exit
(
return_code
)
if
__name__
==
"__main__"
:
config
=
Config
()
while
True
:
config
.
userConfig
()
print
"
\
n
This your configuration:
\
n
"
config
.
displayUserConfig
()
if
get_yes_no
(
"
\
n
Do you confirm?"
):
break
slapprepare/slapprepare/script/slapos
View file @
b0e52529
...
@@ -113,20 +113,27 @@ mkdir -v -p -m 0755 $repo
...
@@ -113,20 +113,27 @@ mkdir -v -p -m 0755 $repo
# software detected, ready to run
# software detected, ready to run
# Set up cron
# Set up cron
# Fix path in case of old config:
SLAPOS_GOOD_CONFIGURATION
=
/etc/opt/slapos/
if
[
$SLAPOS_GOOD_CONFIGURATION
!=
$SLAPOS_CONFIGURATION
]
;
then
sed
-i
"s|
$SLAPOS_GOOD_CONFIGURATION
|
$SLAPOS_CONFIGURATION
|g"
/etc/cron.d/slapos-node
# Remove default route for ipv6 in case of openvpn-needed
echo
"""# BEWARE: This file will be automatically regenerated on each boot
echo
"""# BEWARE: This file will be automatically regenerated on each boot
SHELL=/bin/sh
SHELL=/bin/sh
PATH=/usr/bin:/usr/sbin:/sbin:/bin:/usr/lib/news/bin
PATH=/usr/bin:/usr/sbin:/sbin:/bin:/usr/lib/news/bin
MAILTO=root
MAILTO=root
0 0 * * * root /opt/slapos/bin/slapformat --verbose --log_file=/opt/slapos/slapformat.log -c
${
SLAPOS_CONFIGURATION
}
slapos.cfg >> /opt/slapos/slapformat.log 2>&1
*/5 * * * * root /opt/slapos/bin/slapgrid-cp --verbose --logfile=/opt/slapos/slapgrid-cp.log --pidfile=/opt/slapos/slapgrid-cp.pid
${
SLAPOS_CONFIGURATION
}
slapos.cfg >> /opt/slapos/slapgrid-cp.log 2>&1
*/5 * * * * root /opt/slapos/bin/slapgrid-sr --verbose --logfile=/opt/slapos/slapgrid-sr.log --pidfile=/opt/slapos/slapgrid-sr.pid
${
SLAPOS_CONFIGURATION
}
slapos.cfg >> /opt/slapos/slapgrid-sr.log 2>&1
0 0 * * * root /opt/slapos/bin/slapgrid-ur --verbose --logfile=/opt/slapos/slapgrid-ur.log --pidfile=/opt/slapos/slapgrid-ur.pid
${
SLAPOS_CONFIGURATION
}
slapos.cfg >> /opt/slapos/slapgrid-ur.log 2>&1
0/10 * * * * root if [[ -f
${
SLAPOS_CONFIGURATION
}
/openvpn-needed ]]; then ip -6 route del dev br0 ; fi
0/10 * * * * root if [[ -f
${
SLAPOS_CONFIGURATION
}
/openvpn-needed ]]; then ip -6 route del dev br0 ; fi
"""
>
/etc/cron.d/slapos
if
[
-f
${
SLAPOS_CONFIGURATION
}
/SlapContainer-needed
]
;
then
echo
"""
# XXX: SlapContainer
# XXX: SlapContainer
*/5 * * * * root if [ -x /opt/slapgrid/843c2b4de8c5579427b072d00ec2ec9e/bin/slapcontainer ] ; then /opt/slapgrid/843c2b4de8c5579427b072d00ec2ec9e/bin/slapcontainer --pid /opt/slapos/slapcontainer.pid
${
SLAPOS_CONFIGURATION
}
slapos.cfg /opt/slapos/slapcontainer.db > /opt/slapos/slapcontainer.log 2>&1 ; fi
*/5 * * * * root if [ -x /opt/slapgrid/c436b64d40a48507801d06c53cc27fec/bin/slapcontainer ] ; then /opt/slapgrid/c436b64d40a48507801d06c53cc27fec/bin/slapcontainer --pid /opt/slapos/slapcontainer.pid
${
SLAPOS_CONFIGURATION
}
slapos.cfg /opt/slapos/slapcontainer.db > /opt/slapos/slapcontainer.log 2>&1 ; fi
"""
>
/etc/cron.d/slapos-node
"""
>>
/etc/cron.d/slapos
fi
# Setup more server like network parameters in order to avoid
# Setup more server like network parameters in order to avoid
# "Neighbour table overflow."
# "Neighbour table overflow."
...
...
templates/debian/cron.d
View file @
b0e52529
...
@@ -7,5 +7,3 @@ MAILTO=root
...
@@ -7,5 +7,3 @@ MAILTO=root
0
0
*
*
*
root
/
opt
/
slapos
/
bin
/
slapgrid
-
ur
--
verbose
--
logfile
=/
opt
/
slapos
/
slapgrid
-
ur
.
log
--
pidfile
=/
opt
/
slapos
/
slapgrid
-
ur
.
pid
/
etc
/
opt
/
slapos
/
slapos
.
cfg
>>
/
opt
/
slapos
/
slapgrid
-
ur
.
log
2
>&
1
0
0
*
*
*
root
/
opt
/
slapos
/
bin
/
slapgrid
-
ur
--
verbose
--
logfile
=/
opt
/
slapos
/
slapgrid
-
ur
.
log
--
pidfile
=/
opt
/
slapos
/
slapgrid
-
ur
.
pid
/
etc
/
opt
/
slapos
/
slapos
.
cfg
>>
/
opt
/
slapos
/
slapgrid
-
ur
.
log
2
>&
1
0
0
*
*
*
root
/
opt
/
slapos
/
bin
/
slapformat
--
verbose
--
log_file
=/
opt
/
slapos
/
slapformat
.
log
-
c
/
etc
/
opt
/
slapos
/
slapos
.
cfg
>>
/
opt
/
slapos
/
slapformat
.
log
2
>&
1
0
0
*
*
*
root
/
opt
/
slapos
/
bin
/
slapformat
--
verbose
--
log_file
=/
opt
/
slapos
/
slapformat
.
log
-
c
/
etc
/
opt
/
slapos
/
slapos
.
cfg
>>
/
opt
/
slapos
/
slapformat
.
log
2
>&
1
#
XXX
:
SlapContainer
*/
5
*
*
*
*
root
if
[
-
x
/
opt
/
slapgrid
/
843
c2b4de8c5579427b072d00ec2ec9e
/
bin
/
slapcontainer
]
;
then
/
opt
/
slapgrid
/
843
c2b4de8c5579427b072d00ec2ec9e
/
bin
/
slapcontainer
--
pid
/
opt
/
slapos
/
slapcontainer
.
pid
/
etc
/
opt
/
slapos
/
slapos
.
cfg
/
opt
/
slapos
/
slapcontainer
.
db
>
/
opt
/
slapos
/
slapcontainer
.
log
2
>&
1
;
fi
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