Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
mailinabox
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
mailinabox
Commits
6f51b496
Commit
6f51b496
authored
Jul 10, 2014
by
Joshua Tauberer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
remove the hard-coded migration ID from setup.sh
parent
41b3df6d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
3 deletions
+20
-3
migrate.py
setup/migrate.py
+18
-1
start.sh
setup/start.sh
+2
-2
No files found.
setup/migrate.py
View file @
6f51b496
...
@@ -36,7 +36,16 @@ def migration_1(env):
...
@@ -36,7 +36,16 @@ def migration_1(env):
except
:
except
:
pass
pass
if
__name__
==
"__main__"
:
def
get_current_migration
():
ver
=
0
while
True
:
next_ver
=
(
ver
+
1
)
migration_func
=
globals
()
.
get
(
"migration_
%
d"
%
next_ver
)
if
not
migration_func
:
return
ver
ver
=
next_ver
def
run_migrations
():
if
not
os
.
access
(
"/etc/mailinabox.conf"
,
os
.
W_OK
,
effective_ids
=
True
):
if
not
os
.
access
(
"/etc/mailinabox.conf"
,
os
.
W_OK
,
effective_ids
=
True
):
print
(
"This script must be run as root."
,
file
=
sys
.
stderr
)
print
(
"This script must be run as root."
,
file
=
sys
.
stderr
)
sys
.
exit
(
1
)
sys
.
exit
(
1
)
...
@@ -75,3 +84,11 @@ if __name__ == "__main__":
...
@@ -75,3 +84,11 @@ if __name__ == "__main__":
# iterate and try next version...
# iterate and try next version...
if
__name__
==
"__main__"
:
if
sys
.
argv
[
-
1
]
==
"--current"
:
# Return the number of the highest migration.
print
(
str
(
get_current_migration
()))
elif
sys
.
argv
[
-
1
]
==
"--migrate"
:
# Perform migrations.
run_migrations
()
setup/start.sh
View file @
6f51b496
...
@@ -30,7 +30,7 @@ fi
...
@@ -30,7 +30,7 @@ fi
if
[
-f
/etc/mailinabox.conf
]
;
then
if
[
-f
/etc/mailinabox.conf
]
;
then
# Run any system migrations before proceeding. Since this is a second run,
# Run any system migrations before proceeding. Since this is a second run,
# we assume we have Python already installed.
# we assume we have Python already installed.
setup/migrate.py
setup/migrate.py
--migrate
# Okay now load the old .conf file to get existing configuration options.
# Okay now load the old .conf file to get existing configuration options.
cat
/etc/mailinabox.conf |
sed
s/^/DEFAULT_/
>
/tmp/mailinabox.prev.conf
cat
/etc/mailinabox.conf |
sed
s/^/DEFAULT_/
>
/tmp/mailinabox.prev.conf
...
@@ -38,7 +38,7 @@ if [ -f /etc/mailinabox.conf ]; then
...
@@ -38,7 +38,7 @@ if [ -f /etc/mailinabox.conf ]; then
MIGRATIONID
=
$DEFAULT_MIGRATIONID
MIGRATIONID
=
$DEFAULT_MIGRATIONID
else
else
# What migration are we at for new installs?
# What migration are we at for new installs?
MIGRATIONID
=
1
MIGRATIONID
=
$(
setup/migrate.py
--current
)
fi
fi
# The box needs a name.
# The box needs a name.
...
...
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