# Cyclos

# Divers

### <span style="white-space:pre-wrap;">Problèmes de démarrage de POSTGRESQL</span>

```
chown -R postgres:postgres /var/lib/postgresql
chown -R postgres:postgres /etc/postgresql
chown -R postgres:postgres /var/log/postgresql
```

### <span style="white-space:pre-wrap;">Problèmes de LOGO</span>

<div class="paragraph-content" id="bkmrk-voir-les-infos-dans-" style="white-space:pre-wrap;">voir les infos dans les logs du postgresql</div>```
select id,content_type,lo_id from stored_files;
ALTER LARGE OBJECT 131963 OWNER to cyclos;
```

### <span style="white-space:pre-wrap;">Corriger les droits POSTGRESQL</span>

<div class="code-block" id="bkmrk--1" style="white-space:normal;"><div class="code-block-header"><div class="view-switch"><div class="action-item action-item--default-popover action-item--tertiary"></div></div></div><div></div></div>```
for tbl in `psql -qAt -c "SELECT proname FROM pg_proc WHERE pronamespace::regnamespace::text = 'public';" cyclos4` ; do  psql -c "alter function \"$tbl\" owner to cyclos" cyclos4 ; done
```

```
for tbl in `psql -qAt -c "select tablename from pg_tables where schemaname = 'public';" cyclos4` ; do  psql -c "alter table \"$tbl\" owner to cyclos" cyclos4 ; done
```

```
for tbl in `psql -qAt -c "select sequence_name from information_schema.sequences where sequence_schema = 'public';" cyclos4` ; do  psql -c "alter sequence \"$tbl\" owner to cyclos" cyclos4 ; done
```

```
for tbl in `psql -qAt -c "select table_name from information_schema.views where table_schema = 'public';" cyclos4` ; do  psql -c "alter view \"$tbl\" owner to cyclos" cyclos4 ; done
```

```
GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA public TO cyclos;
GRANT ALL PRIVILEGES ON database cyclos4 TO cyclos;
GRANT ALL PRIVILEGES ON ALL SEQUENCES IN SCHEMA public TO cyclos;
ALTER DATABASE cyclos4 OWNER to cyclos;
```

### <span style="white-space:pre-wrap;">Pb de réinitialisation de la license cyclos :</span>

```
update application set license_key = null, license_data = null, local_license_data = null;

update password_types set avoid_obvious = false where id = 1;

update configurations set required_address =false;
```

### <span style="white-space:pre-wrap;">Restore la base SQL cyclos :</span>

<div class="paragraph-content" id="bkmrk-copier-le-dump-sql-d" style="white-space:pre-wrap;">Copier le dump sql dans le /tmp</div><div class="paragraph-content" id="bkmrk-" style="white-space:pre-wrap;"></div>```
su - postgres
psql
cyclos4# drop database cyclos4;
cyclos4# create database cyclos4;
cyclos4# exit
psql -d cyclos4 -f /tmp/cyclos4-202101280300.sql
psql -d cyclos4
cyclos4#delete from database_lock;
```

### <span style="white-space:pre-wrap;">Problème de démarrage de Cyclos suite à un arrêt inoppiné :</span>

<div class="code-block" id="bkmrk--7" style="white-space:normal;"><div class="code-block-header"><div class="view-switch"><div class="action-item action-item--default-popover action-item--tertiary"></div></div></div><div></div></div>```
[2021-12-28 17:32:13] [info] ******************************************************************************
[2021-12-28 17:32:13] [info] It seems there is another Cyclos instance connected to this database.
[2021-12-28 17:32:13] [info] If you are sure that is not the case (i.e., the server had crashed),
[2021-12-28 17:32:13] [info] run the following command in the database, then restart Cyclos:
[2021-12-28 17:32:13] [info] delete from database_lock;
[2021-12-28 17:32:13] [info] ******************************************************************************
```

### <span style="white-space:pre-wrap;">Purger la base du bugs des balances :</span>

<div class="code-block" id="bkmrk--8" style="white-space:normal;"><div class="code-block-header"><div class="view-switch"><div class="action-item action-item--default-popover action-item--tertiary"><div class="v-popper v-popper--theme-dropdown">  
</div></div></div></div><div>  
</div></div>```
delete from public.closed_account_balances where date > '2021-09-21' ;
```

### <span style="white-space:pre-wrap;">Changer l'url par défaut :</span>

```
cyclos4=# select id,root_url from configurations;
cyclos4=# update configurations set root_url='https://cyclostest.guigeek.org' where id=1;
UPDATE 1
cyclos4=# update configurations set root_url='https://cyclostest.guigeek.org' where id=2;
UPDATE 1
cyclos4=# update configurations set root_url='https://cyclostest.guigeek.org' where id=5;
UPDATE 1
cyclos4=# update configurations set root_url='https://cyclostest.guigeek.org' where id=6;
UPDATE 1
cyclos4=# update configurations set root_url='https://cyclostest.guigeek.org' where id=7;
```

### <span style="white-space:pre-wrap;">Purge database :</span>

```
delete from accountbalances where accountid in (select id from accounts where user_id in (select id from users where status ='PURGED'));
delete from accounts where user_id in (select id from users where status ='PURGED');
delete from userstatuslogs where user_id in (select id from users where status ='PURGED');
delete from messagestousers where user_id in (select id from users where status ='PURGED');
delete from adhistorylogs;
delete from notifiedadinterests;
delete from ads where owner_id in (select id from users where status ='PURGED');
delete from users where status = 'PURGED';
delete from entitypropertylogs;
delete from entity_logs;
```

### <span style="white-space:pre-wrap;">Changer le mot de passe et le réinitialiser à 1234 :</span>

```
update passwords set value='$2a$10$yM.uw9jC7C1DrRGUhqUc3eSR6FCJH0.HdDt3CJs8YL56iATHcXH7.' where id=1;
```

### <span style="white-space:pre-wrap;">Débloquer un utilisateur :</span>

<div class="code-block" id="bkmrk--11" style="white-space:normal;"><div class="code-block-header"><div class="view-switch"><div class="action-item action-item--default-popover action-item--tertiary"></div></div></div><div></div></div>```
update passwords set blocked_until = NULL where id=1;
```

<div class="paragraph-content" id="bkmrk-configuration" style="white-space:pre-wrap;">Configuration</div><div class="paragraph-content" id="bkmrk-system--%3E-configurat" style="white-space:pre-wrap;">System -&gt; Configurations</div><div class="paragraph-content" id="bkmrk-expression-r%C3%A9guli%C3%A8re" style="white-space:pre-wrap;">Expression régulière pour l'identifiant de connexion</div><div class="paragraph-content" id="bkmrk-%5E%5B%5Cw%5C.%40-_%5D%2A%24" style="white-space:pre-wrap;">^<span class="keep-md">\[</span>\w\.@-_<span class="keep-md">\]</span>*$</div><div class="paragraph-content" id="bkmrk-champs-d%27adresse-obl" style="white-space:pre-wrap;">Champs d'adresse obligatoire -&gt; 0 Groupes possibles pour l'inscription publique</div><div class="paragraph-content" id="bkmrk-cyclostest" style="white-space:pre-wrap;">cyclostest</div><div class="paragraph-content" id="bkmrk-global" style="white-space:pre-wrap;">global</div>```
-> Thèmes

-> Default new frontend theme
```

<div class="paragraph-content" id="bkmrk-florain" style="white-space:pre-wrap;">florain</div><div class="code-block" id="bkmrk--13" style="white-space:normal;"><div class="code-block-header"><div class="view-switch"><div class="action-item action-item--default-popover action-item--tertiary"></div></div></div><div></div></div>```
-> logos
```

<div class="paragraph-content" id="bkmrk-le-vert-%23d7da23" style="white-space:pre-wrap;">le vert #d7da23</div><div class="paragraph-content" id="bkmrk-le-gris-%2370706f" style="white-space:pre-wrap;">le gris #70706f</div><div class="paragraph-content" id="bkmrk-on-peut-ajouter-les-" style="white-space:pre-wrap;">on peut ajouter les couleurs dominantes des billets:</div><div class="paragraph-content" id="bkmrk-%23a9dbf6" style="white-space:pre-wrap;">\#a9dbf6</div><div class="paragraph-content" id="bkmrk-%2354bcb4" style="white-space:pre-wrap;">\#54bcb4</div><div class="paragraph-content" id="bkmrk-%23e46b9d" style="white-space:pre-wrap;">\#e46b9d</div><div class="paragraph-content" id="bkmrk-%23f38e3c" style="white-space:pre-wrap;">\#f38e3c</div><div class="paragraph-content" id="bkmrk-%239bc43e" style="white-space:pre-wrap;">\#9bc43e</div>### <span style="white-space:pre-wrap;">Comment voir la liste des fonctions PGSQL :</span>

```
SELECT proname,
       proowner::regrole
FROM pg_proc
WHERE pronamespace::regnamespace::text = 'public';
```

<div class="paragraph-content" id="bkmrk-functions-pgsql" style="white-space:pre-wrap;">Functions PGSQL</div><div class="code-block" id="bkmrk--15" style="white-space:normal;"><div class="code-block-header"><div class="view-switch"><div class="action-item action-item--default-popover action-item--tertiary"></div></div></div><div></div></div>```
 fn_index_custom_field_value               | cyclos
 fn_create_geography                       | cyclos
 fn_index_ad                               | cyclos
 fn_index_user                             | cyclos
 add_days                                  | cyclos
 add_interval                              | cyclos
 fn_index_address                          | cyclos
 balance_sum                               | cyclos
 get_addresses_tsvector                    | cyclos
 insert_tasks_reindex                      | cyclos
 last_login                                | cyclos
 name_hierarchy                            | cyclos
 order_hierarchy                           | cyclos
 reindex_network                           | cyclos
 strip_html_tags                           | cyclos
 to_geography                              | cyclos
 unix_timestamp                            | cyclos
 reserved_amount_diff                      | cyclos
 account_balance                           | cyclos
 balance_diff                              | cyclos
 current_account_status                    | cyclos
 close_account_balances                    | cyclos
 rebuild_closed_account_balances           | cyclos
 update_account_status                     | cyclos
 account_status_from_closing               | cyclos
 fix_inconsistent_account_balances         | cyclos
```

### <span style="white-space:pre-wrap;">Code SQL pour corriger le owner des functions</span>

```
ALTER FUNCTION fn_index_custom_field_value OWNER TO cyclos;
ALTER FUNCTION fn_create_geography OWNER TO cyclos;
ALTER FUNCTION fn_index_ad OWNER TO cyclos;
ALTER FUNCTION fn_index_user OWNER TO cyclos;
ALTER FUNCTION add_days OWNER TO cyclos;
ALTER FUNCTION add_interval OWNER TO cyclos;
ALTER FUNCTION fn_index_address OWNER TO cyclos;
ALTER FUNCTION balance_sum OWNER TO cyclos;
ALTER FUNCTION get_addresses_tsvector OWNER TO cyclos;
ALTER FUNCTION insert_tasks_reindex OWNER TO cyclos;
ALTER FUNCTION last_login OWNER TO cyclos;
ALTER FUNCTION name_hierarchy OWNER TO cyclos;
ALTER FUNCTION order_hierarchy OWNER TO cyclos;
ALTER FUNCTION reindex_network OWNER TO cyclos;
ALTER FUNCTION strip_html_tags OWNER TO cyclos;
ALTER FUNCTION to_geography OWNER TO cyclos;
ALTER FUNCTION unix_timestamp OWNER TO cyclos;
ALTER FUNCTION reserved_amount_diff OWNER TO cyclos;
ALTER FUNCTION account_balance OWNER TO cyclos;
ALTER FUNCTION balance_diff OWNER TO cyclos;
ALTER FUNCTION current_account_status OWNER TO cyclos;
ALTER FUNCTION close_account_balances OWNER TO cyclos;
ALTER FUNCTION rebuild_closed_account_balances OWNER TO cyclos;
ALTER FUNCTION update_account_status OWNER TO cyclos;
ALTER FUNCTION account_status_from_closing OWNER TO cyclos;
ALTER FUNCTION fix_inconsistent_account_balances OWNER TO cyclos;
ALTER FUNCTION last_account_closing OWNER TO cyclos;
ALTER FUNCTION update_balance OWNER TO cyclos;
ALTER FUNCTION close_balances OWNER TO cyclos;
ALTER FUNCTION last_closed_account_status OWNER TO cyclos;
ALTER FUNCTION account_status_from_cache OWNER TO cyclos;
ALTER FUNCTION insert_missing_balances OWNER TO cyclos;
ALTER FUNCTION inconsistent_closed_accounts OWNER TO cyclos;
ALTER FUNCTION last_closed_account_balances OWNER TO cyclos;
ALTER FUNCTION dirty_account_balances_diffs OWNER TO cyclos;
ALTER FUNCTION cached_account_status OWNER TO cyclos;
ALTER FUNCTION account_status_diffs_since_closing OWNER TO cyclos;
ALTER FUNCTION closed_account_status OWNER TO cyclos;
ALTER FUNCTION insert_missing_account_balances OWNER TO cyclos;
ALTER FUNCTION fix_inconsistent_account_balances OWNER TO cyclos;
ALTER FUNCTION fn_index_translation_message OWNER TO cyclos;
ALTER FUNCTION fn_update_last_balance_closing_date OWNER TO cyclos;
ALTER FUNCTION account_status OWNER TO cyclos;
```

<div class="paragraph-content" id="bkmrk--17" style="white-space:pre-wrap;">  
</div>

# Upgrade cyclos

### 1.1.7. Upgrading Cyclos

<div class="itemizedlist" id="bkmrk-to-upgrade-cyclos-fo">- To upgrade Cyclos follow these steps: <div class="itemizedlist">
    - Before updating always study the release notes and changelog they are published on the Cyclos license server.
    - Make a backup of the database.
    - Download the latest version of Cyclos from the license server.
    - Unzip the cyclos-&lt;version&gt;.zip into a temporary directory.
    - Browse to the temporary directory and rename the directory web to cyclos.
    - Copy your current cyclos.properties file (&lt;tomcat\_home&gt;/webapps/cyclos/WEB-INF/classes/cyclos.properties) to the same place in the temporary directory.
    - Remove the directory cyclos from the tomcat webapps directory (&lt;tomcat\_home&gt;/webapps/cyclos/).
    - Browse to the temporary directory and copy the directory cyclos (including its contents) into the webapps directory (&lt;tomcat\_home&gt;/webapps) of the tomcat installation.
    
    </div>
- We would also recommend to do the following: <div class="itemizedlist">
    - Between major Cyclos versions the Cyclos API can change, please test on a local server (with the database backup) if all scripts and extensions made through the web services still work.
    - In general it is a good practice to test everything before upgrading, if you test with your local database please don't forget to remove the email host and sms gateway so that the users don't receive any notifications.
    - All API changes per version can be found here: http://www.cyclos.org/documentation (see Webservices API Differences and Scripting API Differences).
    - If locally everything works fine a live update can be done as described above.
    - To avoid overwriting the cyclos.properties file without intention this file is named as cyclos-release.properties in the zip file. It might be interesting to study the new file to see if new settings have become available.
    
    </div>

</div>```bash
systemctl stop tomcat9
./backupALLSQL.sh
unzip cyclos-4.16.17.zip
cp /opt/tomcat/webapps/ROOT/WEB-INF/classes/cyclos.properties cyclos-4.16.17/web/WEB-INF/classes/
mkdir ROOT-20251201
mv /opt/tomcat/webapps/ROOT/* ROOT-20251201
mv cyclos-4.16.17/web/* /opt/tomcat/webapps/ROOT/
./fixPerms.sh
```

<div class="itemizedlist" id="bkmrk-"></div>

# Installation sur debian 12 (non compatible avec debian 13 et tomcat10)

#### <span style="white-space:pre-wrap;">Installation des prérequis</span>

```
apt install openjdk-17-jre postgresql postgis
```

Installation de tomcat9 (plus dispo en dépot)

```
 useradd -m -d /opt/tomcat -U -s /bin/false tomcat 
```

```
wget https://dlcdn.apache.org/tomcat/tomcat-10/v10.1.46/bin/apache-tomcat-10.1.46.tar.gz
tar zxvf apache-tomcat-10.1.46.tar.gz -C /opt/tomcat --strip-components=1
chown -R tomcat: /opt/tomcat/{logs,temp,webapps,work}
chown -R :tomcat /opt/tomcat
chmod -R g+r /opt/tomcat/conf
chmod g+x /opt/tomcat/conf
```

#### <span style="white-space:pre-wrap;">Restaure la base SQL cyclos :</span>

<div class="paragraph-content" id="bkmrk-copier-le-dump-sql-d" style="white-space:pre-wrap;">Copier le dump sql dans le /tmp</div>```
su - postgres
psql
cyclos4# drop database cyclos4;
cyclos4# create database cyclos4;
cyclos4# exit
psql -d cyclos4 -f /tmp/cyclos4-202101280300.sql
psql -d cyclos4
cyclos4#delete from database_lock;
```