Browse Source

Initial commit

pull/1/head
fabrice.regnier 1 year ago
commit
2477cdfbe9
  1. 10
      .gitignore
  2. 169
      DETAILS.md
  3. 232
      LICENSE
  4. 90
      README.md
  5. 93
      Vagrantfile.dist
  6. 38
      clean.sh
  7. BIN
      doc/images/allServices.jpg
  8. 48
      files/.emacs
  9. 229
      files/.emacs.d/dockerfile-mode/dockerfile-mode.el
  10. 10
      files/10-monitor.conf
  11. 44
      files/clawsmail/addclawsuser.sh
  12. 106
      files/clawsmail/claws-mail/accountrc
  13. 94
      files/clawsmail/claws-mail/accountrc.tmpl
  14. 410
      files/clawsmail/claws-mail/clawsrc
  15. 6
      files/clawsmail/claws-mail/folderlist.xml
  16. 10
      files/clawsmail/claws-mail/folderlist_skel.xml
  17. 2
      files/clawsmail/claws-mail/passwordstorerc
  18. BIN
      files/clawsmail/genpasswd
  19. 333
      files/clawsmail/genpasswd.c
  20. 78
      files/kaz.sh
  21. 3
      files/kaz/config/container-mail.list
  22. 1
      files/kaz/config/container-orga.list
  23. 1
      files/kaz/config/container-proxy.list
  24. 9
      files/kaz/config/container-withMail.list
  25. 10
      files/kaz/config/container-withoutMail.list
  26. 120
      files/kaz/config/dockers.env
  27. 10
      files/keyboard
  28. 315
      files/provision.sh
  29. 15
      files/test.html
  30. 162
      init.sh
  31. 29
      sparsify.sh

10
.gitignore

@ -0,0 +1,10 @@
.apt-mirror-config
.customDocker.sh
.proxy-config
.vagrant
DEADJOE
Vagrantfile
/files/log
/files/kaz/download
/files/kaz/git
/files/kaz/log

169
DETAILS.md

@ -0,0 +1,169 @@
# kaz-vagrant
[Kaz](https://kaz.bzh/) est un CHATONS du Morbihan. Nous proposons ici un moyen de le répliquer dans d'autres lieux. Il y a des éléments de configuration à définir avant d'initialiser ce simulateur.
Le principe est de faire fonctionner un simulateur de notre CHATONS dans une VirtualBox pour mettre au point nos différents services.
Nous utilisons :
* Vagrant pour automatiser la création de la Machine Virtuelle
* VirtualBox pour simuler notre serveur
* Docker pour chaque service de notre serveur
## Pré-requis
Dans la suite, on imagine que vous disposer d'une machine sous Linux (par exemple dernière version de [Debian](https://fr.wikipedia.org/wiki/Debian))
Vous devez disposer d'un minimum de paquets :
```bash
wget -q https://www.virtualbox.org/download/oracle_vbox_2016.asc -O- | apt-key add -
wget -q https://www.virtualbox.org/download/oracle_vbox.asc -O- | apt-key add -
apt install software-properties-common
add-apt-repository "deb [arch=amd64] http://download.virtualbox.org/virtualbox/debian $(lsb_release -cs) contrib"
apt update
apt install git vagrant virtualbox-6.1 linux-image
vagrant plugin install vagrant-disksize
```
Lancez VirtualBox et vérifiez les mises à jours.
Par la suite, si vous ne disposez pas d'un bon débit, il est conseiller d'installer `approx` et `squid` pour ne pas recharger systématiquement tous les paquets depuis l'internet.
pour `approx`, vous pouvez choisir une partition de stockage `/mnt/big/approx`
```bash
apt-get install approx
netstat -ant | grep 9999
mkdir /mnt/big/approx
chown -R approx : /mnt/big/approx
rmdir /var/cache/approx
ln -s /mnt/big/approx/ /var/cache/
cd /etc/apt/
grep -E "^[^#]" sources.list | cut -d " " -f2 | sort -u >> /etc/approx/approx.conf
```
Pour `squid`, vous pouvez choisir une partition de stockage `/mnt/big/squid`
```bash
apt-get install squid
emacs /etc/squid/squid.conf
mkdir /mnt/big/squid
chown -R proxy: /mnt/big/squid
rmdir /var/spool/squid/
ln -s /mnt/big/squid/ /var/spool/squid/
/etc/init.d/squid restart
```
Si vous utilisez un ordinateur portable, votre adresse IP changera sûrement au grè de vos connexions à l'Internet. Dans ce cas il est préférable d'utiliser une adresse stable pour designer votre mandataire. Après vous êtes connecté, il faudra ajouter une adresse à la carte réseaux qui est active.
Dans l'exemple suivant, nous imaginons que la connexion utilise le wifi `wlo1̀ que nous utilisons une classe privée locale `192.168.128.0/25̀ et que notre machine utilisera la première adresse.
```bash
/sbin/ifconfig
/sbin/ifconfig wlo1:0 192.168.128.1/25
/sbin/ifconfig wlo1:0 up
/sbin/ifconfig
```
## Installation
* Télécharger le dépôt kaz-vagrant ou utilisez la commande :
```bash
git clone https://git.kaz.bzh/KAZ/kaz-vagrant.git # pour essayer
git clone git+ssh://git@git.kaz.bzh:2202/KAZ/kaz-vagrant.git # pour contribuer
cd kaz-vagrant/
```
* Personalisez votre simulateur avec la commande (au besoin ajustez la mémoire et les cpus utilisés dans Vagrantfile) :
```bash
vagrant plugin install vagrant-disksize
init.sh
```
* Personnalisez le miroir des paquets Debian si vous en avez un (sinon ignorez cette étape).
Pour cela créez un fichier qui défini des variables d'environnements qui pointent vers l'hôte et le port (dans l'exemple suivant on prend (machine : **__mirror-host__**, port : **__mirror-port__**) dans un fichier `files/.apt-mirror-config` comme ci-dessous
```
APT_MIRROR_DEBIAN=mirror-host:mirror-port
APT_MIRROR_SECURITY=mirror-host:mirror-port
```
VirtualBox utilise un réseau privé 172.17.X.X
Pour pouvoir désigner dans conflit votre PC comme mirror, vous pouvez déclarer un autre réseau (par exemple 172.19.X.X)
```bash
/sbin/ifconfig (eno2) add 172.19.1.1 netmask 255.255.255.0
```
Dans ce cas, il faut refaire le init.sh pour mettre à jour l'adresse IP du serveur mirroir.
* Pour créer tout l'univers Kaz il faut se placer dans le répertoire et lancer la commande :
```bash
vagrant up
```
Il faudra répondre "docker0" à la question "Which interface should the network bridge to?"
Il est possible d'interrompre la création à la coquille vide (sans les services) pour des question de mise au point avec la commande :
```bash
NOKAZ="true" vagrant up
```
Il se peut que le répertoire `/vagrant` ne soit pas monté. Dans ce cas. Quittez la VM et relancez `vagrant up`.
Il est possible de choisir de tester une autres branche de développement du dépôt de Kaz.
```bash
KAZBRANCH="develop" vagrant up
```
* Une fois la commande de création de l'univers, il faut patienter...
* Après il faut patienter encore un peu si on a pas la fibre ...
La fenêtre de virtualbox va se lancer et l'installation va se poursuivre
La progression est visible dans la fenêtre où la commande vagrant est lancée.
## Utilisation
Les utilisateurs créés sont
* debian/debian
* root/root.
Si vous avec laissé la création des dockers, il faut bien attendre la fermeture automatique de la fenêtre et l'apparition de l'écran de connexion (on vous a dit que c'était long).
Vous pouvez alors démarrer le client de messagerie clawsmail dans lequel 4 comptes ont été paramétrés (contact1@kaz.local, contact2@kaz.local, contact3@kaz.local, contact4@kaz.local)
Il y a un aperçu de l'état des services avec l'url https://kaz.local/status/allServices.html
![status](/doc/images/allServices.jpg)
Les erreurs 502 correspondent à des fonctions en cours de développement. Les message "Can't open this page" correspond au fait que le services refuse pour des raison de sécurité de de fonctionner embarqué dans une page.
Vous pouvez également démarrer firefox avec les URL suivantes:
* https://www.kaz.local
* https://tableur.kaz.local
* https://pad.kaz.local
* https://depot.kaz.local
* https://agora.kaz.local/login (compte contact1@kaz.local créé, mot de passe toto)
* https://cloud.kaz.local/login (compte contact1@kaz.local créé, mot de passe totototototototo1234 )
* https://sondage.kaz.local
Il vous faudra accepter les alertes de sécurité pour certificat absent (web et messagerie)
## Echanges avec la machine virtuelle
En cas de nouvelle re-création, la clef privée sera mise à jour. Il faudra effacer l'ancienne pour ne pas avoir le message :
```
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
```
Pour cela il faut supprimer l'entrée des hôtes connus :
```bash
ssh-keygen -f ~/.ssh/known_hosts -R "[127.0.0.1]:2222"
```
Pour copier des fichiers vers la machine virtuelle :
```bash
rsync -rlptDEHAX --no-o -e "ssh -p 2222 -i ~/git/kaz-vagrant/.vagrant/machines/default/virtualbox/private_key" src vagrant@127.0.0.1:/dst
```

232
LICENSE

@ -0,0 +1,232 @@
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright © 2007 Free Software Foundation, Inc. <http://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed.
Preamble
The GNU General Public License is a free, copyleft license for software and other kinds of works.
The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users. We, the Free Software Foundation, use the GNU General Public License for most of our software; it applies also to any other work released this way by its authors. You can apply it to your programs, too.
When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things.
To protect your rights, we need to prevent others from denying you these rights or asking you to surrender the rights. Therefore, you have certain responsibilities if you distribute copies of the software, or if you modify it: responsibilities to respect the freedom of others.
For example, if you distribute copies of such a program, whether gratis or for a fee, you must pass on to the recipients the same freedoms that you received. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights.
Developers that use the GNU GPL protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License giving you legal permission to copy, distribute and/or modify it.
For the developers' and authors' protection, the GPL clearly explains that there is no warranty for this free software. For both users' and authors' sake, the GPL requires that modified versions be marked as changed, so that their problems will not be attributed erroneously to authors of previous versions.
Some devices are designed to deny users access to install or run modified versions of the software inside them, although the manufacturer can do so. This is fundamentally incompatible with the aim of protecting users' freedom to change the software. The systematic pattern of such abuse occurs in the area of products for individuals to use, which is precisely where it is most unacceptable. Therefore, we have designed this version of the GPL to prohibit the practice for those products. If such problems arise substantially in other domains, we stand ready to extend this provision to those domains in future versions of the GPL, as needed to protect the freedom of users.
Finally, every program is threatened constantly by software patents. States should not allow patents to restrict development and use of software on general-purpose computers, but in those that do, we wish to avoid the special danger that patents applied to a free program could make it effectively proprietary. To prevent this, the GPL assures that patents cannot be used to render the program non-free.
The precise terms and conditions for copying, distribution and modification follow.
TERMS AND CONDITIONS
0. Definitions.
“This License” refers to version 3 of the GNU General Public License.
“Copyright” also means copyright-like laws that apply to other kinds of works, such as semiconductor masks.
“The Program” refers to any copyrightable work licensed under this License. Each licensee is addressed as “you”. “Licensees” and “recipients” may be individuals or organizations.
To “modify” a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a “modified version” of the earlier work or a work “based on” the earlier work.
A “covered work” means either the unmodified Program or a work based on the Program.
To “propagate” a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well.
To “convey” a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays “Appropriate Legal Notices” to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion.
1. Source Code.
The “source code” for a work means the preferred form of the work for making modifications to it. “Object code” means any non-source form of a work.
A “Standard Interface” means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language.
The “System Libraries” of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A “Major Component”, in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it.
The “Corresponding Source” for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those subprograms and other parts of the work.
The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source.
The Corresponding Source for a work in source code form is that same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures.
When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified it, and giving a relevant date.
b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to “keep intact all notices”.
c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so.
A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an “aggregate” if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways:
a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b.
d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d.
A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work.
A “User Product” is either (1) a “consumer product”, which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, “normally used” refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product.
“Installation Information” for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made.
If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM).
The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying.
7. Additional Terms.
“Additional permissions” are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or authors of the material; or
e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors.
All other non-permissive additional terms are considered “further restrictions” within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11).
However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice.
Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License.
An “entity transaction” is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it.
11. Patents.
A “contributor” is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's “contributor version”.
A contributor's “essential patent claims” are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, “control” includes the right to grant patent sublicenses in a manner consistent with the requirements of this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version.
In the following three paragraphs, a “patent license” is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To “grant” such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party.
If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent license to downstream recipients. “Knowingly relying” means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it.
A patent license is “discriminatory” if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program.
13. Use with the GNU Affero General Public License.
Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU Affero General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the special requirements of the GNU Affero General Public License, section 13, concerning interaction through a network will apply to the combination as such.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of the GNU General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the Program specifies that a certain numbered version of the GNU General Public License “or any later version” applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU General Public License, you may choose any version ever published by the Free Software Foundation.
If the Program specifies that a proxy can decide which future versions of the GNU General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program.
Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the “copyright” line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode:
<program> Copyright (C) <year> <name of author>
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, your program's commands might be different; for a GUI interface, you would use an “about box”.
You should also get your employer (if you work as a programmer) or school, if any, to sign a “copyright disclaimer” for the program, if necessary. For more information on this, and how to apply and follow the GNU GPL, see <http://www.gnu.org/licenses/>.
The GNU General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. But first, please read <http://www.gnu.org/philosophy/why-not-lgpl.html>.

90
README.md

@ -0,0 +1,90 @@
# kaz-vagrant
[Kaz](https://kaz.bzh/) est un CHATONS du Morbihan. Nous proposons ici un moyen de le répliquer dans une VM. Il y a des éléments de configuration à définir avant d'initialiser ce simulateur.
Le principe est de faire fonctionner un simulateur de notre CHATONS dans une VirtualBox pour mettre au point nos différents services.
Nous utilisons :
* Vagrant pour automatiser la création de la Machine Virtuelle
* VirtualBox pour simuler notre serveur
* Docker pour chaque service de notre serveur
## Pré-requis
Vous avez besoin de [vagrant](https://www.vagrantup.com/), [VirtualBox](https://www.virtualbox.org/) et éventuellement git.
## Installation
* Télécharger le dépôt kaz-vagrant ou utilisez la commande git :
```bash
git clone https://git.kaz.bzh/KAZ/kaz-vagrant.git # pour essayer
git clone git+ssh://git@git.kaz.bzh:2202/KAZ/kaz-vagrant.git # pour contribuer
cd kaz-vagrant/
```
* Personalisez votre simulateur avec la commande (au besoin ajustez la mémoire et les cpus utilisés dans Vagrantfile) :
```bash
vagrant plugin install vagrant-disksize
./init.sh # vous pouvez laisser les choix par défaut
```
* Pour créer tout l'univers Kaz il faut se placer dans le répertoire et lancer la commande :
```bash
vagrant up
```
Cette étape peut-être (très) longue. Il faudra éventuellement répondre "docker0" à la question "Which interface should the network bridge to?"
## Mise au point
Il est possible d'interrompre la création à la coquille vide (juste la VM sans les services KAZ) pour des question de mise au point avec la commande :
```bash
NOKAZ="true" vagrant up
```
Dans ce cas, il faudra ensuite lancer dans la VM :
```bash
/kaz/bin/install.sh
```
Pour détruire la VM et recommencer :
```bash
vagrant destroy
```
## Utilisation
Les utilisateurs créés sont
* debian/debian
* root/root.
Si vous avec laissé la création des dockers, il faut bien attendre la fermeture automatique de la fenêtre et l'apparition de l'écran de connexion (on vous a dit que c'était long).
Lors du démarrage de la VM, il faut lancer les conteneurs dans la VM :
```bash
/kaz/bin/container.sh start
```
Vous pouvez alors démarrer le client de messagerie clawsmail dans lequel 4 comptes ont été paramétrés (contact1@kaz.local, contact2@kaz.local, contact3@kaz.local, contact4@kaz.local)
Il y a un aperçu de l'état des services avec l'url https://kaz.local/status/allServices.html
![status](/doc/images/allServices.jpg)
Les erreurs 502 correspondent à des fonctions en cours de développement. Les message "Can't open this page" correspond au fait que le services refuse pour des raison de sécurité de de fonctionner embarqué dans une page.
Vous pouvez également démarrer firefox avec les URL suivantes:
* https://www.kaz.local
* https://tableur.kaz.local
* https://pad.kaz.local
* https://depot.kaz.local
* https://agora.kaz.local/login (compte contact1@kaz.local créé, mot de passe toto)
* https://cloud.kaz.local/login (compte contact1@kaz.local créé, mot de passe totototototototo1234 )
* https://sondage.kaz.local
Il vous faudra accepter les alertes de sécurité pour certificat absent (web et messagerie)
## Installation avancée
L'installation avancée, notamment pour utiliser d'autres miroirs ou des caches APT, est décrite dans le fichier [DETAILS.md](DETAILS.md).

93
Vagrantfile.dist

@ -0,0 +1,93 @@
# coding: utf-8
# -*- mode: ruby -*-
# vi: set ft=ruby :
unless Vagrant.has_plugin?("vagrant-disksize")
raise Vagrant::Errors::VagrantError.new, "vagrant-disksize plugin is missing. Please install it using 'vagrant plugin install vagrant-disksize' and rerun 'vagrant up'"
end
# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.
Vagrant.configure("2") do |config|
required_plugins = %w( vagrant-vbguest vagrant-disksize )
_retry = false
required_plugins.each do |plugin|
unless Vagrant.has_plugin? plugin
system "vagrant plugin install #{plugin}"
_retry=true
end
end
if (_retry)
exec "vagrant " + ARGV.join(' ')
end
config.vm.box = "debian/bullseye64"
config.disksize.size = '32GB'
# Disable automatic box update checking. If you disable this, then
# boxes will only be checked for updates when the user runs
# `vagrant box outdated`. This is not recommended.
# config.vm.box_check_update = false
# Create a forwarded port mapping which allows access to a specific port
# within the machine from a port on the host machine. In the example below,
# accessing "localhost:8080" will access port 80 on the guest machine.
# config.vm.network "forwarded_port", guest: 80, host: 8080
# Create a private network, which allows host-only access to the machine
# using a specific IP.
# config.vm.network "private_network", ip: "192.168.33.10"
# Create a public network, which generally matched to bridged network.
# Bridged networks make the machine appear as another physical device on
# your network.
# config.vm.network "public_network"
# Share an additional folder to the guest VM. The first argument is
# the path on the host to the actual folder. The second argument is
# the path on the guest to mount the folder. And the optional third
# argument is a set of non-required options.
# config.vm.synced_folder "data", "/vagrant_data"
# config.vm.synced_folder "..", "/root/mi-lxc", create:true, type:"rsync",
# rsync__exclude: [".git/", "zzlocal/", "vagrant/"]
# Provider-specific configuration so you can fine-tune various
# backing providers for Vagrant. These expose provider-specific options.
# Example for VirtualBox:
#
config.vm.provider "virtualbox" do |vb|
# # Display the VirtualBox GUI when booting the machine
# vb.gui = true
#
# # Customize the amount of memory on the VM:
vb.memory = "4096"
vb.cpus="2"
vb.name = "kaz-dev-amd64"
vb.customize ["modifyvm", :id, "--vram", "64", "--clipboard-mode", "bidirectional", '--graphicscontroller', 'vmsvga', '--natnet1', '192.168.64.0/24']
vb.gui = true
end
# Define a Vagrant Push strategy for pushing to Atlas. Other push strategies
# such as FTP and Heroku are also available. See the documentation at
# https://docs.vagrantup.com/v2/push/atlas.html for more information.
# config.push.define "atlas" do |push|
# push.app = "YOUR_ATLAS_USERNAME/YOUR_APPLICATION_NAME"
# end
# Enable provisioning with a shell script. Additional provisioners such as
# Puppet, Chef, Ansible, Salt, and Docker are also available. Please see the
# documentation for more information about their specific syntax and use.
#permet d'avoir un répertoire partagé entre la VM et le host
config.vm.synced_folder "/tmp/", "/tmp_host"
config.vm.provision "shell" do |s|
s.inline = "/vagrant/files/provision.sh"
s.env = {"KAZGUARD" => "true", "HOSTLANG" => ENV['LANG'], "NOKAZ" => ENV['NOKAZ'], "KAZBRANCH" => ENV['KAZBRANCH']}
end
end

38
clean.sh

@ -0,0 +1,38 @@
#!/bin/bash
cd "$(dirname $0)"
while : ; do
read -p "Remove vagrant generated files (y/n)? " yn
case "${yn}" in
[yY]*|[Oo]* )
rm -f Vagrantfile
break;;
""|[Nn]* ) break;;
* ) echo "Please answer y/n.";;
esac
done
while : ; do
read -p "Remove proxy generated files (y/n)? " yn
case "${yn}" in
[yY]*|[Oo]* )
rm -f files/kaz/.apt-mirror-config files/kaz/.proxy-config
rm -f files/.apt-mirror-config files/.proxy-config files/.docker-config.json
break;;
""|[Nn]* ) break;;
* ) echo "Please answer y/n.";;
esac
done
while : ; do
read -p "Remove custom generated files (y/n)? " yn
case "${yn}" in
[yY]*|[Oo]* )
rm -f files/.customDocker.sh
rm -f files/kaz/.customDocker.sh files/local.sh
break;;
""|[Nn]* ) break;;
* ) echo "Please answer y/n.";;
esac
done

BIN
doc/images/allServices.jpg

Binary file not shown.

After

Width:  |  Height:  |  Size: 85 KiB

48
files/.emacs

@ -0,0 +1,48 @@
(custom-set-variables
;; custom-set-variables was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(ansi-color-faces-vector
[default default default italic underline success warning error])
'(ansi-color-names-vector
["black" "red3" "ForestGreen" "yellow3" "blue" "magenta3" "DeepSkyBlue" "gray50"])
'(custom-enabled-themes '(Monokai))
'(inverse-video t)
)
(custom-set-faces
;; custom-set-faces was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
)
(require 'ansi-color)
(defun ansi-color-region ()
"Color the ANSI escape sequences in the acitve region.
Sequences start with an escape \033 (typically shown as \"^[\")
and end with \"m\", e.g. this is two sequences
^[[46;1mTEXT^[[0m
where the first sequence says to diplay TEXT as bold with
a cyan background and the second sequence turns it off.
This strips the ANSI escape sequences and if the buffer is saved,
the sequences will be lost."
(interactive)
(if (not (region-active-p))
(message "ansi-color-region: region is not active"))
(if buffer-read-only
;; read-only buffers may be pointing a read-only file system, so don't mark the buffer as
;; modified. If the buffer where to become modified, a warning will be generated when emacs
;; tries to autosave.
(let ((inhibit-read-only t)
(modified (buffer-modified-p)))
(ansi-color-apply-on-region (region-beginning) (region-end))
(set-buffer-modified-p modified))
(ansi-color-apply-on-region (region-beginning) (region-end))))
(add-to-list 'load-path "~/.emacs.d/dockerfile-mode/")
(require 'dockerfile-mode)
;;(add-to-list 'auto-mode-alist '("Dockerfile\\'" . dockerfile-mode))
(setq auto-mode-alist (cons '("Dockerfile\\'" . dockerfile-mode) auto-mode-alist))

229
files/.emacs.d/dockerfile-mode/dockerfile-mode.el

@ -0,0 +1,229 @@
;;; dockerfile-mode.el --- Major mode for editing Docker's Dockerfiles -*- lexical-binding: t -*-
;; Copyright (c) 2013 Spotify AB
;; Package-Requires: ((emacs "24") (s "1.12"))
;; Homepage: https://github.com/spotify/dockerfile-mode
;;
;; Licensed under the Apache License, Version 2.0 (the "License"); you may not
;; use this file except in compliance with the License. You may obtain a copy of
;; the License at
;;
;; http://www.apache.org/licenses/LICENSE-2.0
;;
;; Unless required by applicable law or agreed to in writing, software
;; distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
;; WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
;; License for the specific language governing permissions and limitations under
;; the License.
;;; Commentary:
;; Provides a major mode `dockerfile-mode' for use with the standard
;; `Dockerfile' file format. Additional convenience functions allow
;; images to be built easily.
;;; Code:
(require 'sh-script)
(require 'rx)
(require 's)
(declare-function cygwin-convert-file-name-to-windows "cygw32.c" (file &optional absolute-p))
(defgroup dockerfile nil
"dockerfile code editing commands for Emacs."
:link '(custom-group-link :tag "Font Lock Faces group" font-lock-faces)
:prefix "dockerfile-"
:group 'languages)
(defcustom dockerfile-mode-hook nil
"*Hook called by `dockerfile-mode'."
:type 'hook
:group 'dockerfile)
(defcustom dockerfile-mode-command "docker"
"Which binary to use to build images"
:group 'dockerfile
:type 'string)
(defcustom dockerfile-use-sudo nil
"Runs docker builder command with sudo."
:type 'boolean
:group 'dockerfile)
(defcustom dockerfile-build-args nil
"List of --build-arg to pass to docker build.
Each element of the list will be passed as a separate
--build-arg to the docker build command."
:type '(repeat string)
:group 'dockerfile)
(defface dockerfile-image-name
'((t (:inherit (font-lock-type-face bold))))
"Face to highlight the base image name after FROM instruction.")
(defface dockerfile-image-alias
'((t (:inherit (font-lock-constant-face bold))))
"Face to highlight the base image alias inf FROM ... AS <alias> construct.")
(defconst dockerfile--from-regex
(rx "from " (group (+? nonl)) (or " " eol) (? "as " (group (1+ nonl)))))
(defvar dockerfile-font-lock-keywords
`(,(cons (rx (or line-start "onbuild ")
(group (or "from" "maintainer" "run" "cmd" "expose" "env" "arg"
"add" "copy" "entrypoint" "volume" "user" "workdir" "onbuild"
"label" "stopsignal" "shell" "healthcheck"))
word-boundary)
font-lock-keyword-face)
(,dockerfile--from-regex
(1 'dockerfile-image-name)
(2 'dockerfile-image-alias nil t))
,@(sh-font-lock-keywords)
,@(sh-font-lock-keywords-2)
,@(sh-font-lock-keywords-1))
"Default `font-lock-keywords' for `dockerfile mode'.")
(defvar dockerfile-mode-map
(let ((map (make-sparse-keymap))
(menu-map (make-sparse-keymap)))
(define-key map "\C-c\C-b" #'dockerfile-build-buffer)
(define-key map "\C-c\M-b" #'dockerfile-build-no-cache-buffer)
(define-key map "\C-c\C-c" #'comment-region)
(define-key map [menu-bar dockerfile-mode] (cons "Dockerfile" menu-map))
(define-key menu-map [dfc]
'(menu-item "Comment Region" comment-region
:help "Comment Region"))
(define-key menu-map [dfb]
'(menu-item "Build" dockerfile-build-buffer
:help "Send the Dockerfile to docker build"))
(define-key menu-map [dfb]
'(menu-item "Build without cache" dockerfile-build-no-cache-buffer
:help "Send the Dockerfile to docker build without cache"))
map))
(defvar dockerfile-mode-syntax-table
(let ((table (make-syntax-table)))
(modify-syntax-entry ?# "<" table)
(modify-syntax-entry ?\n ">" table)
(modify-syntax-entry ?' "\"" table)
(modify-syntax-entry ?= "." table)
table)
"Syntax table for `dockerfile-mode'.")
(define-abbrev-table 'dockerfile-mode-abbrev-table nil
"Abbrev table used while in `dockerfile-mode'.")
(unless dockerfile-mode-abbrev-table
(define-abbrev-table 'dockerfile-mode-abbrev-table ()))
(defun dockerfile-indent-line-function ()
"Indent lines in a Dockerfile.
Lines beginning with a keyword are ignored, and any others are
indented by one `tab-width'."
(unless (member (get-text-property (point-at-bol) 'face)
'(font-lock-comment-delimiter-face font-lock-keyword-face))
(save-excursion
(beginning-of-line)
(skip-chars-forward "[ \t]" (point-at-eol))
(unless (equal (point) (point-at-eol)) ; Ignore empty lines.
;; Delete existing whitespace.
(delete-char (- (point-at-bol) (point)))
(indent-to tab-width)))))
(defun dockerfile-build-arg-string ()
"Create a --build-arg string for each element in `dockerfile-build-args'."
(mapconcat (lambda (arg) (concat "--build-arg " (shell-quote-argument arg)))
dockerfile-build-args " "))
(defun dockerfile-standard-filename (file)
"Convert the FILE name to OS standard.
If in Cygwin environment, uses Cygwin specific function to convert the
file name. Otherwise, uses Emacs' standard conversion function."
(if (fboundp 'cygwin-convert-file-name-to-windows)
(s-replace "\\" "\\\\" (cygwin-convert-file-name-to-windows file))
(convert-standard-filename file)))
(defun dockerfile-tag-string (image-name)
"Return a --tag shell-quoted IMAGE-NAME string or an empty string if image-name is blank."
(if (string= image-name "") "" (format "--tag %s " (shell-quote-argument image-name))))
(defvar dockerfile-image-name nil
"Name of the dockerfile currently being used.
This can be set in file or directory-local variables.")
(define-obsolete-variable-alias 'docker-image-name 'dockerfile-image-name)
(defvar dockerfile-image-name-history nil
"History of image names read by `dockerfile-read-image-name'.")
(defun dockerfile-read-image-name ()
"Read a docker image name."
(read-string "Image name: " dockerfile-image-name 'dockerfile-image-name-history))
;;;###autoload
(defun dockerfile-build-buffer (image-name &optional no-cache)
"Build an image called IMAGE-NAME based upon the buffer.
If prefix arg NO-CACHE is set, don't cache the image.
The build string will be of the format:
`sudo docker build --no-cache --tag IMAGE-NAME --build-args arg1.. -f filename directory`"
(interactive (list (dockerfile-read-image-name) prefix-arg))
(save-buffer)
(compilation-start
(format
"%s%s build %s %s %s -f %s %s"
(if dockerfile-use-sudo "sudo " "")
dockerfile-mode-command
(if no-cache "--no-cache" "")
(dockerfile-tag-string image-name)
(dockerfile-build-arg-string)
(shell-quote-argument (dockerfile-standard-filename (buffer-file-name)))
(shell-quote-argument (dockerfile-standard-filename default-directory)))
nil
(lambda (_) (format "*docker-build-output: %s *" image-name))))
;;;###autoload
(defun dockerfile-build-no-cache-buffer (image-name)
"Build an image called IMAGE-NAME based upon the buffer without cache."
(interactive (list (dockerfile-read-image-name)))
(dockerfile-build-buffer image-name t))
(defun dockerfile--imenu-function ()
"Find the previous headline from point.
Search for a FROM instruction. If an alias is used this is
returned, otherwise the base image name is used."
(when (re-search-backward dockerfile--from-regex nil t)
(let ((data (match-data)))
(when (match-string 2)
;; we drop the first match group because
;; imenu-generic-expression can only use one offset, so we
;; normalize to `1'.
(set-match-data (list (nth 0 data) (nth 1 data) (nth 4 data) (nth 5 data))))
t)))
;;;###autoload
(define-derived-mode dockerfile-mode prog-mode "Dockerfile"
"A major mode to edit Dockerfiles.
\\{dockerfile-mode-map}
"
(set-syntax-table dockerfile-mode-syntax-table)
(set (make-local-variable 'imenu-generic-expression)
`(("Stage" dockerfile--imenu-function 1)))
(set (make-local-variable 'require-final-newline) mode-require-final-newline)
(set (make-local-variable 'comment-start) "#")
(set (make-local-variable 'comment-end) "")
(set (make-local-variable 'comment-start-skip) "#+ *")
(set (make-local-variable 'parse-sexp-ignore-comments) t)
(set (make-local-variable 'font-lock-defaults)
'(dockerfile-font-lock-keywords nil t))
(setq local-abbrev-table dockerfile-mode-abbrev-table)
(set (make-local-variable 'indent-line-function) #'dockerfile-indent-line-function))
;;;###autoload
(add-to-list 'auto-mode-alist '("Dockerfile\\(?:\\..*\\)?\\'" . dockerfile-mode))
(provide 'dockerfile-mode)
;;; dockerfile-mode.el ends here

10
files/10-monitor.conf

@ -0,0 +1,10 @@
Section "ServerFlags"
Option "StandbyTime" "0"
Option "SuspendTime" "0"
Option "OffTime" "0"
Option "BlankTime" "0"
EndSection
Section "Extensions"
Option "DPMS" "Disable"
EndSection

44
files/clawsmail/addclawsuser.sh

@ -0,0 +1,44 @@
#!/bin/bash
# Configure claws mail
set -e
#if [ -z $KAZGUARD ] ; then exit 1; fi
DIR=`dirname $0`
cd `dirname $0`
# $domain, $mailname, $password
name=$1
domainname=$2
password=$3
number=$4
# cp -ar claws-mail ~/.claws-mail
mkdir -p ~/.claws-mail
cat claws-mail/accountrc > /tmp/accountrc
sed -i -e "s/\$name/$name/" /tmp/accountrc
sed -i -e "s/\$domainname/$domainname/" /tmp/accountrc
sed -i -e "s/\$number/$number/" /tmp/accountrc
cat /tmp/accountrc >> ~/.claws-mail/accountrc
if [ ! -f ~/.claws-mail/folderlist.xml ]; then
cp claws-mail/folderlist_skel.xml ~/.claws-mail/folderlist.xml
fi
cat claws-mail/folderlist.xml > /tmp/folderlist.xml
sed -i -e "s/\$name/$name/" /tmp/folderlist.xml
sed -i -e "s/\$domainname/kaz\.bzh/" /tmp/folderlist.xml
sed -i -e "s/\$number/$number/" /tmp/folderlist.xml
sed -i -e "s/<\/folderlist>//" ~/.claws-mail/folderlist.xml
cat /tmp/folderlist.xml >> ~/.claws-mail/folderlist.xml
echo "</folderlist>" >> ~/.claws-mail/folderlist.xml
cp claws-mail/clawsrc ~/.claws-mail/
# chmod +x genpasswd
pass=`./genpasswd $password`
#gcc genpasswd.c -o genpasswd -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/lib/x86_64-linux-gnu/glib-2.0/include/ -lglib-2.0 -lgnutls
echo -e "[account:$number]\nrecv $pass" >> ~/.claws-mail/passwordstorerc

106
files/clawsmail/claws-mail/accountrc

@ -0,0 +1,106 @@
[Account: $number]
domain=kaz.local
name=$name@$domainname
account_name=IMAP
is_default=1
address=$name@$domainname
organization=
protocol=1
receive_server=mail.$domainname
recvtype=3
smtp_server=smtp.$domainname
nntp_server=
local_mbox=/var/mail
use_mail_command=0
mail_command=/usr/sbin/sendmail -t -i
use_nntp_auth=0
use_nntp_auth_onconnect=0
user_id=$name@$domainname
use_apop_auth=0
remove_mail=1
message_leave_time=7
message_leave_hour=0
enable_size_limit=0
size_limit=1024
filter_on_receive=1
filterhook_on_receive=1
imap_auth_method=0
receive_at_get_all=1
max_news_articles=300
inbox=#mh/Mailbox/inbox
local_inbox=#mh/Mailbox/inbox
imap_directory=
imap_subsonly=1
low_bandwidth=0
generate_msgid=1
generate_xmailer=1
add_custom_header=0
msgid_with_addr=0
use_smtp_auth=0
smtp_auth_method=0
smtp_user_id=
pop_before_smtp=0
pop_before_smtp_timeout=5
signature_type=0
signature_path=/home/debian/.signature
auto_signature=1
signature_separator=--
set_autocc=0
auto_cc=
set_autobcc=0
auto_bcc=
set_autoreplyto=0
auto_replyto=
enable_default_dictionary=0
default_dictionary=
enable_default_alt_dictionary=0
default_alt_dictionary=
compose_with_format=0
compose_subject_format=
compose_body_format=
reply_with_format=0
reply_quotemark=
reply_body_format=
forward_with_format=0
forward_quotemark=
forward_body_format=
default_privacy_system=
default_encrypt=0
default_encrypt_reply=1
default_sign=0
default_sign_reply=1
save_clear_text=0
encrypt_to_self=0
privacy_prefs=
ssl_pop=0
ssl_imap=0
ssl_nntp=0
ssl_smtp=0
ssl_certs_auto_accept=0
use_nonblocking_ssl=1
in_ssl_client_cert_file=
out_ssl_client_cert_file=
set_smtpport=0
smtp_port=25
set_popport=0
pop_port=110
set_imapport=0
imap_port=143
set_nntpport=0
nntp_port=119
set_domain=0
domain=
gnutls_set_priority=0
gnutls_priority=
set_tunnelcmd=0
tunnelcmd=
mark_crosspost_read=0
crosspost_color=0
set_sent_folder=0
sent_folder=
set_queue_folder=0
queue_folder=
set_draft_folder=0
draft_folder=
set_trash_folder=0
trash_folder=

94
files/clawsmail/claws-mail/accountrc.tmpl

@ -0,0 +1,94 @@
[AccountTemplate]
#you can use $DEFAULTDOMAIN here
#domain must be defined before the variables that use it
#by default, domain is extracted from the hostname
#domain=
#you can use $USERNAME for name (this is the default)
#name=
#you can use $LOGIN, $NAME_MAIL and $DOMAIN here
#$NAME_MAIL is the name without uppercase and with dots instead
#of spaces
#the default is $NAME_MAIL@$DOMAIN
#email=
#you can use $DOMAIN here
#the default organization is empty
#organization=
#you can use $DOMAIN here
#the default is smtp.$DOMAIN
#smtpserver=
#Whether to use smtp authentication
#the default is 0 (no)
#smtpauth=
#SMTP username
#you can use $LOGIN, $NAME_MAIL, $DOMAIN or $EMAIL here
#the default is empty (same as reception username)
#smtpuser=
#SMTP password
#the default is empty (same as reception password)
#smtppass=
#recvtype can be:
#0 for pop3
#3 for imap
#5 for a local mbox file
#recvtype=
#you can use $DOMAIN here
#the default is {pop,imap}.$DOMAIN
#recvserver=
#you can use $LOGIN, $NAME_MAIL, $DOMAIN or $EMAIL here
#default is $LOGIN
#recvuser=
#default is empty
#recvpass=
#imap dir if imap (relative to the home on the server)
#default is empty
#imapdir=
#show subscribed folders only, if imap
#default is TRUE
#subsonly=
#mbox file if local
#you can use $LOGIN here
#default is /var/mail/$LOGIN
#mboxfile=
#mailbox name if pop3 or local
#relative path from the user's home
#default is "Mail"
#mailbox=
#whether to use encryption on SMTP connections
#default is 0, 1 is SSL/TLS, 2 is STARTTLS
#smtpssl=
#whether to use encryption on POP3 or IMAP connections
#default is 0, 1 is SSL/TLS, 2 is STARTTLS
#recvssl=
#SSL/TLS client certificate path for SMTP
#default is empty (no certificate)
#smtpssl_cert=
#SSL/TLS client certificate path for POP/IMAP
#default is empty (no certificate)
#recvssl_cert=
#SSL/TLS client certificate password for SMTP
#default is empty (no password)
#smtpssl_cert_pass=
#SSL/TLS client certificate password for POP/IMAP
#default is empty (no password)
#recvssl_cert_pass=

410
files/clawsmail/claws-mail/clawsrc

@ -0,0 +1,410 @@
[Common]
config_version=2
use_ext_inc=0
ext_inc_path=/usr/bin/mh/inc
autochk_newmail=0
autochk_interval=600
check_on_startup=0
open_inbox_on_inc=0
scan_all_after_inc=0
newmail_notify_manu=0
newmail_notify_auto=0
newmail_notify_cmd=
receive_dialog_mode=2
receivewin_width=460
receivewin_height=-1
no_receive_error_panel=0
close_receive_dialog=1
save_message=1
confirm_send_queued_messages=0
send_dialog_mode=0
sendwin_width=460
sendwin_height=-1
outgoing_charset=AUTO
encoding_method=0
outgoing_fallback_to_ascii=1
rewrite_first_from=1
warn_empty_subj=1
hide_timezone=0
allow_jisx0201_kana=0
auto_ext_editor=0
forward_as_attachment=0
redirect_keep_from=0
undo_level=50
compose_with_format=0
compose_subject_format=
compose_body_format=Hello,\n
show_compose_margin=0
type_any_header=0
linewrap_length=72
linewrap_quotation=1
linewrap_pastes=1
primary_paste_unselects=0
linewrap_auto=1
auto_indent=1
autosave=1
autosave_length=50
autosave_encrypted=0
warn_large_insert=1
warn_large_insert_size=500
enable_aspell=0
dictionary=fr_FR
alt_dictionary=
use_alternate_dict=0
check_while_typing=1
recheck_when_changing_dict=1
misspelled_color=#ff0000
use_both_dicts=0
reply_with_quote=1
compose_dnd_insert_or_attach=0
reply_account_autoselect=1
forward_account_autoselect=1
reedit_account_autoselect=1
default_reply_list=1
show_ruler=1
reply_quote_mark=>
reply_quote_format=On %d\n%f wrote:\n\n%q\n%X
forward_quote_mark=>
forward_quote_format=\n\nBegin forwarded message:\n\n?d{Date: %d\n}?f{From: %f\n}?t{To: %t\n}?c{Cc: %c\n}?n{Newsgroups: %n\n}?s{Subject: %s\n}\n\n%M
quote_chars=>
widget_font=
message_font=-misc-fixed-medium-r-normal--14-*-*-*-*-*-*-*
small_font=-*-helvetica-medium-r-normal--10-*-*-*-*-*-*-*
bold_font=-*-helvetica-bold-r-normal--12-*-*-*-*-*-*-*
normal_font=-*-helvetica-medium-r-normal--12-*-*-*-*-*-*-*
widget_font_gtk2=
message_font_gtk2=Monospace 10
print_font_gtk2=Monospace 9
small_font_gtk2=Sans 10
normal_font_gtk2=Sans 10
bold_font_gtk2=Sans Bold 10
use_different_print_font=0
derive_from_normal_font=1
custom_color1=#ff9900
custom_colorlabel1=Orange
custom_color2=#ff0000
custom_colorlabel2=Red
custom_color3=#ff66ff
custom_colorlabel3=Pink
custom_color4=#00ccff
custom_colorlabel4=Sky blue
custom_color5=#0000ff
custom_colorlabel5=Blue
custom_color6=#009900
custom_colorlabel6=Green
custom_color7=#663333
custom_colorlabel7=Brown
custom_color8=#aaaaaa
custom_colorlabel8=Grey
custom_color9=#c07254
custom_colorlabel9=Light brown
custom_color10=#c00000
custom_colorlabel10=Dark red
custom_color11=#cc1074
custom_colorlabel11=Dark pink
custom_color12=#5094cd
custom_colorlabel12=Steel blue
custom_color13=#ffd500
custom_colorlabel13=Gold
custom_color14=#00d800
custom_colorlabel14=Bright green
custom_color15=#c060c0
custom_colorlabel15=Magenta
display_image=1
resize_image=1
inline_image=1
display_folder_unread_num=0
newsgroup_abbrev_len=16
translate_header=0
default_sort_key=3
default_sort_type=1
use_address_book=0
thread_by_subject=1
date_format=%a %x %H:%M
msgview_date_format=0
next_on_delete=0
bold_unread=1
enable_thread=1
toolbar_style=3
toolbar_detachable=0
show_col_headers=1
show_statusbar=1
show_searchbar=1
summary_col_show_mark=1
summary_col_show_unread=1
summary_col_show_subject=1
summary_col_show_from=1
summary_col_show_to=0
summary_col_show_date=1
summary_col_show_mime=1
summary_col_show_size=1
summary_col_show_number=0
summary_col_show_score=0
summary_col_show_locked=0
summary_col_show_tags=0
summary_col_pos_mark=0
summary_col_pos_unread=1
summary_col_pos_mime=2
summary_col_pos_subject=3
summary_col_pos_from=4
summary_col_pos_date=5
summary_col_pos_size=6
summary_col_pos_number=7
summary_col_pos_score=8
summary_col_pos_locked=9
summary_col_pos_to=10
summary_col_pos_tags=11
summary_col_size_mark=10
summary_col_size_unread=13
summary_col_size_mime=10
summary_col_size_subject=200
summary_col_size_from=120
summary_col_size_to=120
summary_col_size_date=118
summary_col_size_size=45
summary_col_size_number=40
summary_col_size_score=40
summary_col_size_locked=13
summary_col_size_tags=150
folderwin_x=16
folderwin_y=16
folderview_width=270
folderview_height=493
folderview_visible=1
folder_col_show_folder=1
folder_col_show_new=1
folder_col_show_unread=1
folder_col_show_total=1
folder_col_pos_folder=0
folder_col_pos_new=1
folder_col_pos_unread=2
folder_col_pos_total=3
folder_col_size_folder=120
folder_col_size_new=32
folder_col_size_unread=32
folder_col_size_total=32
summaryview_width=523
summaryview_height=262
main_messagewin_x=256
main_messagewin_y=210
messageview_width=523
messageview_height=228
messageview_visible=1
mainview_x=350
mainview_y=58
mainview_width=523
mainview_height=600
mainwin_x=350
mainwin_y=58
mainwin_maximised=0
mainwin_fullscreen=0
mainwin_menubar=1
mainwin_width=800
mainwin_height=600
messagewin_width=600
messagewin_height=540
mimeview_tree_height=60
sourcewin_width=600
sourcewin_height=500
compose_width=600
compose_height=560
compose_notebook_height=130
compose_x=0
compose_y=0
enable_color=1
quote_level1_color=#0000b3
quote_level2_color=#0000b3
quote_level3_color=#0000b3
enable_bgcolor=0
quote_level1_bgcolor=#cccccc
quote_level2_bgcolor=#d4d4d4
quote_level3_bgcolor=#dddddd
uri_color=#007f00
emphasis_color=#0000cf
target_folder_color=#da1cca
signature_color=#797979
recycle_quote_colors=0
display_header_pane=0
display_header=1
display_xface=1
render_html=1
invoke_plugin_on_html=0
promote_html_part=0
line_space=2
never_send_retrcpt=0
enable_smooth_scroll=0
scroll_step=1
scroll_half_page=0
hide_quoted=1
respect_flowed_format=0
show_all_headers=0
show_other_header=0
attach_desc=1
attach_save_directory=
attach_load_directory=
mime_textviewer=
mime_open_command=gedit '%s'
show_inline_attachments=1
layout_mode=0
always_show_message_when_selected=0
select_on_entry=3
show_tooltips=1
summary_select_prio1=2
summary_select_prio2=3
summary_select_prio3=1
summary_select_prio4=5
summary_select_prio5=0
summary_select_prio6=0
summary_select_prio7=0
mark_as_read_on_new_window=0
mark_as_read_delay=0
immediate_execution=1
nextunreadmsg_dialog=1
summary_from_show=0
pixmap_theme_path=INTERNAL_DEFAULT
ask_mark_all_read=1
ask_apply_per_account_filtering_rules=1
apply_per_account_filtering_rules=0
addressbook_use_editaddress_dialog=1
addressbook_hpaned_pos=-1
addressbook_vpaned_pos=-1
uri_open_command=firefox '%s'
ext_editor_command=gedit '%s'
cmds_use_system_default=1
add_address_by_click=0
session_passwords=0
confirm_on_exit=0
clean_trash_on_exit=0
ask_on_cleaning=1
warn_queued_on_exit=1
work_offline=0
summary_quicksearch_type=0
summary_quicksearch_recurse=1
io_timeout_secs=60
hide_score=-9999
important_score=1
clip_log=1
log_length=500
enable_log_standard=1
enable_log_warning=1
enable_log_error=1
enable_log_status=1
log_msg_color=#00af00
log_warn_color=#af0000
log_error_color=#af0000
log_in_color=#000000
log_out_color=#0000ef
log_status_ok_color=#00af00
log_status_nok_color=#0000af
log_status_skip_color=#aa00aa
enable_filtering_debug=0
filtering_debug_level=1
enable_filtering_debug_inc=1
enable_filtering_debug_manual=1
enable_filtering_debug_folder_proc=0
enable_filtering_debug_pre_proc=0
enable_filtering_debug_post_proc=0
filtering_debug_clip_log=1
filtering_debug_log_length=500
gtk_can_change_accels=0
color_new=#0000b3
filteringwin_width=500
filteringwin_height=-1
filteringactionwin_width=490
filteringactionwin_height=-1
matcherwin_width=520
matcherwin_height=-1
templateswin_width=480
templateswin_height=-1
actionswin_width=486
actionswin_height=-1
tagswin_width=486
tagswin_height=-1
addressbookwin_width=520
addressbookwin_height=-1
addressbookeditpersonwin_width=640
addressbookeditpersonwin_height=320
addressbookeditgroupwin_width=580
addressbookeditgroupwin_height=340
pluginswin_width=-1
pluginswin_height=-1
prefswin_width=600
prefswin_height=-1
folderitemwin_width=500
folderitemwin_height=-1
zero_replacement_char=0
editaccountwin_width=500
editaccountwin_height=-1
accountswin_width=500
accountswin_height=-1
logwin_width=520
logwin_height=-1
filtering_debugwin_width=600
filtering_debugwin_height=-1
folderselwin_width=300
folderselwin_height=-1
addressaddwin_width=300
addressaddwin_height=-1
addressbook_folderselwin_width=300
addressbook_folderselwin_height=-1
aboutwin_width=450
aboutwin_height=500
addrgather_width=450
addrgather_height=-1
news_subscribe_width=450
news_subscribe_height=400
warn_dnd=1
utf8_instead_of_locale_for_broken_mail=0
enable_swap_from=0
use_stripes_everywhere=1
use_stripes_in_summaries=1
stripes_color_offset=4000
enable_hscrollbar=1
folderview_vscrollbar_policy=0
textview_cursor_visible=0
hover_timeout=500
cache_max_mem_usage=4096
cache_min_keep_time=15
thread_by_subject_max_age=10
last_opened_folder=#imap/hacker@isp-a.milxc/Trash
goto_last_folder_on_startup=0
summary_quicksearch_sticky=1
summary_quicksearch_dynamic=0
summary_quicksearch_autorun=0
statusbar_update_step=10
compose_no_markup=0
skip_ssl_cert_check=0
live_dangerously=0
save_parts_readwrite=0
hide_quotes=0
unsafe_ssl_certs=0
real_time_sync=0
print_paper_type=
print_paper_orientation=0
print_margin_top=-1
print_margin_bottom=-1
print_margin_left=-1
print_margin_right=-1
print_use_color=0
print_use_collate=0
print_use_reverse=0
print_use_duplex=0
print_imgs=1
print_previewwin_width=600
print_previewwin_height=-1
use_networkmanager=1
use_shred=0
two_line_vertical=1
inherit_folder_properties=0
flush_metadata=1
nav_history_length=50
diff_added_color=#008b8b
diff_deleted_color=#6a5acd
diff_hunk_color=#a52a2a
folder_search_wildcard=1
address_search_wildcard=1
enable_avatars=3
use_master_passphrase=0
master_passphrase=
master_passphrase_salt=uO5gxcSFnCOAN3ESLXOZyqoz3aJemnEKsaaxqPtD5zyrigsCfpqE7ahXNY4N9A3qnEIBv/3PAqxeTUq9VrKr9g==
master_passphrase_pbkdf2_rounds=50000

6
files/clawsmail/claws-mail/folderlist.xml

@ -0,0 +1,6 @@
<folder type="imap" sort="0" collapsed="0" account_id="$number" name="$name@$domainname">
<folderitem last_change="0" last_sync="0" uidnext="0" last_seen="0" order="0" watched="0" ignore="0" locked="0" forwarded="0" replied="0" total="0" marked="0" unreadmarked="0" unread="0" new="0" mtime="0" sort_type="descending" sort_key="date" hidereadthreads="0" hidedelmsgs="0" hidereadmsgs="0" threaded="1" thread_collapsed="0" collapsed="0" path="Trash" name="Trash" type="trash" />
<folderitem last_change="0" last_sync="0" uidnext="0" last_seen="0" order="0" watched="0" ignore="0" locked="0" forwarded="0" replied="0" total="0" marked="0" unreadmarked="0" unread="0" new="0" mtime="0" sort_type="descending" sort_key="date" hidereadthreads="0" hidedelmsgs="0" hidereadmsgs="0" threaded="1" thread_collapsed="0" collapsed="0" path="Sent" name="Sent" type="outbox" />
<folderitem last_change="0" last_sync="0" uidnext="0" last_seen="0" order="0" watched="0" ignore="0" locked="0" forwarded="0" replied="0" total="0" marked="0" unreadmarked="0" unread="0" new="0" mtime="0" sort_type="descending" sort_key="date" hidereadthreads="0" hidedelmsgs="0" hidereadmsgs="0" threaded="1" thread_collapsed="0" collapsed="0" path="Drafts" name="Drafts" type="draft" />
<folderitem last_change="0" last_sync="0" uidnext="0" last_seen="0" order="0" watched="0" ignore="0" locked="0" forwarded="0" replied="0" total="0" marked="0" unreadmarked="0" unread="0" new="0" mtime="0" sort_type="descending" sort_key="date" hidereadthreads="0" hidedelmsgs="0" hidereadmsgs="0" threaded="1" thread_collapsed="0" collapsed="0" path="INBOX" name="INBOX" type="inbox" />
</folder>

10
files/clawsmail/claws-mail/folderlist_skel.xml

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<folderlist>
<folder type="mh" path="Mail" sort="0" collapsed="1" name="Boîte aux lettres">
<folderitem last_seen="0" order="0" watched="0" ignore="0" locked="0" forwarded="0" replied="0" total="0" marked="0" unreadmarked="0" unread="0" new="0" mtime="1641582172" sort_type="descending" sort_key="date" hidereadthreads="0" hidedelmsgs="0" hidereadmsgs="0" threaded="1" thread_collapsed="0" collapsed="0" path="inbox" name="inbox" type="inbox" />
<folderitem last_seen="0" order="0" watched="0" ignore="0" locked="0" forwarded="0" replied="0" total="0" marked="0" unreadmarked="0" unread="0" new="0" mtime="1641582172" sort_type="descending" sort_key="date" hidereadthreads="0" hidedelmsgs="0" hidereadmsgs="0" threaded="1" thread_collapsed="0" collapsed="0" path="draft" name="draft" type="draft" />
<folderitem last_seen="0" order="0" watched="0" ignore="0" locked="0" forwarded="0" replied="0" total="0" marked="0" unreadmarked="0" unread="0" new="0" mtime="1641582172" sort_type="descending" sort_key="date" hidereadthreads="0" hidedelmsgs="0" hidereadmsgs="0" threaded="1" thread_collapsed="0" collapsed="0" path="trash" name="trash" type="trash" />
<folderitem last_seen="0" order="0" watched="0" ignore="0" locked="0" forwarded="0" replied="0" total="0" marked="0" unreadmarked="0" unread="0" new="0" mtime="1641582172" sort_type="descending" sort_key="date" hidereadthreads="0" hidedelmsgs="0" hidereadmsgs="0" threaded="1" thread_collapsed="0" collapsed="0" path="sent" name="sent" type="outbox" />
<folderitem last_seen="0" order="0" watched="0" ignore="0" locked="0" forwarded="0" replied="0" total="0" marked="0" unreadmarked="0" unread="0" new="0" mtime="1641582350" sort_type="descending" sort_key="date" hidereadthreads="0" hidedelmsgs="0" hidereadmsgs="0" threaded="1" thread_collapsed="0" collapsed="0" path="queue" name="queue" type="queue" />
</folder>
</folderlist>

2
files/clawsmail/claws-mail/passwordstorerc

@ -0,0 +1,2 @@
[account:1]
recv $password

BIN
files/clawsmail/genpasswd

Binary file not shown.

333
files/clawsmail/genpasswd.c

@ -0,0 +1,333 @@
/* customized from claws mail source code */
/* pkcs5_pbkdf2.c - Password-Based Key Derivation Function 2
* Copyright (c) 2008 Damien Bergamini <damien.bergamini@free.fr>
*
* Modifications for Claws Mail are:
* Copyright (c) 2016 the Claws Mail team
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/*
* Claws Mail -- a GTK+ based, lightweight, and fast e-mail client
* Copyright (C) 2016 The Claws Mail Team
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#include <glib.h>
#include <sys/types.h>
#include <string.h>
#include <stdint.h>
#include <stdlib.h>
#include <stdio.h>
#define CHECKSUM_BLOCKLEN 64
/*
* HMAC-SHA-1 (from RFC 2202).
*/
static void
hmac_sha1(const guchar *text, size_t text_len, const guchar *key,
size_t key_len, guchar *digest)
{
GChecksum *cksum;
gssize digestlen = g_checksum_type_get_length(G_CHECKSUM_SHA1);
gsize outlen;
guchar k_pad[CHECKSUM_BLOCKLEN];
guchar tk[digestlen];
gint i;
if (key_len > CHECKSUM_BLOCKLEN) {
cksum = g_checksum_new(G_CHECKSUM_SHA1);
g_checksum_update(cksum, key, key_len);
outlen = digestlen;
g_checksum_get_digest(cksum, tk, &outlen);
g_checksum_free(cksum);
key = tk;
key_len = digestlen;
}
memset(k_pad, 0, sizeof k_pad);
memcpy(k_pad, key, key_len);
for (i = 0; i < CHECKSUM_BLOCKLEN; i++)
k_pad[i] ^= 0x36;
cksum = g_checksum_new(G_CHECKSUM_SHA1);
g_checksum_update(cksum, k_pad, CHECKSUM_BLOCKLEN);
g_checksum_update(cksum, text, text_len);
outlen = digestlen;
g_checksum_get_digest(cksum, digest, &outlen);
g_checksum_free(cksum);
memset(k_pad, 0, sizeof k_pad);
memcpy(k_pad, key, key_len);
for (i = 0; i < CHECKSUM_BLOCKLEN; i++)
k_pad[i] ^= 0x5c;
cksum = g_checksum_new(G_CHECKSUM_SHA1);
g_checksum_update(cksum, k_pad, CHECKSUM_BLOCKLEN);
g_checksum_update(cksum, digest, digestlen);
outlen = digestlen;
g_checksum_get_digest(cksum, digest, &outlen);
g_checksum_free(cksum);
}
#undef CHECKSUM_BLOCKLEN
/*
* Password-Based Key Derivation Function 2 (PKCS #5 v2.0).
* Code based on IEEE Std 802.11-2007, Annex H.4.2.
*/
gint
pkcs5_pbkdf2(const gchar *pass, size_t pass_len, const guchar *salt,
size_t salt_len, guchar *key, size_t key_len, guint rounds)
{
gssize digestlen = g_checksum_type_get_length(G_CHECKSUM_SHA1);
guchar *asalt, obuf[digestlen];
guchar d1[digestlen], d2[digestlen];
guint i, j;
guint count;
size_t r;
if (pass == NULL || salt == NULL || key == NULL)
return -1;
if (rounds < 1 || key_len == 0)
return -1;
if (salt_len == 0 || salt_len > SIZE_MAX - 4)
return -1;
if ((asalt = malloc(salt_len + 4)) == NULL)
return -1;
memcpy(asalt, salt, salt_len);
for (count = 1; key_len > 0; count++) {
asalt[salt_len + 0] = (count >> 24) & 0xff;
asalt[salt_len + 1] = (count >> 16) & 0xff;
asalt[salt_len + 2] = (count >> 8) & 0xff;
asalt[salt_len + 3] = count & 0xff;
hmac_sha1(asalt, salt_len + 4, pass, pass_len, d1);
memcpy(obuf, d1, sizeof(obuf));
for (i = 1; i < rounds; i++) {
hmac_sha1(d1, sizeof(d1), pass, pass_len, d2);
memcpy(d1, d2, sizeof(d1));
for (j = 0; j < sizeof(obuf); j++)
obuf[j] ^= d1[j];
}
r = MIN(key_len, digestlen);
memcpy(key, obuf, r);
key += r;
key_len -= r;
};
memset(asalt, 0, salt_len + 4);
free(asalt);
memset(d1, 0, sizeof(d1));
memset(d2, 0, sizeof(d2));
memset(obuf, 0, sizeof(obuf));
return 0;
}
//
# include <gnutls/gnutls.h>
# include <gnutls/crypto.h>
#include <glib.h>
#include <glib/gi18n.h>
#include <stdlib.h>
/* Length of stored key derivation, before base64. */
#define KD_LENGTH 64
/* Length of randomly generated and saved salt, used for key derivation.
* Also before base64. */
#define KD_SALT_LENGTH 64
char* monsalt;
int get_random_bytes(char* dst, int len) {
return 1;
}
static void _generate_salt()
{
guchar salt[KD_SALT_LENGTH];
if (!get_random_bytes(salt, KD_SALT_LENGTH)) {
printf("Could not get random bytes for kd salt.\n");
return;
}
monsalt = g_base64_encode(salt, KD_SALT_LENGTH);
}
#undef KD_SALT_LENGTH
static guchar *_make_key_deriv(const gchar *passphrase, guint rounds,
guint length)
{
guchar *kd, *salt;
gchar *saltpref = "uO5gxcSFnCOAN3ESLXOZyqoz3aJemnEKsaaxqPtD5zyrigsCfpqE7ahXNY4N9A3qnEIBv/3PAqxeTUq9VrKr9g==";
gsize saltlen;
gint ret;
/* Grab our salt, generating and saving a new random one if needed. */
if (saltpref == NULL || strlen(saltpref) == 0) {
_generate_salt();
saltpref = "uO5gxcSFnCOAN3ESLXOZyqoz3aJemnEKsaaxqPtD5zyrigsCfpqE7ahXNY4N9A3qnEIBv/3PAqxeTUq9VrKr9g==";
}
salt = g_base64_decode(saltpref, &saltlen);
kd = g_malloc0(length);
//START_TIMING("PBKDF2");
ret = pkcs5_pbkdf2(passphrase, strlen(passphrase), salt, saltlen,
kd, length, rounds);
//END_TIMING();
g_free(salt);
if (ret == 0) {
return kd;
}
g_free(kd);
return NULL;
}
#define BUFSIZE 128
#define IVLEN 16
gchar *password_encrypt_gnutls(const gchar *password,
const gchar *encryption_passphrase)
{
gnutls_cipher_algorithm_t algo = GNUTLS_CIPHER_AES_256_CBC;
gnutls_cipher_hd_t handle;
gnutls_datum_t key, iv;
int keylen, blocklen, ret, len, i;
unsigned char *buf, *encbuf, *base, *output;
guint rounds = 5000;
g_return_val_if_fail(password != NULL, NULL);
g_return_val_if_fail(encryption_passphrase != NULL, NULL);
/* ivlen = gnutls_cipher_get_iv_size(algo);*/
keylen = gnutls_cipher_get_key_size(algo);
blocklen = gnutls_cipher_get_block_size(algo);
/* digestlen = gnutls_hash_get_len(digest); */
/* Take the passphrase and compute a key derivation of suitable
* length to be used as encryption key for our block cipher. */
key.data = _make_key_deriv(encryption_passphrase, rounds, keylen);
key.size = keylen;
/* Prepare random IV for cipher */
iv.data = malloc(IVLEN);
iv.size = IVLEN;
if (!get_random_bytes(iv.data, IVLEN)) {
g_free(key.data);
g_free(iv.data);
return NULL;
}
/* Initialize the encryption */
ret = gnutls_cipher_init(&handle, algo, &key, &iv);
if (ret < 0) {
g_free(key.data);
g_free(iv.data);
return NULL;
}
/* Find out how big buffer (in multiples of BUFSIZE)
* we need to store the password. */
i = 1;
len = strlen(password);
while(len >= i * BUFSIZE)
i++;
len = i * BUFSIZE;
/* Fill buf with one block of random data, our password, pad the
* rest with zero bytes. */
buf = malloc(len + blocklen);
memset(buf, 0, len + blocklen);
if (!get_random_bytes(buf, blocklen)) {
g_free(buf);
g_free(key.data);
g_free(iv.data);
gnutls_cipher_deinit(handle);
return NULL;
}
memcpy(buf + blocklen, password, strlen(password));
/* Encrypt into encbuf */
encbuf = malloc(len + blocklen);
memset(encbuf, 0, len + blocklen);
ret = gnutls_cipher_encrypt2(handle, buf, len + blocklen,
encbuf, len + blocklen);
if (ret < 0) {
g_free(key.data);
g_free(iv.data);
g_free(buf);
g_free(encbuf);
gnutls_cipher_deinit(handle);
return NULL;
}
/* Cleanup */
gnutls_cipher_deinit(handle);
g_free(key.data);
g_free(iv.data);
g_free(buf);
/* And finally prepare the resulting string:
* "{algorithm,rounds}base64encodedciphertext" */
base = g_base64_encode(encbuf, len + blocklen);
//printf("base is %s\n", base);
g_free(encbuf);
output = g_strdup_printf("{%s,%d}%s",
gnutls_cipher_get_name(algo), rounds, base);
g_free(base);
//printf(output);
return output;
}
int main(int argc, char* argv[]) {
//printf("pass %s %s\n", password_encrypt_gnutls("totfrefrgo", "passkey0"), gnutls_cipher_get_name(GNUTLS_CIPHER_AES_256_CBC));
printf(password_encrypt_gnutls(argv[1], "passkey0"));
//printf(argv[1]);
}

78
files/kaz.sh

@ -0,0 +1,78 @@
#!/bin/bash
if [ -z "${KAZGUARD}" ] ; then
exit 1
fi
DIR=$(cd "$(dirname $0)"; pwd)
cd "${DIR}"
set -e
export VAGRANT_SRC_DIR=/vagrant/files
mkdir -p "${VAGRANT_SRC_DIR}/log/"
export DebugLog="${VAGRANT_SRC_DIR}/log/log-kaz-$(date +%y-%m-%d-%T)-"
(
echo "########## ********** Start kaz.sh $(date +%D-%T)"
#pour la résolution de noms dans /etc/hosts
SERVICES_LIST="smtp mail ldap www depot tableur pad webmail sondage garradin test-garradin wiki git agora cloud office cachet quotas"
docker-clean -a
rm -rf /kaz
if [ -z "${KAZBRANCH}" ] ; then
KAZBRANCH="master"
fi
echo -e "\n #### git checkout ${KAZBRANCH}\n"
# copie des sources
cd /
[ -f kaz ] || git clone https://git.kaz.bzh/KAZ/kaz.git
(cd /kaz ; git checkout "${KAZBRANCH}" )
find /kaz -name \*.sh -exec chmod a+x {} \;
# pour ceux qui disposent d'un cache apt local et pas la fibre
if [ -f "${VAGRANT_SRC_DIR}/.apt-mirror-config" ]; then
rsync -a "${VAGRANT_SRC_DIR}/.apt-mirror-config" /kaz/
fi
if [ -f "${VAGRANT_SRC_DIR}/.proxy-config" ]; then
rsync -a "${VAGRANT_SRC_DIR}/.proxy-config" /etc/profile.d/proxy.sh
rsync -a "${VAGRANT_SRC_DIR}/.proxy-config" /kaz/
fi
if [ -f "${VAGRANT_SRC_DIR}/.docker-config.json" ]; then
mkdir -p /root/.docker
rsync -a "${VAGRANT_SRC_DIR}/.docker-config.json" /root/.docker/config.json
fi
echo -e "\n #### rsync download\n"
[ -d "${VAGRANT_SRC_DIR}/kaz/download" ] &&
rsync -a "${VAGRANT_SRC_DIR}/kaz/download/" /kaz/download/
[ -d "${VAGRANT_SRC_DIR}/kaz/git" ] &&
rsync -a "${VAGRANT_SRC_DIR}/kaz/git/" /kaz/git/
[ -f "${VAGRANT_SRC_DIR}/kaz/config/dockers.env" ] &&
[ ! -f "/kaz/config/dockers.env" ] &&
rsync -a "${VAGRANT_SRC_DIR}/kaz/config/dockers.env" /kaz/config/dockers.env
for type in mail orga proxy withMail withoutMail ; do
[ -f "${VAGRANT_SRC_DIR}/kaz/config/container-${type}.list" ] &&
[ ! -f "/kaz/config/config/container-${type}.list" ] &&
rsync -a "${VAGRANT_SRC_DIR}/kaz/config/container-${type}.list" /kaz/config/
done
echo -e "\n #### secretGen\n"
/kaz/bin/secretGen.sh
#possibilité de lancer vagrant up NOKAZ="true" quand on construit la machine
if [ "${NOKAZ}" == "true" ]; then
echo "on ne lance pas install.sh"
else
echo "on lance install.sh"
/kaz/bin/install.sh
fi
# clear apt cache
DEBIAN_FRONTEND=noninteractive apt-get autoremove -y
DEBIAN_FRONTEND=noninteractive apt-get clean
echo "########## ********** End kaz.sh $(date +%D-%T)"
) > >(tee ${DebugLog}stdout.log) 2> >(tee ${DebugLog}stderr.log >&2)

3
files/kaz/config/container-mail.list

@ -0,0 +1,3 @@
# e-mail server composer
postfix
sympa

1
files/kaz/config/container-orga.list

@ -0,0 +1 @@
# orga composer

1
files/kaz/config/container-proxy.list

@ -0,0 +1 @@
proxy

9
files/kaz/config/container-withMail.list

@ -0,0 +1,9 @@
cloud
dokuwiki
#framadate
garradin
gitea
jirafeau
#mattermost
roundcube
#keycloak

10
files/kaz/config/container-withoutMail.list

@ -0,0 +1,10 @@
cachet
jirafeau
ethercalc
collabora
ethercalc
etherpad
ldap
quotas
web
#vigilo

120
files/kaz/config/dockers.env

@ -0,0 +1,120 @@
# Les variables d'environnements utilisées
# par les dockers via le lien :
# .env -> ../../config/dockers.env
#######################################
# prod / dev / local
mode=local
########################################
# choix du domaine
# prod=kaz.bzh / dev=dev.kaz.bzh / local=kaz.local
domain=kaz.local
########################################
# choix du domaine des mails sympa
# prod=kaz.bzh / dev=kaz2.ovh / local=kaz.local
domain_sympa=kaz.local
########################################
# choix d'un serveur partiel
# site=site-2
site=
########################################
# Pour garradin qui met en "dure" dans
# sa config l'URL pour l'atteindre
# prod=https (gandi) / dev=https (letsencrypt) / local=http
httpProto=https
# prod=89.234.186.111 / dev=192.168.57.1 / local=127.0.0.1
MAIN_IP=127.0.0.1
# prod=89.234.186.151 / dev=192.168.57.2 / local=127.0.0.2
SYMPA_IP=127.0.0.2
########################################
# noms des services
# ou www (mais bof)
webHost=
cachetHost=cachet
calcHost=tableur
cloudHost=cloud
dateHost=sondage
dokuwikiHost=wiki
fileHost=depot
garHost=garradin
gitHost=git
gravHost=grav
ldapHost=ldap
matterHost=agora
officeHost=office
padHost=pad
quotasHost=quotas
smtpHost=smtp
sympaHost=listes
vigiloHost=vigilo
webmailHost=webmail
wordpressHost=wp
########################################
# noms des containers
cachetServName=cachetServ
dokuwikiServName=dokuwikiServ
ethercalcServName=ethercalcServ
etherpadServName=etherpadServ
framadateServName=framadateServ
garradinServName=garradinServ
gitServName=gitServ
gravServName=gravServ
jirafeauServName=jirafeauServ
ldapServName=ldapServ
mattermostServName=mattermostServ
nextcloudServName=nextcloudServ
officeServName=officeServ
proxyServName=proxyServ
quotasServName=quotasServ
roundcubeServName=roundcubeServ
smtpServName=mailServ
sympaServName=sympaServ
vigiloServName=vigiloServ
webServName=webServ
wordpressServName=wpServ
cachetDBName=cachetDB
ethercalcDBName=ethercalcDB
etherpadDBName=etherpadDB
framadateDBName=framadateDB
gitDBName=gitDB
mattermostDBName=mattermostDB
nextcloudDBName=nextcloudDB
quotasDBName=quotasDB
roundcubeDBName=roundcubeDB
sympaDBName=sympaDB
vigiloDBName=vigiloDB
wordpressDBName=wpDB
ldapIUName=ldapIU
########################################
# politique de redémarrage
# prod=always / test=unless-stopped / local=no
restartPolicy=no
########################################
# devrait être dans env-jirafeauServ
# mais seuls les variables de ".env" sont
# utilisables pour le montage des volumes
jirafeauDir=/var/jirafeauData/lkuDM16R5Sp4QHr/
ldapRoot=dc=kaz,dc=local
########################################
# services activés par container.sh
# variables d'environneements utilisées
# pour le tmpl du mandataire (proxy)

10
files/keyboard

@ -0,0 +1,10 @@
# KEYBOARD CONFIGURATION FILE
# Consult the keyboard(5) manual page.
XKBMODEL="pc105"
XKBLAYOUT="fr"
XKBVARIANT="latin9"
XKBOPTIONS="terminate:ctrl_alt_bksp"
BACKSPACE="guess"

315
files/provision.sh

@ -0,0 +1,315 @@
#!/bin/bash
if [ -z "${KAZGUARD}" ] ; then
exit 1
fi
resize2fs /dev/sda1
DIR=$(cd "$(dirname $0)"; pwd)
cd "${DIR}"
set -e
export VAGRANT_SRC_DIR=/vagrant/files
mkdir -p "${VAGRANT_SRC_DIR}/log/"
export DebugLog="${VAGRANT_SRC_DIR}/log/log-vagrant-$(date +%y-%m-%d-%T)-"
(
echo "########## ********** Start Vagrant $(date +%D-%T)"
#pour la résolution de noms dans /etc/hosts
SERVICES_LIST="smtp mail ldap www depot tableur pad webmail sondage garradin test-garradin wiki git agora cloud office cachet quotas"
# Copie de qques fichiers
cp "${VAGRANT_SRC_DIR}/keyboard" /etc/default/keyboard
# Lock grub (https://www.mail-archive.com/debian-bugs-dist@lists.debian.org/msg1758060.html)
sysctl -w net.ipv4.ip_forward=1
DEBIAN_FRONTEND=noninteractive apt-mark hold grub*
# MAJ et install
sed -i -e 's/main.*/main contrib non-free/' /etc/apt/sources.list
if [ -f "${VAGRANT_SRC_DIR}/.apt-mirror-config" ]; then
# pour ceux qui disposent d'un cache apt local et pas la fibre
# suffit d'indiquer "host:port" dans le fichier ".apt-mirror-config"
. "${VAGRANT_SRC_DIR}/.apt-mirror-config"
sed -i \
-e "s%s\?://deb.debian.org%://${APT_MIRROR_DEBIAN}%g" \
-e "s%s\?://security.debian.org%://${APT_MIRROR_DEBIAN_SECURITY}%g" \
-e "s%s\?://archive.ubuntu.com%://${APT_MIRROR_UBUNTU}%g" \
-e "s%s\?://security.ubuntu.com%://${APT_MIRROR_UBUNTU_SECURITY}%g" \
/etc/apt/sources.list
fi
DEBIAN_FRONTEND=noninteractive apt-get --allow-releaseinfo-change update
DEBIAN_FRONTEND=noninteractive apt-get -y upgrade
DEBIAN_FRONTEND=noninteractive apt-get -y dist-upgrade
DEBIAN_FRONTEND=noninteractive apt-get install -y apg curl git sudo unzip rsync firefox-esr tcpdump net-tools mousepad wireshark swapspace whois ldap-utils # could be with --no-install-recommends
DEBIAN_FRONTEND=noninteractive apt-get install -y xfce4 lightdm xfce4-terminal xserver-xorg gitk # needs to install recommends
ssh-keygen -t rsa -b 4096 -N '' <<<$'\ny'
rsync /root/.ssh/id_rsa.pub /root/.ssh/authorized_keys
# Pour le confort de chacun
# Le fihcier .customDocker.sh contient
# DEBIAN_FRONTEND=noninteractive apt-get install -y joe
# DEBIAN_FRONTEND=noninteractive apt-get install -y emacs
# DEBIAN_FRONTEND=noninteractive apt-get install -y vim
if [ -f "${VAGRANT_SRC_DIR}/.customDocker.sh" ]; then
chmod a+x "${VAGRANT_SRC_DIR}/.customDocker.sh"
"${VAGRANT_SRC_DIR}/.customDocker.sh"
fi
# Localisation du $LANG, en par défaut, timezone Paris
if [ -z "${HOSTLANG}" ] ; then
HOSTLANG="en_US.UTF-8"
fi
echo "Europe/Paris" > /etc/timezone
ln -sf /usr/share/zoneinfo/Europe/Paris /etc/localtime
dpkg-reconfigure -f noninteractive tzdata
sed -i -e 's/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen
sed -i -e "s/# ${HOSTLANG} /${HOSTLANG} /" /etc/locale.gen
echo "LANG=\"${HOSTLANG}\"">/etc/default/locale
dpkg-reconfigure --frontend=noninteractive locales || true # don't fail for a locales problem
update-locale LANG=${HOSTLANG} || true # don't fail for a locales problem
echo -e "\n #### create user\n"
# Creation des utilisateurs
usermod -p $(mkpasswd --method=sha-512 root) root
useradd -m -s "/bin/bash" -p $(mkpasswd --method=sha-512 debian) debian || true # don't fail if user already exists
# augmentation de la taille de /run si lowmem
#echo "tmpfs /run tmpfs nosuid,noexec,size=26M 0 0" >> /etc/fstab
#mount -o remount /run
# Désactivation de la mise en veille de l'écran
mkdir -p /etc/X11/xorg.conf.d/
rsync -a "${VAGRANT_SRC_DIR}/10-monitor.conf" /etc/X11/xorg.conf.d/
# mv /etc/xdg/autostart/light-locker.desktop /etc/xdg/autostart/light-locker.desktop.bak
DEBIAN_FRONTEND=noninteractive apt-get remove --purge -y light-locker
#faut virer exim, il fout la grouille avec le docker postfix
DEBIAN_FRONTEND=noninteractive apt-get remove --purge -y exim4-base exim4-config exim4-daemon-light
#login ssh avec mot de passe
sed -i "s/PasswordAuthentication no/PasswordAuthentication yes/" /etc/ssh/sshd_config
if ! grep -q "PasswordAuthentication yes" /etc/ssh/sshd_config 2>/dev/null; then
echo "PasswordAuthentication yes" >> /etc/ssh/sshd_config
fi
# autorisation du routing et augmentation inotify
if ! grep -q "net.ipv4.ip_forward" /etc/sysctl.conf 2>/dev/null; then
echo "net.ipv4.ip_forward=1" >> /etc/sysctl.conf
fi
sed -i "s/#net.ipv4.ip_forward=1/net.ipv4.ip_forward=1/" /etc/sysctl.conf
if ! grep -q "fs.inotify.max_queued_events" /etc/sysctl.conf 2>/dev/null; then
echo -e "fs.inotify.max_queued_events=1048576\nfs.inotify.max_user_instances=1048576\nfs.inotify.max_user_watches=1048576" >> /etc/sysctl.conf
fi
sysctl -p
# enable bash autocompletion
if ! grep -q "/usr/share/bash-completion/bash_completion" /etc/bash.bashrc 2>/dev/null; then
cat >> /etc/bash.bashrc <<EOF
# enable bash completion in interactive shells
if ! shopt -oq posix; then
if [ -f /usr/share/bash-completion/bash_completion ]; then
. /usr/share/bash-completion/bash_completion
elif [ -f /etc/bash_completion ]; then
. /etc/bash_completion
fi
fi
EOF
fi
# XFCE4 panel: use default config
# source: https://forum.xfce.org/viewtopic.php?pid=36585#p36585
rsync -a /etc/xdg/xfce4/panel/default.xml /etc/xdg/xfce4/xfconf/xfce-perchannel-xml/xfce4-panel.xml
# Permetre l'édition emacs des lignes de commande (exemple "Esc. flèche gauche" pour "déplace d'un mot à gauche")
TERM_CFG=/root/.config/xfce4/terminal/terminalrc
mkdir -p $(dirname "${TERM_CFG}")
touch "${TERM_CFG}"
if ! grep -q "ShortcutsNoMnemonics" "${TERM_CFG}" 2>/dev/null; then
echo -e "[Configuration]\nShortcutsNoMnemonics=TRUE" >> "${TERM_CFG}"
fi
echo -e "\n #### set swapspace\n"
# free swapspace at shutdown
sed -i -e 's/ExecStart=\/usr\/sbin\/swapspace/ExecStart=\/usr\/sbin\/swapspace\nExecStop=\/usr\/sbin\/swapspace -e/' /lib/systemd/system/swapspace.service
systemctl daemon-reload
# limit journald log size
mkdir -p /etc/systemd/journald.conf.d
if [ ! -f /etc/systemd/journald.conf.d/sizelimit.conf ]; then
cat > /etc/systemd/journald.conf.d/sizelimit.conf <<EOF
[Journal]
SystemMaxUse=20M
SystemMaxFileSize=2M
EOF
fi
# KAZ specific things
#installation de docker, docker-compose et on y fourre le user debian dans le groupe idoine
DEBIAN_FRONTEND=noninteractive apt-get install -y docker.io docker-compose docker-clean
usermod -G docker debian
# activation dans alias dans /root/.bashrc
sed -i \
-e 's/^\# alias/alias/g' \
-e 's/^\# export/export/g' \
-e 's/^\# eval/eval/g' \
/root/.bashrc
if ! grep -q "for file in /dockers" /root/.bashrc 2>/dev/null; then
cat >> /root/.bashrc <<EOF
# enable bash completion in interactive shells
if ! shopt -oq posix; then
if [ -f /usr/share/bash-completion/bash_completion ]; then
. /usr/share/bash-completion/bash_completion
elif [ -f /etc/bash_completion ]; then
. /etc/bash_completion
fi
fi
for file in /kaz/bin/.*-completion.bash ; do
source "\${file}"
done
EOF
fi
# # Localisation du $LANG, en par défaut, timezone Paris
# if [ -z "${KAZBRANCH}" ] ; then
# KAZBRANCH="develop-vm"
# fi
# echo -e "\n #### git checkout ${KAZBRANCH}\n"
#
# # copie des sources
# cd /
# [ -f kaz ] || git clone https://git.kaz.bzh/KAZ/kaz.git
# (cd /kaz ; git checkout "${KAZBRANCH}" )
# find /kaz -name \*.sh -exec chmod a+x {} \;
#
# # pour ceux qui disposent d'un cache apt local et pas la fibre
# if [ -f "${VAGRANT_SRC_DIR}/.apt-mirror-config" ]; then
# rsync -a "${VAGRANT_SRC_DIR}/.apt-mirror-config" /kaz/
# fi
# if [ -f "${VAGRANT_SRC_DIR}/.proxy-config" ]; then
# rsync -a "${VAGRANT_SRC_DIR}/.proxy-config" /etc/profile.d/proxy.sh
# rsync -a "${VAGRANT_SRC_DIR}/.proxy-config" /kaz/
# fi
# if [ -f "${VAGRANT_SRC_DIR}/.docker-config.json" ]; then
# mkdir -p /root/.docker
# rsync -a "${VAGRANT_SRC_DIR}/.docker-config.json" /root/.docker/config.json
# fi
# Ajout d'un serveur DNS sur la VM
#*****************ATTENTION: semble inutile. peut-être privilégié les entrées dans /etc/hosts tout simplement ?
DEBIAN_FRONTEND=noninteractive apt-get install -y dnsmasq
#***********DEBUT CERTIF*******************
#*****************ATTENTION: MARCHE PAS (il faut accepter toutes les exceptions de sécurité
echo -e "\n #### mkcert\n"
# Récupérer mkcert et générer la CA
DEBIAN_FRONTEND=noninteractive apt-get install -y libnss3-tools
mkdir -p /root/mkcert
cd /root/mkcert
if [ ! -f mkcert ]; then
wget https://github.com/FiloSottile/mkcert/releases/download/v1.4.3/mkcert-v1.4.3-linux-amd64 -O mkcert
chmod +x mkcert
mkdir -p /etc/letsencrypt/local/
export CAROOT=/etc/letsencrypt/local/
/root/mkcert/mkcert -install # CA dans /etc/letsencrypt/local/
cd "${CAROOT}"
/root/mkcert/mkcert "*.kaz.local" # cert et clé dans /etc/letsencrypt/local/
mkdir -p /etc/letsencrypt/live/kaz.local/
ln -s ../../local/_wildcard.kaz.local.pem /etc/letsencrypt/live/kaz.local/fullchain.pem
ln -s ../../local/_wildcard.kaz.local-key.pem /etc/letsencrypt/live/kaz.local/privkey.pem
fi
# Essai pour faire accepter la CA à FFOX dès le début
# Add to Firefox store
if [ ! -f /usr/lib/firefox-esr/distribution/policies.json ]; then
cat > /usr/lib/firefox-esr/distribution/policies.json << EOF
{
"policies": {
"Certificates": {
"ImportEnterpriseRoots": true,
"Install": ["/etc/letsencrypt/local/rootCA.pem"]
}
}
}
EOF
fi
#***********FIN CERTIF*******************
#ajout des services dans le host
echo -e "\n #### update /etc/hosts\n"
if ! grep -q "\skaz.local\b" /etc/hosts 2>/dev/null; then
echo "127.0.0.1 kaz.local" >>/etc/hosts
fi
if ! grep -q "\slistes.kaz.local\b" /etc/hosts 2>/dev/null; then
echo "127.0.0.2 listes.kaz.local" >>/etc/hosts
fi
for SERVICE in ${SERVICES_LIST}; do
if ! grep -q "\s${SERVICE}.kaz.local\b" /etc/hosts 2>/dev/null; then
sed -i /etc/hosts \
-e "/\skaz.local\b/ s/$/ ${SERVICE}.kaz.local/"
fi
done
echo -e "\n #### clawsmail\n"
# les scripts de créations de BAL pour clawsmail
cp -ar "${VAGRANT_SRC_DIR}/clawsmail" /
cd /clawsmail
chmod +x addclawsuser.sh
chmod +x genpasswd
#client pour tester la messagerie
DEBIAN_FRONTEND=noninteractive apt-get install -y claws-mail
# On met le KAZGUARD pour la mise au point
echo "export KAZGUARD='true'" >> /root/.bashrc
# echo -e "\n #### rsync download\n"
# [ -d "${VAGRANT_SRC_DIR}/kaz/download" ] &&
# rsync -a "${VAGRANT_SRC_DIR}/kaz/download/" /kaz/download/
# [ -d "${VAGRANT_SRC_DIR}/kaz/git" ] &&
# rsync -a "${VAGRANT_SRC_DIR}/kaz/git/" /kaz/git/
# [ -f "${VAGRANT_SRC_DIR}/kaz/config/dockers.env" ] &&
# [ ! -f "/kaz/config/dockers.env" ] &&
# rsync -a "${VAGRANT_SRC_DIR}/kaz/config/dockers.env" /kaz/config/dockers.env
# for type in mail orga proxy withMail withoutMail ; do
# [ -f "${VAGRANT_SRC_DIR}/kaz/config/container-${type}.list" ] &&
# [ ! -f "/kaz/config/config/container-${type}.list" ] &&
# rsync -a "${VAGRANT_SRC_DIR}/kaz/config/container-${type}.list" /kaz/config/
# done
#
# echo -e "\n #### secretGen\n"
# /kaz/bin/secretGen.sh
#
# #possibilité de lancer vagrant up NOKAZ="true" quand on construit la machine
# if [ "${NOKAZ}" == "true" ]; then
# echo "on ne lance pas install.sh"
# else
# echo "on lance install.sh"
# /kaz/bin/install.sh
# fi
${VAGRANT_SRC_DIR}/kaz.sh
# clear apt cache
DEBIAN_FRONTEND=noninteractive apt-get autoremove -y
DEBIAN_FRONTEND=noninteractive apt-get clean
echo "########## ********** End Vagrant $(date +%D-%T)"
) > >(tee ${DebugLog}stdout.log) 2> >(tee ${DebugLog}stderr.log >&2)
reboot

15
files/test.html

@ -0,0 +1,15 @@
<html>
<a href="https://kaz.local">https://kaz.local</a><br/>
<a href="https://www.kaz.local">https://www.kaz.local</a><br/>
<a href="https://depot.kaz.local">https://depot.kaz.local</a><br/>
<a href="https://tableur.kaz.local">https://tableur.kaz.local</a><br/>
<a href="https://pad.kaz.local">https://pad.kaz.local</a><br/>
<a href="https://webmail.kaz.local">https://webmail.kaz.local</a><br/>
<a href="https://sondage.kaz.local">https://sondage.kaz.local</a><br/>
<a href="https://test-garradin.kaz.local">https://test-garradin.kaz.local</a><br/>
<a href="https://wiki.kaz.local">https://wiki.kaz.local</a><br/>
<a href="https://git.kaz.local">https://git.kaz.local</a><br/>
<a href="https://office.kaz.local">https://office.kaz.local</a><br/>
<a href="https://cloud.kaz.local">https://cloud.kaz.local</a><br/>
<a href="https://agora.kaz.local">https://agora.kaz.local</a><br/>
</html>

162
init.sh

@ -0,0 +1,162 @@
#!/bin/bash
### Personalisation de la VM
cd "$(dirname $0)"
BOLD=''
RED=''
GREEN=''
YELLOW=''
BLUE=''
MAGENTA=''
CYAN=''
NC='' # No Color
NL='
'
mkdir -p ./files/kaz/log/ ./files/kaz/download/ ./files/kaz/git/
chmod a+rxw ./files/kaz/log/ ./files/kaz/download/ ./files/kaz/git/
cp Vagrantfile.dist Vagrantfile
OLD_MEN=$(grep vb.memory Vagrantfile | sed -e 's%.*vb.memory\s*=\s*"\([^"]*\)".*%\1%')
OLD_CUPS=$(grep vb.cpus Vagrantfile | sed -e 's%.*vb.cpus\s*=\s*"\([^"]*\)".*%\1%')
MEM=$(expr $(head -1 /proc/meminfo | awk '{print $2}') / 4096)
CUP=$(expr $(nproc) / 2)
cat <<EOF
${GREEN}${BOLD}
MEM: ${OLD_MEN} => ${MEM}
CUP: ${OLD_CUPS} => ${CUP}
${NC}
Update './Vagrantfile'
EOF
sed -i Vagrantfile \
-e 's%vb.memory\s*=\s*"[^"]*"%vb.memory = "'${MEM}'"%' \
-e 's%vb.cpus\s*=\s*"[^"]*"%vb.cpus = "'${CUP}'"%'
APT_CONF="files/.apt-mirror-config"
if [ -f "${APT_CONF}" ]; then
. "${APT_CONF}"
fi
### Personalisation d'un cache apt
if [ -z "${APT_MIRROR_DEBIAN}" ]; then
APT_MIRROR_DEBIAN=$(grep "deb\s.*/debian[^-]" /etc/apt/sources.list | head -1 | sed -e "s%.*deb\s.*://\([^/]*\)/debian.*%\1%")
fi
if [ -z "${APT_MIRROR_DEBIAN_SECURITY}" ]; then
APT_MIRROR_DEBIAN_SECURITY=$(grep "deb\s.*/debian-security" /etc/apt/sources.list | head -1 | sed -e "s%.*deb\s.*://\([^/]*\)/debian-security.*%\1%")
fi
if [ -z "${APT_MIRROR_UBUNTU}" ]; then
APT_MIRROR_UBUNTU=$(grep "deb\s.*://\([^/]*\)/ubuntu" /etc/apt/sources.list | head -1 | sed -e "s%.*deb\s.*://\([^/]*\)/ubuntu.*%\1%")
fi
if [ -z "${APT_MIRROR_UBUNTU_SECURITY}" ]; then
APT_MIRROR_UBUNTU_SECURITY=$(grep "deb\s.*://\([^/]*\)/ubuntu.*-security" /etc/apt/sources.list | head -1 | sed -e "s%.*deb\s.*://\([^/]*\)/ubuntu.*%\1%")
fi
if [ -z "${APT_MIRROR_UBUNTU}" ]; then
APT_MIRROR_UBUNTU="${APT_MIRROR_DEBIAN}"
fi
if [ -z "${APT_MIRROR_UBUNTU_SECURITY}" ]; then
APT_MIRROR_UBUNTU_SECURITY="${APT_MIRROR_DEBIAN_SECURITY}"
fi
while : ; do
cat <<EOF
${GREEN}${BOLD}
APT_MIRROR_DEBIAN=${APT_MIRROR_DEBIAN}
APT_MIRROR_DEBIAN_SECURITY=${APT_MIRROR_DEBIAN_SECURITY}
APT_MIRROR_UBUNTU=${APT_MIRROR_UBUNTU}
APT_MIRROR_UBUNTU_SECURITY=${APT_MIRROR_UBUNTU_SECURITY}
${NC}
EOF
read -p "Update '${APT_CONF}' (ip:port or y/n)? [no] " proxy
case "${proxy}" in
*:* )
APT_MIRROR_DEBIAN=${proxy}
APT_MIRROR_DEBIAN_SECURITY=${proxy}
APT_MIRROR_UBUNTU=${proxy}
APT_MIRROR_UBUNTU_SECURITY=${proxy}
;;
[YyOo]* )
cat > "${APT_CONF}" <<EOF
# Generated by $(pwd)$(basename $0)
# $(date "+%x %X")
APT_MIRROR_DEBIAN=${APT_MIRROR_DEBIAN}
APT_MIRROR_DEBIAN_SECURITY=${APT_MIRROR_DEBIAN_SECURITY}
APT_MIRROR_UBUNTU=${APT_MIRROR_UBUNTU}
APT_MIRROR_UBUNTU_SECURITY=${APT_MIRROR_UBUNTU_SECURITY}
EOF
break;;
""|[Nn]* ) break;;
* ) echo "Please answer ip:port, yes or no.";;
esac
done
PROXY_CONF="files/.proxy-config"
if [ -f "${PROXY_CONF}" ]; then
FTP_PROXY=$(grep "ftp_proxy" "${PROXY_CONF}" | head -1 | sed -e "s%.*ftp_proxy\s*=\s*.*://\(.*\)%\1%")
HTTP_PROXY=$(grep "http_proxy" "${PROXY_CONF}" | head -1 | sed -e "s%.*http_proxy\s*=\s*.*://\(.*\)%\1%")
HTTPS_PROXY=$(grep "https_proxy" "${PROXY_CONF}" | head -1 | sed -e "s%.*https_proxy\s*=\s*.*://\(.*\)%\1%")
fi
while : ; do
cat <<EOF
${GREEN}${BOLD}
export ftp_proxy=ftp://${FTP_PROXY}
export http_proxy=http://${HTTP_PROXY}
export https_proxy=https://${HTTPS_PROXY}
${NC}
EOF
read -p "proxy in '${PROXY_CONF}' (ip:port, yes or no)? [no] " proxy
case "${proxy}" in
*:* )
FTP_PROXY=${proxy}
HTTP_PROXY=${proxy}
HTTPS_PROXY=${proxy}
;;
[yY]*|[Oo]* )
cat > "${PROXY_CONF}" <<EOF
# Generated by $(pwd)$(basename $0)
# $(date "+%x %X")
export ftp_proxy=ftp://${FTP_PROXY}
export http_proxy=http://${HTTP_PROXY}
export https_proxy=https://${HTTPS_PROXY}
EOF
break;;
""|[Nn]* ) break;;
* ) echo "Please answer ip:port, yes or no.";;
esac
done
CUSTOM_CONF=files/.customDocker.sh
echo
if [ -f "${CUSTOM_CONF}" ]; then
OLD_EDITOR=$(grep install "${CUSTOM_CONF}" | grep "\(joe\|emacs\|vim\)" | head -1 | sed -e "s%.*\(joe\|emacs\|vim\).*%\1%")
fi
while : ; do
read -p "Choose editor in '${CUSTOM_CONF}' (joe, emacs, vim or no)? [${GREEN}${BOLD}${OLD_EDITOR}${NC}] " editor
case "${editor}" in
joe|emacs|vim )
if [ ! -f "${CUSTOM_CONF}" ]; then
echo "#!/bin/bash" > "${CUSTOM_CONF}"
fi
chmod a+x "${CUSTOM_CONF}"
if ! grep -qw "${editor}" "${CUSTOM_CONF}" 2> /dev/null ; then
echo "DEBIAN_FRONTEND=noninteractive apt-get install -y ${editor}" >> "${CUSTOM_CONF}"
echo "rsync -a /vagrant/files/.emacs* /root/" >> "${CUSTOM_CONF}"
fi
break;;
""|[Nn]* ) break;;
* ) echo "Please answer joe, emacs, vim or no.";;
esac
done

29
sparsify.sh

@ -0,0 +1,29 @@
#!/usr/bin/env bash
set -e
# Get HD filename
FILENAME=`vboxmanage showvminfo kaz-dev-amd64 | grep SATA | grep UUID | cut -d':' -f2 | cut -d'(' -f1 | sed -e 's/^[ \t]*//' | sed -e 's/[ \t]*$//'`
# Split the dir and filename
DIR=`dirname "$FILENAME"`
FILE=`basename "$FILENAME"`
# Get HD UUID
UUID=`vboxmanage showvminfo kaz-dev-amd64 | grep SATA | grep UUID | cut -d':' -f 3| cut -d')' -f1 | sed -e 's/^[ \t]*//' | sed -e 's/[ \t]*$//'`
# echo -e $DIR
# echo -e $FILE
# echo -e $UUID
echo "Old disk is at $DIR/$FILE, moving it away to $DIR/old.vmdk..."
mv -v "$DIR/$FILE" "$DIR/old.vmdk"
echo
echo "Creating a new sparsed disk at $DIR/$FILE from $DIR/old.vmdk..."
virt-sparsify "$DIR/old.vmdk" "$DIR/$FILE"
echo
echo "Setting UUID to $UUID..."
vboxmanage internalcommands sethduuid "$DIR/$FILE" $UUID
echo
echo "Old virtual disk has been moved to $DIR/old.vmdk, you can now confirm its deletion"
rm -iv "$DIR/old.vmdk"
Loading…
Cancel
Save