beto-isard
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights New
    • Engagement control
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       Owned this note    Owned this note      
    Published Linked with GitHub
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    # post-install v2 ## Install server #### /mnt/crear_vm_dd.sh ```bash #/bin/bash #USAGE # el num_host especifica el final de la adreça ip # exemple: bash test0 170 # ==> crearà una màquina virtual amb nom test0 i ip pública: 136.243.112.170 # bash create_vm_dd.sh NOM_VM NUM_HOST # definim directoris on anirà el xml que defineix # la vm i els difernts discos virtuals. # Cal uns discos més ràpids i amb més IOPs pel S.O i les bases de dades # El disc amb els documents de moodle/nextcloud... pot anar amb un # punt de muntatge més lent o amb caché BASE_DIR_SO="/mnt/nvme" BASE_DIR_DB="/mnt/nvme" BASE_DIR_DATA="/mnt/cache" # qcow base del que derivara el disc del sistema operatiu DEBIAN_BASE_PATH="/mnt/nvme/base-debian.qcow2" #configuració de la IP, la part final de la ip es el segon paràmetre # del script ($2) PREFIX_IP="136.243.112" #Tamany dels discos SIZE_DB="50G" SIZE_DATA="1T" #MEMORY &/ CPU MEMORY_SIZE_MB=4098 VCPUS=2 #ROOT PASSWORD PWD_ROOT=Pirineu5 set -e if [ -z $2 ]; then # No envar set echo "EXAMPLE: bash crear_escola.sh nomescola 186" echo " on nomescola és sense domini i 186 és el número de host" exit 1 fi for DIR in "$BASE_DIR_SO/$1" "$BASE_DIR_DB/$1" "$BASE_DIR_DATA/$1" do if [ -d "$DIR" ]; then # Take action if $DIR exists. # echo "ERROR: directory $DIR exists" exit 1 fi done mkdir -p $BASE_DIR_SO/$1 mkdir -p $BASE_DIR_DB/$1 mkdir -p $BASE_DIR_DATA/$1 #creació d'imatges qcow, el sistema operatiu es una imatge incremental d'un debian 10 qemu-img create -F qcow2 -f qcow2 -b $DEBIAN_BASE_PATH $BASE_DIR_SO/$1/$1_so.qcow2 qemu-img create -f qcow2 $BASE_DIR_DB/$1/$1_db.qcow2 $SIZE_DB qemu-img create -f qcow2 $BASE_DIR_DATA/$1/$1_data.qcow2 $SIZE_DATA virt-install --virt-type kvm --name $1 \ --os-type=linux \ --os-variant debian10 \ --disk path=$BASE_DIR_SO/$1/$1_so.qcow2 \ --disk path=$BASE_DIR_DB/$1/$1_db.qcow2 \ --disk path=$BASE_DIR_DATA/$1/$1_data.qcow2 \ --memory=$MEMORY_SIZE_MB \ --cpu host-passthrough \ --vcpus=$VCPUS \ --network=bridge:virbr1 \ --network network=local-backups \ --graphics none \ --print-xml > $BASE_DIR_SO/$1/$1.xml virsh define $BASE_DIR_SO/$1/$1.xml echo $PREFIX_IP > "/tmp/prefix_ip" virt-copy-in -d $1 /tmp/prefix_ip /var/lib/ echo $2 > "/tmp/hostnumber" virt-copy-in -d $1 /tmp/hostnumber /var/lib/ echo $1 > "/tmp/hostname" virt-copy-in -d $1 /tmp/hostname /var/lib/ virt-copy-in -d $1 /mnt/vmscripts/base_setup.service /lib/systemd/system virt-copy-in -d $1 /mnt/vmscripts/base_setup.sh /lib/ virt-sysprep --root-password password:$PWD_ROOT -a /mnt/nvme/$1/$1_so.qcow2 guestfish -a /mnt/nvme/$1/$1_so.qcow2 <<_EOF_ run mount /dev/bbb-vg/root / ln-s /lib/systemd/system/base_setup.service /etc/systemd/system/multi-user.target.wants/base_setup.service _EOF_ virsh start $1 ``` #### /mnt/vmscripts/base_setup.service ```conf [Unit] Description=Automated preinstallation After=NetworkManager.service [Service] #ExecStartPre=/bin/bash -c 'until ping -c1 hetzner.com; do sleep 1; done;' ExecStart=/bin/bash -c 'cd /lib && ./base_setup.sh 1>/tmp/base_setup.log 2>/tmp/base_setup-error.log' ExecStartPost=/bin/rm /etc/systemd/system/multi-user.target.wants/base_setup.service Type=simple [Install] WantedBy=multi-user.target ``` #### /mnt/vmscripts/base_setup.sh ```bash #!/bin/bash hostnumber=$(cat /var/lib/hostnumber) hostname=$(cat /var/lib/hostname) prefix_ip=$(cat /var/lib/prefix_ip) servername="$hostname" host=$hostnumber if_out_name="enp1s0" if_out_newname="out" ### range: 136.243.25.176 - 136.243.25.191 #ip_out="136.243.25.$host" ip_out="$prefix_ip.$host" mask_out="32" gw_out="157.90.134.156" #dns_out="8.8.8.8" dns_out="1.1.1.1" ################### # NETWORK # Assigna el nom del servidor al nom de la màquina echo "$servername" > /etc/hostname sysctl -w kernel.hostname=$servername apt install -y network-manager systemctl enable --now NetworkManager # Elimina totes les conexions actuals nmcli --fields UUID,TIMESTAMP-REAL con show | awk '{print $1}' | while read line; do nmcli con delete uuid $line; done echo "" > /etc/network/interfaces # Canvia el nom de les interfícies enp que s'afegeixin per 'out' MAC=$(cat /sys/class/net/$if_out_name/address) #quan arranqui el server i es trobi la tarjeta amb aquesta MAC li canviarà el nom a la interface per out echo "SUBSYSTEM==\"net\", ACTION==\"add\", DRIVERS==\"?*\", ATTR{address}==\"$MAC\", KERNEL==\"enp*\", NAME=\"$if_out_newname\"" >> /etc/udev/rules.d/70-persistent-net.rules # Com no podem reiniciar, fem el canvi de nom manualment, cal donar de baixar la connexió per poder # canviar el nom ip link set $if_out_name down ip link set $if_out_name name $if_out_newname ip link set $if_out_newname up # definir al network manager una connexió de tipus ethernet per aquest nom de interface nmcli con add con-name $if_out_newname ifname $if_out_newname type ethernet # modificar aquesta connexió afegint la ip, la màscara (que com serà ip pública sera /32) nmcli con mod $if_out_newname ipv4.method manual ipv4.addresses "$ip_out/$mask_out" ipv4.gateway "$gw_out" ipv4.dns "$dns_out" #no volem ipv6 nmcli con mod $if_out_newname ipv6.method ignore #activem la connexió i apliquem canvis nmcli con up $if_out_newname # create ssh HOST KEYs ssh-keygen -A #create keys for user root ssh-keygen -b 2048 -t rsa -f /root/.ssh/id_rsa -q -N "" apt update -y apt install rsync -yes # SSH apt install sshpass -y echo "PermitRootLogin yes" >> /etc/ssh/sshd_config systemctl restart sshd # crear sistema de fitxers ext4 als dos discos de db y data mkfs.ext4 /dev/vdb mkfs.ext4 /dev/vdc # crea els directoris on farem el muntatge mkdir -p /opt/digitaldemocratic/db mkdir -p /opt/digitaldemocratic/data # afegim al fstab el muntatge dels discos de db i data per tal que al reiniciar # estigui muntat als directoris de /opt/digitaldemocratic/db i data echo "/dev/vdb /opt/digitaldemocratic/db ext4 defaults,noatime,nodiratime,noquota 0 0" >> /etc/fstab echo "/dev/vdc /opt/digitaldemocratic/data ext4 defaults,noatime,nodiratime,noquota 0 0" >> /etc/fstab # remuntar el que falti partir del fstab mount -a # paquets extra apt update -y apt upgrade -y apt install -y tmux vim htop # Digitaldemocratic mkdir /opt/src cd /opt/src git clone https://gitlab.com/digitaldemocratic/digitaldemocratic cd digitaldemocratic cp digitaldemocratic.conf.sample digitaldemocratic.conf cp -r custom.sample custom ./securize_conf.sh # Canvia els noms de domini de la configuració del dd pel hostname de la màquina sed -i "s/DOMAIN=mydomain.com/DOMAIN=$hostname.digitaldemocratic.net/g" digitaldemocratic.conf sed -i "s/LETSENCRYPT_DNS=/LETSENCRYPT_DNS=$hostname.digitaldemocratic.net/g" digitaldemocratic.conf sed -i "s/LETSENCRYPT_EMAIL=/LETSENCRYPT_EMAIL=info@digitaldemocratic.net/g" digitaldemocratic.conf echo "######## BASE CONFIGURATION FINISHED ##########" #echo "Afegeix la teva clau api de gandi al /opt/digitaldemocratic/digitaldemocratic.conf i fes make up && sleep 20 && make add-plugins" ./dd-ctl repo-update # si volem llançar el dd-ctl en un tmux per si ens volem connectar a veure com va el process amb "tmux a" # tmux new-session -d -s dd './dd-ctl all' # en aquest script no podem fer servir el tmux perque no tenim un tty obert llavors: ./dd-ctl all ``` # 1. Instal·lació des de cero: - Clonar el directori de digital democratic ```bash mkdir /opt/src git clone https://gitlab.com/digitaldemocratic/digitaldemocratic /opt/src/digitaldemocratic cd /opt/src/digitaldemocratic cp digitaldemocratic.conf.sample digitaldemocratic.conf bash securize_conf.sh apt install -y vim tmux ``` - Canviem el nom del domini ```bash sed -i s/^TITLE/#TITLE/ digitaldemocratic.conf sed -i s/^DOMAIN/#DOMAIN/ digitaldemocratic.conf echo "### PERSONALIZED VARS" >> digitaldemocratic.conf echo 'TITLE="El que sigui"' >> digitaldemocratic.conf echo 'DOMAIN=elquesigui.net' >> digitaldemocratic.conf ``` - Copiem el custom.sample i fem un make all ```bash cp -r custom.sample custom ./dd-ctl all ``` ## Post-install ### custom title ```bash #comment the default title in conf file sed -i s/^TITLE/#TITLE/ digitaldemocratic.conf sed -i s/^DOMAIN/#DOMAIN/ digitaldemocratic.conf echo "### PERSONALIZED VARS" >> digitaldemocratic.conf echo 'TITLE="Test1 DD"' >> digitaldemocratic.conf echo 'TITLE_SHORT="test1"' >> digitaldemocratic.conf echo 'DOMAIN=test1.digitaldemocratic.net' >> digitaldemocratic.conf ``` Si volem aplicar els canvis i està executant-se el contenidor, fer un restart: ```bash ./dd-ctl down ./dd-ctl all ./dd-ctl up ``` ![](https://i.imgur.com/IkfXMjm.png) (no dóna opció a sso?) ### Moodle Quan entres amb l'usuari i contrasenya local et surt això la primera vegada: ![](https://i.imgur.com/5aHHYeN.png) ### keycloak **REALM**: A realm is a space where you manage objects, including users, applications, roles, and groups. **CLIENTS**: Clients are trusted browser apps and web services in a realm. These clients can request a login. You can also define client specific roles. **CLIENT SCOPES**: Client scopes allow you to define a common set of protocol mappers and roles, which are shared between multiple clients **MAPPERS** #### Resumen 1. Account avatar 2. On single Role Attribute Go to https://sso.DOMINI/auth/admin/master/console ![](https://i.imgur.com/1FGGqna.png) ![](https://i.imgur.com/CGsqKjy.png) ![](https://i.imgur.com/Q2i349B.png) ![](https://i.imgur.com/KYbY4ao.png) ![](https://i.imgur.com/oJJPRdp.png) ### Client Nextcloud Keycloak: * Afegir group_list mapper (member) ![](https://i.imgur.com/sgCBXwt.png) ![](https://i.imgur.com/qKVlAHq.png) ![](https://i.imgur.com/vu4MwE2.png) ![](https://i.imgur.com/g4pBkH6.png) * Quotas​ ```bash sql ALTER DATABASE your_database_name SET log_statement = 'all'; ALTER DATABASE your_database_name SET log_statement = 'mod'; ALTER DATABASE your_database_name SET log_statement = 'none'; ALTER DATABASE your_database_name SET log_directory = '/path/donde/sea'; ALTER DATABASE your_database_name SET log_filename = 'postgresql-%Y-%m-%d_%H%M%S.log'; ALTER DATABASE your_database_name SET log_line_prefix = '%m [%p] %q%u@%h%d ' ``` ### j. crear servidor de sftp para una carpeta concreta para equipo de wordpress solo toque lo suyo Se pilla un docker que le dices la ruta, donde quieres mapear, usuario, puerto... * user: javier * pwd: jugand0conwordpress * protocolo: sftp * path_folder: /opt/digitaldemocratic/src/wordpress/wp-content/ * usuario como el que va a entrar: 33 (www-data) * carpeta dentro de su home donde se va a mapear la carpeta: home/javier/upload (cuando se conecte verá upload y dentro el contenido de path_folder) docker pull atmoz/sftp cd /opt/digitaldemocratic/src/wordpress/wp-content/ chown -R www-data:www-data ./ firewall-cmd --add-port=3222/tcp docker run -v /opt/digitaldemocratic/src/wordpress/wp-content:/home/javier/upload -p 3222:22 -d atmoz/sftp javier:jugand0conwordpress:33 * Displayname ![](https://i.imgur.com/sgCBXwt.png) ![](https://i.imgur.com/qKVlAHq.png) ![](https://i.imgur.com/vu4MwE2.png) Script: ``` var Output = user.getFirstName()+" "+user.getLastName(); Output; ``` ![](https://i.imgur.com/iyl9lYV.png) ### Client Wordpress ![](https://i.imgur.com/Nk8YPCI.png) ![](https://i.imgur.com/3ZRPyzd.png) Configuration: ![](https://i.imgur.com/uOwYjOJ.png) Script: ``` var Output = user.getFirstName()+" "+user.getLastName(); Output; ``` ### SAML PLUGINS ACTIVATION #### MOODLE 1. Login a moodle com admin via: https://moodle.\DOMINI/login/index.php?saml=off `cat /opt/src/digitaldemocratic/digitaldemocratic.conf | grep -i moodle_admin` ![](https://i.imgur.com/zhdMsjM.png) 2. Entrar a "Administració del lloc" -> Connectors -> Autenticació (SAML2) ![](https://i.imgur.com/SZ19er2.png) ![](https://i.imgur.com/KAkxMMZ.png) ![](https://i.imgur.com/eGDFcpi.png) 3. Clic en el botó "Regenerate certificate", acceptar la configuració tal qual i tornar a la pàgina de configuració de SAML2 ![](https://i.imgur.com/dKD6P2Q.png) ![](https://i.imgur.com/0XwEelC.png) 4. Clic en el botó "Lock certificate" ![](https://i.imgur.com/mupXZ7B.png) 5. Veure que "Allowed any auth type" está activat (permet que els usuaris creats via admin tinguin access sso) ![](https://i.imgur.com/WJDUFEa.png) 6. Desa ![](https://i.imgur.com/atcu2a0.png) 7. Al terminal executar el script per autoconfigurar: ``` docker exec isard-sso-admin python3 /admin/saml_scripts/moodle_saml.py ``` 8. Purgar el cache del moodle: ``` docker exec -ti isard-apps-moodle php7 admin/cli/purge_caches.php ``` #### NEXTCLOUD ![](https://i.imgur.com/m2Umdd5.png) ![](https://i.imgur.com/cpd5YEw.png) Click Save (the one in the Common Settings section) ![](https://i.imgur.com/JYG2G6H.png) - Per configurar el email: ![](https://i.imgur.com/5jIt2EE.png) - Los circles: ![](https://i.imgur.com/yyNyUvc.png) Al cercar "Circles" al buscador: Es descarrega: ![](https://i.imgur.com/pzZZ51r.png) Ara sortirà un menú nou ![](https://i.imgur.com/IbRuJqC.png) Tornem a la pantalla de configuració i anem a la secció "Treball en grup" o "Groupware": ![](https://i.imgur.com/yjbOrLz.png) O bé per linies de comandes: ``` docker exec -u www-data isard-apps-nextcloud-app php occ --no-warnings config:app:set circles members_limit --value="150" docker exec -u www-data isard-apps-nextcloud-app php occ --no-warnings config:app:set circles allow_linked_groups --value="1" docker exec -u www-data isard-apps-nextcloud-app php occ --no-warnings config:app:set circles skip_invitation_to_closed_circles --value="1 ``` Por si aca: ``` Add 'skeletondirectory' => '', to your config.php ``` ### Moodle Post-Install Es fa login com a admin del moodle a https://moodle.domini/login/index.php?saml=off ![](https://i.imgur.com/SZ19er2.png) ![](https://i.imgur.com/KAkxMMZ.png) Clic en el botó "Regenerate certificate", acceptar la configuració tal qual i tornar a la pàgina de configuració de SAML2 ![](https://i.imgur.com/dKD6P2Q.png) ![](https://i.imgur.com/eGDFcpi.png) Fem que el certificat expiri en 10 anys: ![](https://i.imgur.com/arxJF6r.png) Clic en el botó "Lock certificate" ![](https://i.imgur.com/mupXZ7B.png) Per executar l'script: ``` docker exec -ti isard-sso-admin openssl req -nodes -new -x509 -keyout /admin/saml_certs/private.key -out /admin/saml_certs/public.cert ``` Omplim el formulari amb almenys un 'Common name' ```docker exec -ti isard-sso-admin python3 admin/nextcloud_saml_onlycerts.py``` I reiniciem: ``` docker restart isard-apps-moodle docker restart isard-sso-keycloak ``` ### Neteja de caché Fer les comandes una a una: `docker exec -ti isard-sso-keycloak /opt/jboss/keycloak/bin/jboss-cli.sh --connect --command='/subsystem=keycloak-server/theme=defaults/:write-attribute(name=cacheThemes,value=false)'` `docker exec -ti isard-sso-keycloak /opt/jboss/keycloak/bin/jboss-cli.sh --connect --command='/subsystem=keycloak-server/theme=defaults/:write-attribute(name=cacheTemplates,value=false)'` `docker exec -ti isard-sso-keycloak /opt/jboss/keycloak/bin/jboss-cli.sh --connect --command='/subsystem=keycloak-server/theme=defaults/:write-attribute(name=staticMaxAge,value=-1)'` `docker exec -ti isard-sso-keycloak /opt/jboss/keycloak/bin/jboss-cli.sh --connect --command='reload'` `docker exec -ti isard-sso-keycloak /opt/jboss/keycloak/bin/jboss-cli.sh --connect --command='/subsystem=keycloak-server/theme=defaults/:write-attribute(name=cacheThemes,value=true)'` `docker exec -ti isard-sso-keycloak /opt/jboss/keycloak/bin/jboss-cli.sh --connect --command='/subsystem=keycloak-server/theme=defaults/:write-attribute(name=cacheTemplates,value=true)' ` ` docker exec -ti isard-sso-keycloak /opt/jboss/keycloak/bin/jboss-cli.sh --connect --command='/subsystem=keycloak-server/theme=defaults/:write-attribute(name=staticMaxAge,value=2592000)'` ` docker exec -ti isard-sso-keycloak /opt/jboss/keycloak/bin/jboss-cli.sh --connect --command='reload' ` ### Personalitzar moodle - Per depurar cachés: https://moodle.DOMINI/admin/purgecaches.php ![](https://i.imgur.com/lw5g14Y.png) - Per desactivar cron: ![](https://i.imgur.com/xT4A2dg.png) ![](https://i.imgur.com/9QBhx4Z.png) ![](https://i.imgur.com/nKgcbYq.png) ### Selecció de tema: ![](https://i.imgur.com/JiRFb8Q.png) ![](https://i.imgur.com/fmWmDwX.png) Configurar a gusto: ![](https://i.imgur.com/TEpFOaG.png) https://moodle.DOMINI/admin/settings.php?section=themesettingcbe ![](https://i.imgur.com/mfMrRjD.png) ### Per configurar els blocs: * Afegir bloques: ![](https://i.imgur.com/7zHXvZG.png) ![](https://i.imgur.com/x91xIW4.png) ![](https://i.imgur.com/tBCmDqM.png) https://moodle.DOMINI/my/indexsys.php ![](https://i.imgur.com/KHofHbp.png) ![](https://i.imgur.com/OqTKDC6.png) * Eliminar els blocs: * Plans d'aprendizatge: DESACTIVAR * Cursos visitats recentment: DESACTIVAR * Fitxers privats: DESACTIVAR * Usuaris en línia: DESACTIVAR * Esdeveniments propers: DESACTIVAR * Insígnies recents: DESACTIVAR * 3iP Mods pending: AFEGEIX Ens hauria de quedar així: ![](https://i.imgur.com/4snUpDS.png) ```bash docker exec isard-apps-moodle php7 /var/www/html/admin/cli/cfg.php --name=guestloginbutton --set=0 docker exec isard-apps-moodle php7 /var/www/html/admin/cli/cfg.php --name=enrol_plugins_enabled --set=manual docker exec isard-apps-moodle php7 /var/www/html/admin/cli/cfg.php --name=enablemobilewebservice --set=0 docker exec isard-apps-moodle php7 /var/www/html/admin/cli/cfg.php --name=enablebadges --set=0 ``` ### Permisos de rol dels usuaris ![](https://i.imgur.com/emep2Qz.png) Treure aquests permisos a l'usuari autenticat: - moodle/my:manageblocks : DESACTIVAR - moodle/user:manageownfiles: DESACTIVAR - moodle/user:editownmessageprofile: DESACTIVAR - moodle/user:editownprofile: DESACTIVAR - report/usersessions:manageownsessions: DESACTIVAR - moodle/user:manageownblocks: DESACTIVAR Per editar els rols d'aquesta manera: ![](https://i.imgur.com/tJjyWER.png) Cliquem la icona i anem a la part de baix de la pàgina per assignar els permisos. Ens trobarem amb aixó: ![](https://i.imgur.com/H4Tpjyu.png) A baix podem veure els permisos amb la nomenclatura esmentada. Seleccionem els checkboxes corresponents. Guardem la configuració: ![](https://i.imgur.com/NJE4lA3.png) - Per desactivar el botó d'inici de sessió de visitants : OCULT https://moodle.DOMINI/admin/settings.php?section=manageauths ![](https://i.imgur.com/9YpFux0.png) - Per gestionar plugin de matriculació (https://moodle.DOMINI/admin/settings.php?section=manageenrols) - Accés de visitant: DESHABILITAT - Autoinscripció: DESHABILITAT - Sincronització de la cohort: DESHABILITAT ![](https://i.imgur.com/CkHRifV.png) - Forçar als usuaris a identificar-se en politiques de seguretat (https://moodle.DOMINI/admin/settings.php?section=sitepolicies): ACTIVAR ### Paràmetres de configuració ![](https://i.imgur.com/fnijGS3.png) - Desactivar competències (https://moodle.DOMINI/admin/settings.php?section=competencysettings): DESACTIVAR ![](https://i.imgur.com/9nkK4Qp.png) - Desactivar insígnies (https://moodle.DOMINI/admin/settings.php?section=optionalsubsystems): DESACTIVAR ![](https://i.imgur.com/q4fbWq8.png) - Desactivar missatge "Habilita els serveis web per als dispositius mòbils" (https://moodle.DOMINI/admin/settings.php?section=mobilesettings): DESACTIVAR ![](https://i.imgur.com/r1ds6EP.png) - Seguiment de compleció (https://moodle.DOMINI/admin/settings.php?section=coursesettings): NO ![](https://i.imgur.com/ZUQm0wE.png) - Private sessions Jitsi (https://moodle.DOMINI/admin/settings.php?section=modsettingjitsi): NO ![](https://i.imgur.com/pNUknn3.png) ### Nextcloud Submission ![](https://i.imgur.com/WUG17ft.png) Si OnlyOffice està configurat al nextcloud podem accedir al document en: https://nextcloud.DOMINI/apps/onlyoffice/ ![](https://i.imgur.com/qrVxYOV.png) Al NextCloud entrant com a admin: https://nextcloud.DOMINI/apps/files/?dir=/&fileid=49 ![](https://i.imgur.com/dyteEcl.png) S'anomenarà template.docx: ![](https://i.imgur.com/jMCVKoJ.png) (Y ahora qué?) ### Canviar idioma Per posar el català com a idioma per defecte: ![](https://i.imgur.com/6mFDsn0.png) Apareixerà una llista on sortirà el català disponible per instal·lar. S'instal·la i se sel·leciona com a idioma principal: ![](https://i.imgur.com/tHlALmW.png) ![](https://i.imgur.com/auCPDtG.png) Desar els canvis i purgar [la caché](https://hackmd.io/Pqia-LNAScyGfI27oB8ScQ?both#Neteja-de-cach%C3%A9). ## Troubleshooting ### 1. Crear una snapshot de la VM `virsh snapshot-create-as dd-baixeras --name v1` ### 2. Fer un backup de la instal·lació. Per guardar-la en /opt/old: ```bash= cd /opt/src/digitaldemocratic docker-compose down cd /opt mkdir /opt/old mkdir /opt/old/digitaldemocratic mkdir /opt/old/digitaldemocratic/db mkdir /opt/old/digitaldemocratic/data mv /opt/digitaldemocratic/db/* /opt/old/digitaldemocratic/db/ mv /opt/digitaldemocratic/data/* /opt/old/digitaldemocratic/data/ mv /opt/digitaldemocratic/backup /opt/old/digitaldemocratic/ mv /opt/digitaldemocratic/src /opt/old/digitaldemocratic/ mv /opt/src /opt/old/ ``` ### 3. Automatizació en moodle amb SQL Exemple de SQL: ``` #desactivar cron UPDATE mdl_sessions SET timemodified = $1 WHERE id=$2","parameters: $1 = '1622324372', $2 = '4' #activar cron UPDATE",2021-05-29 23:41:14 CEST,5/22855,0,LOG,00000,"execute <unnamed>: UPDATE mdl_config SET value = $2 WHERE name = $1","parameters: $1 = 'cron_enabled', $2 = '0' INSERT INTO mdl_config_log (userid,timemodified,name,oldvalue,value,plugin) VALUES($1,$2,$3,$4,$5,$6) RETURNING id","parameters: $1 = '2', $2 = '1622324474', $3 = 'cron_enabled', $4 = '1', $5 = '0', $6 = NULL 2021-05-29 23:40:49.420 CEST,"moodle","moodle",319,"172.25.0.14:54268",60b2b4e1.13f,1,"UPDATE",2021-05-29 23:40:49 CEST,5/22512,0,LOG,00000,"execute <unnamed>: UPDATE mdl_sessions SET timemodified = $1 WHERE id=$2","parameters: $1 = '1622324449', $2 = '4'",,,,,,,,"","client backend" 2021-05-29 23:40:49.427 CEST,"moodle","moodle",319,"172.25.0.14:54268",60b2b4e1.13f,2,"UPDATE",2021-05-29 23:40:49 CEST,5/22515,0,LOG,00000,"execute <unnamed>: UPDATE mdl_user SET lastip = $1,lastaccess = $2 WHERE id=$3","parameters: $1 = '172.25.0.6', $2 = '1622324449', $3 = '2'",,,,,,,,"","client backend" 2021-05-29 23:40:49.573 CEST,"moodle","moodle",319,"172.25.0.14:54268",60b2b4e1.13f,3,"UPDATE",2021-05-29 23:40:49 CEST,5/22590,0,LOG,00000,"execute <unnamed>: UPDATE mdl_config SET value = $2 WHERE name = $1","parameters: $1 = 'cron_enabled', $2 = '1'",,,,,,,,"","client backend" 2021-05-29 23:40:49.574 CEST,"moodle","moodle",319,"172.25.0.14:54268",60b2b4e1.13f,4,"INSERT",2021-05-29 23:40:49 CEST,5/22591,0,LOG,00000,"execute <unnamed>: INSERT INTO mdl_config_log (userid,timemodified,name,oldvalue,value,plugin) VALUES($1,$2,$3,$4,$5,$6) RETURNING id","parameters: $1 = '2', $2 = '1622324449', $3 = 'cron_enabled', $4 = '0', $5 = '1', $6 = NULL",,,,,,,,"","client backend" 2021-05-29 23:40:49.577 CEST,"moodle","moodle",319,"172.25.0.14:54268",60b2b4e1.13f,5,"UPDATE",2021-05-29 23:40:49 CEST,5/22593,0,LOG,00000,"execute <unnamed>: UPDATE mdl_config SET name = $1,value = $2 WHERE id=$3","parameters: $1 = 'scheduledtaskreset', $2 = '1622324449', $3 = '433'",,,,,,,,"","client backend" 2021-05-29 23:40:49.648 CEST,"moodle","moodle",319,"172.25.0.14:54268",60b2b4e1.13f,6,"INSERT",2021-05-29 23:40:49 CEST,5/22658,0,LOG,00000,"execute <unnamed>: INSERT INTO mdl_logstore_standard_log (eventname,component,action,target,objecttable,objectid,crud,edulevel,contextid,contextlevel,contextinstanceid,userid,courseid,relateduserid,anonymous,other,timecreated,origin,ip,realuserid) VALUES ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14,$15,$16,$17,$18,$19,$20)","parameters: $1 = '\core\event\config_log_created', $2 = 'core', $3 = 'created', $4 = 'config_log', $5 = 'config_log', $6 = '1846', $7 = 'c', $8 = '0', $9 = '1', $10 = '10', $11 = '0', $12 = '2', $13 = '0', $14 = NULL, $15 = '0', $16 = '{""name"":""cron_enabled"",""oldvalue"":""0"",""value"":""1"",""plugin"":null}', $17 = '1622324449', $18 = 'web', $19 = '172.25.0.6', $20 = NULL",,,,,,,,"","client backend" ``` No ### 4. Resum en csv de mapejos de docker-compose ```bash import yaml f=open('docker-compose.yml') compose_yaml = f.read() f.close() d = yaml.load(compose_yaml) l=[] for k,c in d['services'].items(): for v in c.get('volumes',[]): print(v) fields = [k]+v.split(':') l.append(fields) # import pprint #pprint.pprint(fields) #print(mapper) import pprint pprint.pprint(l) l.sort(key=lambda x:(x[1],x[0])) for t in l: print(','.join(t)) ``` ### 5. Logs de Postgres La idea és tenir els logs a /opt/digitaldemocratic/db/postgres/extra_logs.conf amb aquest contingut: ```bash rm -f /opt/digitaldemocratic/db/postgres/extra_logs.conf cat > /opt/digitaldemocratic/db/postgres/extra_logs.conf << "EOF" #log_statement = 'all' #log_statement = 'none' log_statement = 'mod' #log_timezone = 'Europe/Madrid' log_line_prefix = '%m [%p] %q%u@%h%d ' log_rotation_age = 1d log_truncate_on_rotation = on log_file_mode = 0640 log_filename = 'postgresql-%Y-%m-%d_%H%M%S.log' #log_directory = '/pg_log' logging_collector = on #log_destination = 'stderr' # Valid values are combinations of log_destination = 'stderr,csvlog' EOF ``` ```bash #Afegim una línia al final del fitxer postgresql.conf echo "include_dir extras_conf" >> /opt/digitaldemocratic/db/postgres/postgresql.conf #Llavors es crea una carpeta per les configuracions extra: mkdir /opt/digitaldemocratic/db/postgres/extras_conf #Amb un fitxer amb una linia comentada a dins: echo "# extra configs in this directory" > /opt/digitaldemocratic/db/postgres/extras_conf/readme.conf #Quan es necessiti activar els logs d'updates/inserts: rm -f /opt/digitaldemocratic/db/postgres/extras_conf/extra_logs.conf cp /opt/digitaldemocratic/db/postgres/extra_logs.conf /opt/digitaldemocratic/db/postgres/extras_conf/ docker restart isard-apps-postgresql ``` Per recollir canvis de moodle, intentar que no interfereixen les consultes de taules que se actualitzan amb cron cada pocs minuts: ```bash tail -f log/postgresql-2021-05-29_230400.csv | grep moodle | grep -v mdl_task_log | grep -v mdl_task_scheduled | grep -v mdl_question_response_analysis | grep -v mdl_question ``` I quan vulguis esborrar els logs i deixar tot com estava simplement s'ha de esborrar el fitxer de configs extres i els logs, i reiniciar postgres. ### 6. Logs de Postgres en caliente cambiando desde SQL ??? ```sql ALTER DATABASE your_database_name SET log_statement = 'all'; ALTER DATABASE your_database_name SET log_statement = 'mod'; ALTER DATABASE your_database_name SET log_statement = 'none'; ALTER DATABASE your_database_name SET log_directory = '/path/donde/sea'; ALTER DATABASE your_database_name SET log_filename = 'postgresql-%Y-%m-%d_%H%M%S.log' ALTER DATABASE your_database_name SET log_line_prefix = '%m [%p] %q%u@%h%d ' ``` ### 7. Fer canvis al repositori de digitaldemocratic Fer coses: ```bash cd /opt/src/digitaldemocratic git remote add beto git@gitlab.com:beto/digitaldemocratic.git git checkout -b hotfix/securize_ddadmin_pwd git commit -am 'add DDADMIN_PASSWORD to securize_conf.sh' git push -u beto ``` Per fer una merge request (MR) i esperar que l'aprobin: ```bash git checkout master git checkout -b production git rebase master git merge hotfix/securize_ddadmin_pwd ``` Quan s'aprobi, si és aprobada: ```bash git fetch origin git checkout master git rebase origin/master git checkout -b production git rebase master git checkout master ``` ### 8. crear servidor de sftp para una carpeta concreta para equipo de wordpress solo toque lo suyo Se pilla un docker que le dices la ruta, donde quieres mapear, usuario, puerto... * user: javier * pwd: jugand0conwordpress * protocolo: sftp * path_folder: /opt/digitaldemocratic/src/wordpress/wp-content/ * usuario como el que va a entrar: 33 (www-data) * carpeta dentro de su home donde se va a mapear la carpeta: home/javier/upload (cuando se conecte verá upload y dentro el contenido de path_folder) docker pull atmoz/sftp cd /opt/digitaldemocratic/src/wordpress/wp-content/ chown -R www-data:www-data ./ firewall-cmd --add-port=3222/tcp docker run -v /opt/digitaldemocratic/src/wordpress/wp-content:/home/javier/upload -p 3222:22 -d atmoz/sftp javier:jugand0conwordpress:33 ----------------------- ## cambiar - borrar lo de customización - que las casillas queden marcadas - automatizar todo

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully