add webapp limesurvey
This commit is contained in:
parent
39267baaad
commit
3063e78dd9
|
@ -0,0 +1,89 @@
|
|||
import os
|
||||
import textwrap
|
||||
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
from orchestra.contrib.orchestration import ServiceController, replace
|
||||
from django.template import Template, Context
|
||||
from orchestra.settings import NEW_SERVERS
|
||||
from .. import settings
|
||||
|
||||
from . import WebAppServiceMixin
|
||||
|
||||
|
||||
class LimesurveyController(WebAppServiceMixin, ServiceController):
|
||||
"""
|
||||
Installs the latest version of Limesurvey available on git github.com/LimeSurvey/LimeSurvey
|
||||
"""
|
||||
verbose_name = _("Limesurvey")
|
||||
model = 'webapps.WebApp'
|
||||
default_route_match = "webapp.type == 'limesurvey-php'"
|
||||
doc_settings = (settings,
|
||||
('WEBAPPS_DEFAULT_MYSQL_DATABASE_HOST',)
|
||||
)
|
||||
|
||||
|
||||
def save(self, webapp):
|
||||
context = self.get_context(webapp)
|
||||
perms = Template(textwrap.dedent("""\
|
||||
{% if sftpuser %}
|
||||
chown -R {{sftpuser}}:{{sftpuser}} {{home}}/webapps/{{app_name}}
|
||||
{% else %}
|
||||
chown -R {{user}}:{{group}} {{home}}/webapps/{{app_name}}
|
||||
{% endif %}
|
||||
"""
|
||||
))
|
||||
linenohub = Template(textwrap.dedent("""\
|
||||
{% if sftpuser %}
|
||||
su - {{sftpuser}} --shell /bin/bash << 'EOF'
|
||||
{% else %}
|
||||
su - {{user}} --shell /bin/bash << 'EOF'
|
||||
{% endif %}
|
||||
"""
|
||||
))
|
||||
context.update({'perms' : perms.render(Context(context)), 'linenohub' : linenohub.render(Context(context)) })
|
||||
self.append(textwrap.dedent("""\
|
||||
if [[ $(ls "%(app_path)s" | wc -l) -gt 1 ]]; then
|
||||
echo "App directory not empty." 2> /dev/null
|
||||
exit 0
|
||||
fi
|
||||
mkdir -p %(app_path)s
|
||||
|
||||
# Download limesurvey
|
||||
git clone --depth 1 https://github.com/LimeSurvey/LimeSurvey.git %(app_path)s/
|
||||
|
||||
# create database config
|
||||
if [[ ! -e %(app_path)s/application/config/config.php ]]; then
|
||||
cp %(app_path)s/application/config/config-sample-mysql.php %(app_path)s/application/config/config.php
|
||||
sed -i "s/'connectionString' => .*/'connectionString' => 'mysql:host=%(db_host)s;port=3306;dbname=%(db_name)s;',/" %(app_path)s/application/config/config.php
|
||||
sed -i "s/'username' => .*/'username' => '%(db_user)s',/" %(app_path)s/application/config/config.php
|
||||
sed -i "s/'password' => .*/'password' => '%(password)s',/" %(app_path)s/application/config/config.php
|
||||
|
||||
fi
|
||||
|
||||
# add correct perms
|
||||
%(perms)s
|
||||
find %(app_path)s/ -type f -exec chmod -x {} ";"
|
||||
|
||||
# Run install moodle cli command on the background, because it takes so long...
|
||||
stdout=$(mktemp)
|
||||
stderr=$(mktemp)
|
||||
%(linenohub)s
|
||||
cd %(app_path)s/application/commands/
|
||||
php console.php install admin "%(password)s" admin "%(email)s" verbose
|
||||
EOF
|
||||
""") % context
|
||||
)
|
||||
|
||||
def get_context(self, webapp):
|
||||
context = super(LimesurveyController, self).get_context(webapp)
|
||||
contents = webapp.content_set.all()
|
||||
context.update({
|
||||
'db_name': webapp.data['db_name'],
|
||||
'db_user': webapp.data['db_user'],
|
||||
'password': webapp.data['password'],
|
||||
'db_host': 'localhost' if webapp.target_server.name in NEW_SERVERS else settings.WEBAPPS_DEFAULT_MYSQL_DATABASE_HOST,
|
||||
'email': webapp.account.email,
|
||||
'sftpuser': webapp.sftpuser.username if webapp.target_server.name in NEW_SERVERS else None ,
|
||||
})
|
||||
return replace(context, '"', "'")
|
|
@ -21,7 +21,7 @@ class CMSAppForm(PHPAppForm):
|
|||
db_user = forms.CharField(label=_("Database user"),
|
||||
help_text=_("Database user exclusively used for this webapp."))
|
||||
password = forms.CharField(label=_("Password"),
|
||||
help_text=_("Initial database and WordPress admin password.<br>"
|
||||
help_text=_("Initial database and App admin password.<br>"
|
||||
"Subsequent changes to the admin password will not be reflected."))
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
from .cms import CMSApp
|
||||
|
||||
|
||||
class LimesurveyApp(CMSApp):
|
||||
name = 'limesurvey-php'
|
||||
verbose_name = "Limesurvey"
|
||||
help_text = _(
|
||||
"This installs the latest version of Limesurvey into the webapp directory.<br>"
|
||||
"A database and database user will automatically be created for this webapp.<br>"
|
||||
"This installer creates a user 'admin' with a randomly generated password.<br>"
|
||||
"The password will be visible in the 'password' field after the installer has finished."
|
||||
)
|
||||
icon = 'orchestra/icons/apps/limesurvey.png'
|
||||
db_prefix = 'lime_'
|
||||
|
||||
def get_detail(self):
|
||||
return self.instance.data.get('php_version', '')
|
Binary file not shown.
After Width: | Height: | Size: 4.7 KiB |
|
@ -0,0 +1,32 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<svg width="344.59042" height="374.29803" version="1.1" viewBox="0 0 344.59042 374.29803" xmlns="http://www.w3.org/2000/svg">
|
||||
<defs>
|
||||
<linearGradient id="linearGradient925" x1="8.9167995" x2="33.738998" y1="11.905" y2="11.905" gradientTransform="matrix(12.491,0,0,5.9363,232.56,210.1)" gradientUnits="userSpaceOnUse">
|
||||
<stop stop-color="#11861e" offset="0" />
|
||||
<stop stop-color="#0eb13f" offset="1" />
|
||||
</linearGradient>
|
||||
<linearGradient id="linearGradient997" x1="494.85999" x2="590.25" y1="351.31" y2="351.31" gradientTransform="translate(135.91,623.3)" gradientUnits="userSpaceOnUse">
|
||||
<stop stop-color="#4dcf00" offset="0" />
|
||||
<stop stop-color="#50d400" offset="1" />
|
||||
</linearGradient>
|
||||
<linearGradient id="linearGradient1005" x1="497.82001" x2="606.04999" y1="473.53" y2="473.53" gradientTransform="translate(135.91,623.3)" gradientUnits="userSpaceOnUse">
|
||||
<stop stop-color="#4ed000" offset="0" />
|
||||
<stop stop-color="#50d400" offset="1" />
|
||||
</linearGradient>
|
||||
<linearGradient id="linearGradient1013" x1="318.29999" x2="509.31" y1="529.09003" y2="529.09003" gradientTransform="translate(135.91,623.3)" gradientUnits="userSpaceOnUse">
|
||||
<stop stop-color="#3bb200" offset="0" />
|
||||
<stop stop-color="#4dce00" offset="1" />
|
||||
</linearGradient>
|
||||
<linearGradient id="linearGradient1021" x1="304.04001" x2="407.64999" y1="397.17999" y2="397.17999" gradientTransform="translate(135.91,623.3)" gradientUnits="userSpaceOnUse">
|
||||
<stop stop-color="#3bb100" offset="0" />
|
||||
<stop stop-color="#40ba00" offset="1" />
|
||||
</linearGradient>
|
||||
</defs>
|
||||
<g transform="translate(-304.03838,-209.99777)" stroke-width="8.611">
|
||||
<path class="b" d="m 350.79,246.11 a 104.37,104.37 0 0 1 33.325,6.1827 189.37,189.37 0 0 1 30.819,13.95 266.08,266.08 0 0 1 28.244,18.23 c 4.495,3.3411 8.8952,6.7424 13.218,10.333 2.1786,1.7739 4.3055,3.608 6.4066,5.4852 1.0592,0.92139 2.1097,1.8772 3.1689,2.8244 l 1.5672,1.4983 1.7222,1.6017 -31.31,0.0689 2.79,-3.2722 2.5833,-2.8933 c 1.7222,-1.9116 3.4444,-3.7458 5.2441,-5.5886 q 5.313,-5.4164 10.833,-10.488 c 3.6769,-3.3755 7.4916,-6.6391 11.306,-9.808 1.9375,-1.5672 3.8836,-3.1344 5.8211,-4.6672 l 2.9278,-2.3164 2.9966,-2.213 c 7.9738,-5.9588 16.249,-11.444 24.765,-16.593 8.516,-5.149 17.308,-9.7391 26.264,-14.002 a 268.42,268.42 0 0 1 56.144,-19.297 230.43,230.43 0 0 1 29.278,-4.4605 169.64,169.64 0 0 1 29.725,-0.0689 c -4.1591,2.8589 -8.3786,5.2786 -12.503,7.8705 -2.0408,1.2917 -4.1247,2.5833 -6.2,3.7458 -1.0247,0.61138 -2.0408,1.2228 -3.0655,1.8772 l -3.0655,1.8772 c -8.146,4.9083 -16.077,9.8769 -23.982,14.716 -15.741,9.808 -31,19.659 -45.957,29.811 -14.957,10.152 -29.536,20.529 -43.804,31.293 -3.5392,2.7211 -7.1213,5.3819 -10.626,8.1719 -3.5047,2.79 -6.9836,5.5197 -10.462,8.2752 -3.4789,2.7555 -6.8888,5.623 -10.221,8.4474 -1.6705,1.4294 -3.3411,2.8244 -4.9772,4.228 l -4.495,3.9525 -18.944,16.662 -12.391,-16.585 c -0.24111,-0.34445 -0.68027,-0.86111 -1.0592,-1.2917 l -1.1883,-1.4294 -2.4197,-2.8933 -4.9427,-5.8211 q -5.0116,-5.8211 -10.118,-11.616 c -6.8113,-7.6983 -13.726,-15.362 -20.847,-22.888 -7.121,-7.526 -14.346,-14.957 -21.975,-22.139 a 248.98,248.98 0 0 0 -24.593,-20.77 z" fill="url(#linearGradient925)" />
|
||||
<path class="c" d="m 455.04,524.95 a 91.734,91.734 0 0 1 -82.132,-51.064 l -54.611,23.508 a 151.02,151.02 0 0 0 191.01,76.811 l -23.474,-54.611 a 91.398,91.398 0 0 1 -30.793,5.3561 z" fill="url(#linearGradient1013)" />
|
||||
<path class="d" d="m 363.43,433.27 a 91.708,91.708 0 0 1 44.218,-78.361 l -38.431,-45.811 a 151,151 0 0 0 -55.972,176.16 l 54.706,-23.508 a 91.432,91.432 0 0 1 -4.5208,-28.477 z" fill="url(#linearGradient1021)" />
|
||||
<path class="e" d="m 546.13,312.95 -51.27,37.889 a 92.491,92.491 0 0 1 40.713,38.836 l 54.68,-23.508 A 152.07,152.07 0 0 0 546.13,312.951 Z" fill="url(#linearGradient997)" />
|
||||
<path class="f" d="m 606.05,433.31 a 150.02,150.02 0 0 0 -10.462,-55.188 l -54.577,23.474 a 91.63,91.63 0 0 1 -43.193,112.72 l 23.508,54.628 a 151.19,151.19 0 0 0 84.724,-135.63 z" fill="url(#linearGradient1005)" />
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 4.0 KiB |
Loading…
Reference in New Issue