Skip to content

Commit 54cfa94

Browse files
committed
config.py is now named config.default.py
1 parent 1f571fa commit 54cfa94

File tree

8 files changed

+46
-33
lines changed

8 files changed

+46
-33
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ site.retry
44

55
.vagrant
66
.idea
7+
config.py
78

89
### Python ###
910
# Byte-compiled / optimized / DLL files

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ language: python
22
python:
33
- "2.7"
44
install:
5+
- cp config.default.py config.py
56
- pip install -r requirements.txt
67
before_script:
78
- ./pylint-check.py

Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ RUN virtualenv -p /usr/bin/python2.7 /opt/postmaster/env
3333
WORKDIR /opt/postmaster/git
3434

3535
RUN /opt/postmaster/env/bin/pip install -r requirements.txt
36+
RUN cp -pn /opt/postmaster/git/config.default.py /opt/postmaster/git/config.py
3637
RUN source /opt/postmaster/env/bin/activate && python manage.py clean
3738
RUN chown -R www-data:www-data /opt/postmaster
3839
RUN chmod +x /opt/postmaster/git/ops/docker.sh
File renamed without changes.

docs/ChangeLog.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,13 @@ Improvements:
2323
* Cleaned up JavaScript event listeners [GH-120]
2424
* Vagrant now uses Ansible for configuration instead of a bash script [GH-111]
2525
* Updated the Python packages to the latest versions [GH-135]
26+
* Apache logs for PostMaster now default to /opt/postmaster/logs
2627

2728
Bug Fixes:
2829

2930
* Fixed an issue where error logs were attempting to be written before the log file path was defined [GH-109]
31+
* The configuration file, config.py, is now named as config.default.py in the repository. During installation, the administrator must now copy or rename config.default.py to config.py.
32+
This is so that config.py is not overwritten during package upgrades.
3033

3134

3235
### v1.0.0 - Abbey Road

docs/Installation/Ubuntu1404.md

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -117,56 +117,55 @@ This allows you to separate the system installed python packages from PostMaster
117117
cd /opt/postmaster/git
118118
pip install -r requirements.txt
119119

120-
13. PostMaster needs to be configured to connect to the MySQL database using the MySQL user created in step 2 of MySQL Preparation.
120+
13. Create the PostMaster configuration file from using the sample file that was included:
121+
122+
cp -pn /opt/postmaster/git/config.default.py /opt/postmaster/git/config.py
123+
124+
14. PostMaster needs to be configured to connect to the MySQL database using the MySQL user created in step 2 of MySQL Preparation.
121125
Make sure to replace "password_changeme" with the actual password supplied in step 2 of MySQL Preparation, and if needed,
122126
replace '127.0.0.1' with the IP address or DNS specified in step 2 of MySQL Preparation:
123127

124128
cd /opt/postmaster/git
125129
python manage.py setdburi 'mysql://postmasteruser:password_changeme@127.0.0.1:3306/servermail'
126130

127-
14. PostMaster needs to create a few tables under the servermail database. This is done via a database migration,
131+
15. PostMaster needs to create a few tables under the servermail database. This is done via a database migration,
128132
which means that only the necessary changes to the database are made, and these changes are reversible if something went wrong.
129133
To start the migration, run the following command:
130134

131135
python manage.py upgradedb
132136

133-
15. PostMaster uses a secret key for certain cryptographic functions. To generate a random key, run the following command:
137+
16. PostMaster uses a secret key for certain cryptographic functions. To generate a random key, run the following command:
134138

135139
python manage.py generatekey
136140

137-
16. You may now exit from the python virtual environment:
141+
17. You may now exit from the python virtual environment:
138142

139143
deactivate
140144

141-
17. Provide the proper permissions on the PostMaster files:
145+
18. Provide the proper permissions on the PostMaster files:
142146

143147
chown -R www-data:www-data /opt/postmaster
144148
chmod -R 550 /opt/postmaster
145149
chmod 770 /opt/postmaster/logs
146150

147-
18. Disable the default Apache site:
151+
19. Disable the default Apache site:
148152

149153
a2dissite 000-default.conf
150154

151-
19. Copy the default PostMaster Apache site configuration and give it the appropriate permissions.
155+
20. Copy the default PostMaster Apache site configuration and give it the appropriate permissions.
152156
It is highly recommended that you implement SSL before using PostMaster in production:
153157

154158
cp /opt/postmaster/git/ops/apache.conf /etc/apache2/sites-available/postmaster.conf
155159
chmod 644 /etc/apache2/sites-available/postmaster.conf
156160
chown root:root /etc/apache2/sites-available/postmaster.conf
157161

158-
20. Enable the PostMaster Apache site:
162+
21. Enable the PostMaster Apache site:
159163

160164
a2ensite postmaster.conf
161165

162-
21. Restart Apache for the changes to take effect:
166+
22. Restart Apache for the changes to take effect:
163167

164168
service apache2 restart
165169

166-
22. PostMaster should now be running. Simply use the username "admin" and the password "PostMaster" to login.
170+
23. PostMaster should now be running. Simply use the username "admin" and the password "PostMaster" to login.
167171
You can change your username and password from Manage -> Administrators.
168-
169-
23. Please keep in mind that the /opt/postmaster/git/db/migrations folder should be backed up after installation/updates.
170-
This is because PostMaster uses database migrations to safely upgrade the database schema,
171-
and this folder contains auto-generated database migration scripts that allow you to revert back if a database migration ever failed.
172-
If this folder is missing, PostMaster can't tell what state your database is in, and therefore, cannot revert back.

docs/Installation/WindowsServer2012R2.md

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -129,17 +129,21 @@ This is done with the following command:
129129

130130
pip install -r "$env:SystemDrive\PostMaster\git\requirements.txt"
131131

132-
26. Copy wfastcgi.py, created by Microsoft Web Platform Installer earlier, to C:\PostMaster\git:
132+
26. Create the PostMaster configuration file from using the sample file that was included:
133133

134-
Copy-Item -Path "$env:SystemDrive\Python27\Scripts\wfastcgi.py" "$env:SystemDrive\PostMaster\git"
134+
Copy-Item "$env:SystemDrive\PostMaster\git\config.default.py "$env:SystemDrive\PostMaster\git\config.py"
135135

136-
27. At this point, PostMaster requires an IIS site. You can either use the "Default Web Site" and change the virtual directory to C:\PostMaster\git,
136+
27. Copy wfastcgi.py, created by Microsoft Web Platform Installer earlier, to C:\PostMaster\git:
137+
138+
Copy-Item "$env:SystemDrive\Python27\Scripts\wfastcgi.py" "$env:SystemDrive\PostMaster\git"
139+
140+
28. At this point, PostMaster requires an IIS site. You can either use the "Default Web Site" and change the virtual directory to C:\PostMaster\git,
137141
or create a new site that points to that directory. This tutorial will use the Default Web Site. To change the virtual directory, use the following commands:
138142

139143
Import-Module WebAdministration
140144
Set-ItemProperty 'IIS:\Sites\Default Web Site\' -Name physicalPath -Value "$env:SystemDrive\PostMaster\git"
141145

142-
28. Now, IIS needs to know how to run PostMaster. The following commands configure FastCGI to be able to use the Python virtual environment created earlier and run PostMaster
146+
29. Now, IIS needs to know how to run PostMaster. The following commands configure FastCGI to be able to use the Python virtual environment created earlier and run PostMaster
143147
(If you are using a site other than "Default Web Site", change that value in the commands below):
144148

145149
Import-Module WebAdministration
@@ -149,41 +153,36 @@ or create a new site that points to that directory. This tutorial will use the D
149153
Add-WebConfiguration -Filter "/system.webServer/fastCgi/application[@fullPath='$env:SystemDrive\PostMaster\env\Scripts\python.exe' and @arguments='$env:SystemDrive\PostMaster\git\wfastcgi.py']/environmentVariables" -Value @{name='PYTHONPATH'; value="$env:SystemDrive\PostMaster\git"} -AtIndex 0
150154
Add-WebConfiguration -Filter "/system.webServer/fastCgi/application[@fullPath='$env:SystemDrive\PostMaster\env\Scripts\python.exe' and @arguments='$env:SystemDrive\PostMaster\git\wfastcgi.py']/environmentVariables" -Value @{name='WSGI_HANDLER'; value='app.app'} -AtIndex 1
151155

152-
29. PostMaster needs to be configured to connect to the MySQL database using the MySQL user created in step 2 of MySQL Preparation.
156+
30. PostMaster needs to be configured to connect to the MySQL database using the MySQL user created in step 2 of MySQL Preparation.
153157
Make sure to replace "password_changeme" and "127.0.0.1' with the actual values supplied in step 2 of MySQL Preparation, and if needed,
154158
replace '127.0.0.1' with the IP address or DNS specified in step 2 of MySQL Preparation:
155159

156160
cd C:\Postmaster\git
157161
python manage.py setdburi 'mysql://postmasteruser:password_changeme@127.0.0.1:3306/servermail'
158162

159-
30. PostMaster needs to create a few tables under the servermail database. This is done via a database migration,
163+
31. PostMaster needs to create a few tables under the servermail database. This is done via a database migration,
160164
which means that only the necessary changes to the database are made, and these changes are reversible if something went wrong.
161165
To start the migration, run the following command:
162166

163167
python manage.py upgradedb
164168

165-
31. PostMaster uses a secret key for certain cryptographic functions. To generate a random key, run the following command:
169+
32. PostMaster uses a secret key for certain cryptographic functions. To generate a random key, run the following command:
166170

167171
python manage.py generatekey
168172

169-
32. By deafult, PostMaster logs to a Linux based path, run the following command to change the log to the text file created in step 11:
173+
33. By deafult, PostMaster logs to a Linux based path, run the following command to change the log to the text file created in step 11:
170174

171175
python manage.py setlogfile "$env:SystemDrive\PostMaster\logs\postmaster.log"
172176

173-
33. You may now exit the Python virtual environment:
177+
34. You may now exit the Python virtual environment:
174178

175179
deactivate
176180

177-
34. Restart IIS to make sure all the changes take effect:
181+
35. Restart IIS to make sure all the changes take effect:
178182

179183
iisreset
180184

181-
35. At this point it is highly recommended that you implement SSL before using PostMaster in production.
185+
36. At this point it is highly recommended that you implement SSL before using PostMaster in production.
182186

183-
36. PostMaster should now be running. Simply use the username "admin" and the password "PostMaster" to login.
187+
37. PostMaster should now be running. Simply use the username "admin" and the password "PostMaster" to login.
184188
You can change your username and password from Manage -> Administrators.
185-
186-
37. Please keep in mind that the C:\PostMaster\git\db\migrations folder should be backed up after installation/updates.
187-
This is because PostMaster uses database migrations to safely upgrade the database schema,
188-
and this folder contains auto-generated database migration scripts that allow you to revert back if a database migration ever failed.
189-
If this folder is missing, PostMaster can't tell what state your database is in, and therefore, cannot revert back.

ops/ansible/roles/postmaster_deploy/tasks/main.yml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,16 @@
2929
file: path=/opt/postmaster/logs state=directory owner={{remote_user}} group=www-data mode=0775 recurse=yes
3030
become: yes
3131

32-
- pip: requirements=/opt/postmaster/git/requirements.txt virtualenv=/opt/postmaster/env
32+
- name: Install python dependencies
33+
pip: requirements=/opt/postmaster/git/requirements.txt virtualenv=/opt/postmaster/env
34+
35+
- name: Checking if config.py exists
36+
stat: path=/opt/postmaster/git/config.py
37+
register: config_file
38+
39+
- name: Copying config.default.py to config.py
40+
copy: src=/opt/postmaster/git/config.default.py dest=/opt/postmaster/git/config.py remote_src=True
41+
when: config_file.stat.exists == False
3342

3443
- include: mysql.yml
3544
when: provision_type == "dev"

0 commit comments

Comments
 (0)