From 9a2adb35a901efea782a46773017aafcd79c1e54 Mon Sep 17 00:00:00 2001 From: Augusto Date: Fri, 19 Apr 2019 17:25:05 +0100 Subject: [PATCH 01/41] reverse range exam exercise --- subjects/reverserange.md | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 subjects/reverserange.md diff --git a/subjects/reverserange.md b/subjects/reverserange.md new file mode 100644 index 00000000..b6c63cd3 --- /dev/null +++ b/subjects/reverserange.md @@ -0,0 +1,25 @@ +# reverserange +## Instructions + +Write the function ReverseRange, it must allocate (with make()) an array of integers, fill it with consecutive +values that begin at end and end at start (Including start and end !), then +return that array. + +This function must be declare as follows + +## Expected function + +```go + +func ReverseRange(start, end int) []int { + +} + +``` + +And its output : + +- With (1, 3) you will return an array containing 3, 2 and 1 +- With (-1, 2) you will return an array containing 2, 1, 0 and -1. +- With (0, 0) you will return an array containing 0. +- With (0, -3) you will return an array containing -3, -2, -1 and 0. \ No newline at end of file From 13f525305d9ccfc3564ec2767323a64cbbc13743 Mon Sep 17 00:00:00 2001 From: Christopher Fremond Date: Thu, 25 Apr 2019 17:14:12 +0100 Subject: [PATCH 02/41] reformatting and correction of title --- subjects/reverserange.en.md | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 subjects/reverserange.en.md diff --git a/subjects/reverserange.en.md b/subjects/reverserange.en.md new file mode 100644 index 00000000..6e3a92b4 --- /dev/null +++ b/subjects/reverserange.en.md @@ -0,0 +1,24 @@ +## reverserange + +### Instructions + +Write the function ReverseRange which must: + +- allocate (with make()) an array of integers. +- fill it with consecutive values that begin at `end` and end at `start` (Including `start` and `end` !) +- finally return that array. + +### Expected function + +```go +func ReverseRange(start, end int) []int { + +} +``` + +Examples of output : + +- With (1, 3) the function will return an array containing 3, 2 and 1. +- With (-1, 2) the function will return an array containing 2, 1, 0 and -1. +- With (0, 0) the function will return an array containing 0. +- With (0, -3) the function will return an array containing -3, -2, -1 and 0. From 91d79279f8e244a5a72fea8c2be7e1bb2ef2a6f1 Mon Sep 17 00:00:00 2001 From: Augusto Date: Fri, 19 Apr 2019 18:30:58 +0100 Subject: [PATCH 03/41] hidden parameter exam exercise --- subjects/hiddenp.md | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 subjects/hiddenp.md diff --git a/subjects/hiddenp.md b/subjects/hiddenp.md new file mode 100644 index 00000000..f18f947e --- /dev/null +++ b/subjects/hiddenp.md @@ -0,0 +1,27 @@ +# hiddenp +## Instructions + +Write a program named hidenp that takes two strings and displays 1 +followed by a newline if the first string is hidden in the second one, +otherwise displays 0 followed by a newline. + +Let s1 and s2 be strings. We say that s1 is hidden in s2 if it's possible to +find each character from s1 in s2, in the same order as they appear in s1. +Also, the empty string is hidden in any string. + +If the number of parameters is not 2, the program displays a newline. + +And its output : + +```console +student@ubuntu:~/student/hiddenp$ go build +student@ubuntu:~/student/hiddenp$ ./hiddenp "fgex.;" "tyf34gdgf;'ektufjhgdgex.;.;rtjynur6" | cat -e +1$ +student@ubuntu:~/student/hiddenp$ ./hiddenp "abc" "2altrb53c.sse" | cat -e +1$ +student@ubuntu:~/student/hiddenp$ ./hiddenp "abc" "btarc" | cat -e +0$ +student@ubuntu:~/student/hiddenp$ ./hiddenp | cat -e +$ +student@ubuntu:~/student/hiddenp$ +``` From 39ebf85d83136cc6bbaf6c0f3d43d06a6d6203db Mon Sep 17 00:00:00 2001 From: Christopher Fremond Date: Thu, 25 Apr 2019 18:17:37 +0100 Subject: [PATCH 04/41] reformatting and correction of title --- subjects/hiddenp.en.md | 28 ++++++++++++++++++++++++++++ subjects/hiddenp.md | 27 --------------------------- 2 files changed, 28 insertions(+), 27 deletions(-) create mode 100644 subjects/hiddenp.en.md delete mode 100644 subjects/hiddenp.md diff --git a/subjects/hiddenp.en.md b/subjects/hiddenp.en.md new file mode 100644 index 00000000..7a71d84e --- /dev/null +++ b/subjects/hiddenp.en.md @@ -0,0 +1,28 @@ +## hiddenp + +### Instructions + +Write a program named hiddenp that takes two strings and that, if the first string is hidden in the second one, displays 1 +followed by a newline, otherwise it displays 0 followed by a newline. + +Let s1 and s2 be strings. It is considered that s1 is hidden in s2 if it is possible to +find each character from s1 in s2, **in the same order as they appear in s1.** + +If s1 is an empty string it is considered hidden in any string. + +If the number of parameters is not 2, the program displays a newline. + +Example of output : + +```console +student@ubuntu:~/student/hiddenp$ go build +student@ubuntu:~/student/hiddenp$ ./hiddenp "fgex.;" "tyf34gdgf;'ektufjhgdgex.;.;rtjynur6" | cat -e +1$ +student@ubuntu:~/student/hiddenp$ ./hiddenp "abc" "2altrb53c.sse" | cat -e +1$ +student@ubuntu:~/student/hiddenp$ ./hiddenp "abc" "btarc" | cat -e +0$ +student@ubuntu:~/student/hiddenp$ ./hiddenp | cat -e +$ +student@ubuntu:~/student/hiddenp$ +``` diff --git a/subjects/hiddenp.md b/subjects/hiddenp.md deleted file mode 100644 index f18f947e..00000000 --- a/subjects/hiddenp.md +++ /dev/null @@ -1,27 +0,0 @@ -# hiddenp -## Instructions - -Write a program named hidenp that takes two strings and displays 1 -followed by a newline if the first string is hidden in the second one, -otherwise displays 0 followed by a newline. - -Let s1 and s2 be strings. We say that s1 is hidden in s2 if it's possible to -find each character from s1 in s2, in the same order as they appear in s1. -Also, the empty string is hidden in any string. - -If the number of parameters is not 2, the program displays a newline. - -And its output : - -```console -student@ubuntu:~/student/hiddenp$ go build -student@ubuntu:~/student/hiddenp$ ./hiddenp "fgex.;" "tyf34gdgf;'ektufjhgdgex.;.;rtjynur6" | cat -e -1$ -student@ubuntu:~/student/hiddenp$ ./hiddenp "abc" "2altrb53c.sse" | cat -e -1$ -student@ubuntu:~/student/hiddenp$ ./hiddenp "abc" "btarc" | cat -e -0$ -student@ubuntu:~/student/hiddenp$ ./hiddenp | cat -e -$ -student@ubuntu:~/student/hiddenp$ -``` From 94355f40474697fb6dab5110d1b2a042aa6634b3 Mon Sep 17 00:00:00 2001 From: Christopher Fremond Date: Thu, 25 Apr 2019 17:23:09 +0100 Subject: [PATCH 05/41] deleting extra file --- subjects/reverserange.md | 25 ------------------------- 1 file changed, 25 deletions(-) delete mode 100644 subjects/reverserange.md diff --git a/subjects/reverserange.md b/subjects/reverserange.md deleted file mode 100644 index b6c63cd3..00000000 --- a/subjects/reverserange.md +++ /dev/null @@ -1,25 +0,0 @@ -# reverserange -## Instructions - -Write the function ReverseRange, it must allocate (with make()) an array of integers, fill it with consecutive -values that begin at end and end at start (Including start and end !), then -return that array. - -This function must be declare as follows - -## Expected function - -```go - -func ReverseRange(start, end int) []int { - -} - -``` - -And its output : - -- With (1, 3) you will return an array containing 3, 2 and 1 -- With (-1, 2) you will return an array containing 2, 1, 0 and -1. -- With (0, 0) you will return an array containing 0. -- With (0, -3) you will return an array containing -3, -2, -1 and 0. \ No newline at end of file From 79b89502038177ab4c089ea40fbfe1031b69fb3d Mon Sep 17 00:00:00 2001 From: Augusto Date: Wed, 24 Apr 2019 12:34:12 +0100 Subject: [PATCH 06/41] reverse string capitalizer exam exercise --- subjects/reversestrcap.md | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 subjects/reversestrcap.md diff --git a/subjects/reversestrcap.md b/subjects/reversestrcap.md new file mode 100644 index 00000000..3ec67321 --- /dev/null +++ b/subjects/reversestrcap.md @@ -0,0 +1,26 @@ +# reversestrcap +## Instructions + +Write a program that takes one or more strings and, for each argument, puts +the last character of each word (if it's a letter) in uppercase and the rest +in lowercase, then displays the result followed by a \n. + +A word is a section of string delimited by spaces/tabs or the start/end of the +string. If a word has a single letter, it must be capitalized. + +If there are no parameters, display \n. + +## Expected output + +```console +student@ubuntu:~/student/reversestrcap$ go build +student@ubuntu:~/student/reversestrcap$ ./reversestrcap "First SMALL TesT" | cat -e +firsT smalL tesT$ +student@ubuntu:~/student/reversestrcap$ ./reversestrcap go run reversestrcap.go "SEconD Test IS a LItTLE EasIEr" "bEwaRe IT'S NoT HARd WhEN " " Go a dernier 0123456789 for the road e" | cat -e +seconD tesT iS A littlE easieR$ +bewarE it'S noT harD wheN $ + gO A dernieR 0123456789 foR thE roaD E$ +student@ubuntu:~/student/reversestrcap$ ./reversestrcap | cat -e +$ +student@ubuntu:~/student/reversestrcap$ +``` From 59c00df372ac7e28ecf90929b786057505b144b0 Mon Sep 17 00:00:00 2001 From: Christopher Fremond Date: Thu, 25 Apr 2019 19:52:16 +0100 Subject: [PATCH 07/41] reformatting and correction of title --- subjects/reversestrcap.en.md | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 subjects/reversestrcap.en.md diff --git a/subjects/reversestrcap.en.md b/subjects/reversestrcap.en.md new file mode 100644 index 00000000..3dc04544 --- /dev/null +++ b/subjects/reversestrcap.en.md @@ -0,0 +1,27 @@ +## reversestrcap + +### Instructions + +Write a program that takes one or more strings and that, **for each argument**: +-puts the last character of each word (if it is a letter) in uppercase and the rest +in lowercase +-then it displays the result followed by a `\n`. + +A word is a sequence of alphanumerical characters. + +If there are no parameters, the program displays a `\n`. + +Examples of outputs : + +```console +student@ubuntu:~/student/reversestrcap$ go build +student@ubuntu:~/student/reversestrcap$ ./reversestrcap "First SMALL TesT" | cat -e +firsT smalL tesT$ +student@ubuntu:~/student/reversestrcap$ ./reversestrcap go run reversestrcap.go "SEconD Test IS a LItTLE EasIEr" "bEwaRe IT'S NoT HARd WhEN " " Go a dernier 0123456789 for the road e" | cat -e +seconD tesT iS A littlE easieR$ +bewarE it'S noT harD wheN $ + gO A dernieR 0123456789 foR thE roaD E$ +student@ubuntu:~/student/reversestrcap$ ./reversestrcap | cat -e +$ +student@ubuntu:~/student/reversestrcap$ +``` From 11e1bf592b74ffa0c1cd862ef0097673d7761cfb Mon Sep 17 00:00:00 2001 From: Christopher Fremond Date: Thu, 25 Apr 2019 19:58:48 +0100 Subject: [PATCH 08/41] deletion of extra file --- subjects/reversestrcap.md | 26 -------------------------- 1 file changed, 26 deletions(-) delete mode 100644 subjects/reversestrcap.md diff --git a/subjects/reversestrcap.md b/subjects/reversestrcap.md deleted file mode 100644 index 3ec67321..00000000 --- a/subjects/reversestrcap.md +++ /dev/null @@ -1,26 +0,0 @@ -# reversestrcap -## Instructions - -Write a program that takes one or more strings and, for each argument, puts -the last character of each word (if it's a letter) in uppercase and the rest -in lowercase, then displays the result followed by a \n. - -A word is a section of string delimited by spaces/tabs or the start/end of the -string. If a word has a single letter, it must be capitalized. - -If there are no parameters, display \n. - -## Expected output - -```console -student@ubuntu:~/student/reversestrcap$ go build -student@ubuntu:~/student/reversestrcap$ ./reversestrcap "First SMALL TesT" | cat -e -firsT smalL tesT$ -student@ubuntu:~/student/reversestrcap$ ./reversestrcap go run reversestrcap.go "SEconD Test IS a LItTLE EasIEr" "bEwaRe IT'S NoT HARd WhEN " " Go a dernier 0123456789 for the road e" | cat -e -seconD tesT iS A littlE easieR$ -bewarE it'S noT harD wheN $ - gO A dernieR 0123456789 foR thE roaD E$ -student@ubuntu:~/student/reversestrcap$ ./reversestrcap | cat -e -$ -student@ubuntu:~/student/reversestrcap$ -``` From 20081821881be3a8d5b853f63918885b9fa237fb Mon Sep 17 00:00:00 2001 From: Augusto Date: Wed, 24 Apr 2019 16:22:16 +0100 Subject: [PATCH 09/41] expand string exam exercise readme --- subjects/expandstr.md | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 subjects/expandstr.md diff --git a/subjects/expandstr.md b/subjects/expandstr.md new file mode 100644 index 00000000..aec0964b --- /dev/null +++ b/subjects/expandstr.md @@ -0,0 +1,28 @@ +## expandstr + +### Instructions + +Write a program that takes a string and displays it with exactly three spaces +between each word, with no spaces or tabs either at the beginning or the end, +followed by a newline. + +A word is a section of string delimited either by spaces/tabs, or by the +start/end of the string. + +If the number of parameters is not 1, or if there are no words, simply display +a newline. + +Example of output : + +```console +student@ubuntu:~/student/expandstr$ go build +student@ubuntu:~/student/expandstr$ ./expandstr "you see it's easy to display the same thing" | cat -e +you see it's easy to display the same thing$ +student@ubuntu:~/student/expandstr$ ./expandstr " only it's harder " | cat -e +only it's harder$ +student@ubuntu:~/student/expandstr$ ./expandstr " how funny it is" "did you hear, Mathilde ?" | cat -e +$ +student@ubuntu:~/student/expandstr$ ./expandstr | cat -e +$ +student@ubuntu:~/student/expandstr$ +``` From 44aadee2c90768671c7beac248e510c41fab3d9b Mon Sep 17 00:00:00 2001 From: Christopher Fremond Date: Thu, 25 Apr 2019 20:09:22 +0100 Subject: [PATCH 10/41] reformatting and correction of title --- subjects/{expandstr.md => expandstr.en.md} | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) rename subjects/{expandstr.md => expandstr.en.md} (75%) diff --git a/subjects/expandstr.md b/subjects/expandstr.en.md similarity index 75% rename from subjects/expandstr.md rename to subjects/expandstr.en.md index aec0964b..62be75bf 100644 --- a/subjects/expandstr.md +++ b/subjects/expandstr.en.md @@ -3,16 +3,16 @@ ### Instructions Write a program that takes a string and displays it with exactly three spaces -between each word, with no spaces or tabs either at the beginning or the end, -followed by a newline. +between each word, with no spaces or tabs at either the beginning nor the end. -A word is a section of string delimited either by spaces/tabs, or by the -start/end of the string. +The string will be followed by a newline. -If the number of parameters is not 1, or if there are no words, simply display +A word is a sequence of alphanumerical characters. + +If the number of parameters is not 1, or if there are no words, the program displays a newline. -Example of output : +Examples of outputs : ```console student@ubuntu:~/student/expandstr$ go build From 8377fed2445bdbb833a37aaaa5282c24f9fa50ff Mon Sep 17 00:00:00 2001 From: Augusto Date: Wed, 24 Apr 2019 17:19:59 +0100 Subject: [PATCH 11/41] parameters counter exam exercise readme --- subjects/paramcount.md | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 subjects/paramcount.md diff --git a/subjects/paramcount.md b/subjects/paramcount.md new file mode 100644 index 00000000..cc93c365 --- /dev/null +++ b/subjects/paramcount.md @@ -0,0 +1,21 @@ +## paramcount + +### Instructions + +Write a program that displays the number of arguments passed to it, followed by +a newline. + +If there are no arguments, just display a 0 followed by a newline. + +Example of output : + +```console +student@ubuntu:~/student/paramcount$ go build +student@ubuntu:~/student/paramcount$ ./paramcount 1 2 3 5 7 24 +6 +student@ubuntu:~/student/paramcount$ ./paramcount 6 12 24 | cat -e +3$ +student@ubuntu:~/student/paramcount$ ./paramcount | cat -e +0$ +student@ubuntu:~/student/paramcount$ +``` From 9f71a71e5672d8827af041018b37e68f012460a7 Mon Sep 17 00:00:00 2001 From: Christopher Fremond Date: Fri, 26 Apr 2019 12:48:02 +0100 Subject: [PATCH 12/41] reformatting and correction of title --- subjects/{paramcount.md => paramcount.en.md} | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename subjects/{paramcount.md => paramcount.en.md} (89%) diff --git a/subjects/paramcount.md b/subjects/paramcount.en.md similarity index 89% rename from subjects/paramcount.md rename to subjects/paramcount.en.md index cc93c365..c11c7171 100644 --- a/subjects/paramcount.md +++ b/subjects/paramcount.en.md @@ -2,12 +2,12 @@ ### Instructions -Write a program that displays the number of arguments passed to it, followed by +Write a program that displays the number of arguments passed to it. This number will be followed by a newline. If there are no arguments, just display a 0 followed by a newline. -Example of output : +Examples of outputs : ```console student@ubuntu:~/student/paramcount$ go build From 8d30c012851da32513f5aa5de046423549d6858d Mon Sep 17 00:00:00 2001 From: Augusto Date: Wed, 24 Apr 2019 18:26:31 +0100 Subject: [PATCH 13/41] itoa --- subjects/itoa.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 subjects/itoa.md diff --git a/subjects/itoa.md b/subjects/itoa.md new file mode 100644 index 00000000..9295201d --- /dev/null +++ b/subjects/itoa.md @@ -0,0 +1,14 @@ +## itoa + +### Instructions + +Write a function that takes an int and converts it to a string. +The function returns the result in a char array that you must allocate. + +## Expected function + +```go +func Itoa(n int) int { + +} +``` \ No newline at end of file From 43c9b48f154997886eaca3d6f0c7ea7fcfbe5e58 Mon Sep 17 00:00:00 2001 From: Christopher Fremond Date: Fri, 26 Apr 2019 16:38:27 +0100 Subject: [PATCH 14/41] remaning and reformating of instructions --- subjects/itoa.en.md | 15 +++++++++++++++ subjects/itoa.md | 14 -------------- 2 files changed, 15 insertions(+), 14 deletions(-) create mode 100644 subjects/itoa.en.md delete mode 100644 subjects/itoa.md diff --git a/subjects/itoa.en.md b/subjects/itoa.en.md new file mode 100644 index 00000000..f613beb4 --- /dev/null +++ b/subjects/itoa.en.md @@ -0,0 +1,15 @@ +## itoa + +### Instructions + +- Write a function that simulates the behaviour of the `Itoa` function in Go. `Itoa` transforms a number represented as an`int` in a number represented as a `string`. + +- For this exercise the handling of the signs + or - **does have** to be taken into account. + +## Expected function + +```go +func Itoa(n int) string { + +} +``` diff --git a/subjects/itoa.md b/subjects/itoa.md deleted file mode 100644 index 9295201d..00000000 --- a/subjects/itoa.md +++ /dev/null @@ -1,14 +0,0 @@ -## itoa - -### Instructions - -Write a function that takes an int and converts it to a string. -The function returns the result in a char array that you must allocate. - -## Expected function - -```go -func Itoa(n int) int { - -} -``` \ No newline at end of file From e10adba2f9f2d95b9f6ec33a4e4b23f463c3d741 Mon Sep 17 00:00:00 2001 From: Frenchris <34804391+Frenchris@users.noreply.github.com> Date: Fri, 26 Apr 2019 19:56:12 +0100 Subject: [PATCH 15/41] Correction of Subject --- subjects/gcd.en.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/subjects/gcd.en.md b/subjects/gcd.en.md index c9e4e30f..b4080384 100644 --- a/subjects/gcd.en.md +++ b/subjects/gcd.en.md @@ -10,6 +10,8 @@ strictly positive integer). If the number of parameters is not 2, display a newline. +All arguments tested will be valid positive `int` values. + Example of output : ```console @@ -24,5 +26,7 @@ student@ubuntu:~/student/gcd$ ./gcd 17 3 | cat -e 1$ student@ubuntu:~/student/gcd$ ./gcd | cat -e $ +student@ubuntu:~/student/gcd$ ./gcd 50 12 4 | cat -e +$ student@ubuntu:~/student/gcd$ ``` From 2a0ae8159c0b41264e9815cf37fc71b05978bd99 Mon Sep 17 00:00:00 2001 From: Louise Foussat Date: Fri, 26 Apr 2019 11:02:32 +0100 Subject: [PATCH 16/41] update modular step doc with new input type countries, better form step example, rename subtypes (to form-step/sign step) --- docs/modular-steps-management.md | 81 ++++++++++++++++++-------------- 1 file changed, 45 insertions(+), 36 deletions(-) diff --git a/docs/modular-steps-management.md b/docs/modular-steps-management.md index ccaf253c..78263f64 100644 --- a/docs/modular-steps-management.md +++ b/docs/modular-steps-management.md @@ -36,7 +36,7 @@ Capture d’écran 2019-04-22 à 15 59 33 -* Add a new key **subtype** of type `String` with the exact value 'onb-adm-form-generator' +* Add a new key **subtype** of type `String` with the exact value 'form-step' * Add a new key **form** of type `Object` * Form can have several sections. Each section is displayed with a title, and its inputs. > NB: The submission of the form will check the required inputs of all the sections created for the form. @@ -48,13 +48,13 @@ > The values will be considered as the properties of your input. #### Defining an input: -* A **type** key of type `String` must be declared. It defines the type of the input : `tel`, `text`, `date`, `select`, `radio`, `switch`, `checkbox`, `textarea` (and soon a special type `countries`). +* A **type** key of type `String` must be declared. It defines the type of the input : `tel`, `text`, `date`, `select`, `radio`, `switch`, `checkbox`, `textarea`, `countries`. * All other attributes needed for the input can be added to the object, according to the input type: `placeholder`, `id`, `required`, `label`, `items`, `emptyItems`, `index`, etc... #### Important indication: * The **index** property is used to order the inputs. It will not be passed onto the input. Be mindful not to set the same index twice. * The **type** property is required. It will be used to determine the kind of input should be generated. It is passed onto the input only if the input type attribute is required (type 'tel' or 'text' for example, but not for type 'select' - in this case, we will generate a select element) - * At the moment, our team is creating a special type 'countries' (a `Select` displaying all the countries). Documentation will be updated as soon as it is available. + * A special type 'countries' has been added to the classicals. It generate a `Select` (containing all the countries) with a search bar. 'Items' property is handled by the app. * `onChange` prop are ignored as the event is handled by the app. * For `switch` and `checkbox` input types, the default value has to be set as a boolean property named **value**. * More information for each inputs is available in the design documentation: @@ -68,74 +68,83 @@ ### Examples Here is an example of the form step's attributes. It presents a form with two sections, and an example of each kind of input type. -> NB : this example object will soon be provided in the admin. +> NB : this example object is provided in the admin, in the onboarding section: 'Form step example'. ```json { - "subtype": "onb-adm-form", + "subtype": "form-step", "form": { "section1": { "title": "My section title", "inputs": { - "firstName": { + "typeText": { "index": 0, - "placeholder": "First name", + "placeholder": "Text placeholder", + "maxLength": 50, "type": "text", "required": true }, - "tel": { + "typeTel": { "index": 1, "required": true, "type": "tel", - "label": "Phone number", + "label": "Tel label", "placeholder": "+333 33 33 33 33", "pattern": "[+][3][0-9]{2}[0-9]{2}[0-9]{2}[0-9]{2}[0-9]{2}" }, - "medicalInfo": { - "label": "Medical informations", - "index": 6, - "placeholder": "Medical Informations", + "typeTextArea": { + "label": "Textarea label", + "index": 7, + "maxLength": 250, + "placeholder": "Textarea placeholder", "type": "textarea" }, - "dateOfBirth": { + "typeDate": { "index": 2, "required": true, "type": "date", - "label": "Date of birth", + "label": "Date label", "value": "2000-01-01" }, - "gender": { + "typeCountries": { + "index": 4, + "id": "countries", + "type": "countries", + "required": true, + "emptyItem": { "label": "Select your country label" } + }, + "typeSelect": { "index": 3, "type": "select", - "id": "genders", + "id": "typeSelect", "required": true, - "emptyItem": { "label": "Select your gender" }, + "emptyItem": { "label": "Special emply item" }, "items": [ - { "label": "Male", "data": "male" }, - { "label": "Female", "data": "female" } + { "label": "Item 1", "data": "item1" }, + { "label": "Item 2", "data": "item2" } ] }, - "environment": { - "index": 4, + "typeRadio": { + "index": 5, "type": "radio", "required": true, - "label": "Which environment do you live in ?", + "label": "Radio label - choose your radio", "inlineBlock": true, "items": [ - { "label": "City", "data": "city" }, - { "label": "Countryside", "data": "countryside" } + { "label": "Radio 1", "data": "radio1" }, + { "label": "Radio 2", "data": "radio2" } ] }, - "programmingAbilities": { - "index": 5, + "typeSwitch": { + "index": 6, "type": "switch", - "label": "I am new in programming", + "label": "Switch label", "value": true }, - "generalConditions": { - "index": 7, + "typeCheckbox": { + "index": 8, "type": "checkbox", - "label": "I have read and I accept the general conditions", + "label": "Checkbox label", "value": false } } @@ -143,9 +152,9 @@ Here is an example of the form step's attributes. It presents a form with two se "section2": { "title": "My second section title", "inputs": { - "firstName": { + "typeText": { "index": 0, - "placeholder": "First name", + "placeholder": "Text placeholder", "type": "text", "required": true } @@ -157,7 +166,7 @@ Here is an example of the form step's attributes. It presents a form with two se This 'form' step would look like this: -![form step example](https://user-images.githubusercontent.com/35296671/56503976-012aae80-650f-11e9-82c8-dd7d026b6eb1.png) +![form step example](https://user-images.githubusercontent.com/35296671/56800060-1a36a680-6812-11e9-9357-28311046641e.png) ## Settings for a `document to sign` step The newly created child can be customized with these attributes : @@ -176,7 +185,7 @@ The newly created child can be customized with these attributes : 1. Edit you step object 2. Go to *Object attributes* 3. Add the following attributes: - * Add a new key **subtype** of type `String` with the exact value 'onb-adm-sign' + * Add a new key **subtype** of type `String` with the exact value 'sign-step' * Add a new key **text** of type `String` with the text of your document to sign as value * Add a new key **buttonText** of type `String` with the text that you want to display in the submit button of your step. Default value for this attribute is 'Sign'. * Add a new key **checkbox** of type `Object`, if the user has to be forced to click on a checkbox before validating his document (ex: 'I have read and accepted the conditions'). In the checkbox object, the following attributes should be defined: @@ -191,7 +200,7 @@ Here is an example of the structure a 'document to sign' step could have: ```json { - "subtype": "onb-adm-sign", + "subtype": "sign-step", "text": "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent ornare non sem eu pretium. Integer porttitor risus eget nibh iaculis, ac lacinia orci dictum. Nunc ullamcorper consequat enim in posuere. Aliquam volutpat est odio, vel maximus arcu maximus sit amet. Donec ultricies faucibus magna id luctus. Duis et dapibus elit. In vestibulum ipsum erat, at commodo tortor convallis vel. Nunc ut ultrices nulla. Etiam lorem justo, consequat a consectetur a, porttitor non turpis. Mauris eu mollis nisl, id dignissim quam. Curabitur condimentum sollicitudin rutrum. Aenean blandit, arcu nec ullamcorper rhoncus, lectus sem lacinia lorem, venenatis dignissim velit mi et sapien. Nullam posuere augue ut magna ullamcorper dignissim. Ut rhoncus sapien vel nulla commodo finibus. Cras non leo vel urna finibus volutpat. Praesent et ex eget diam tincidunt suscipit. Phasellus bibendum neque vel placerat iaculis. Vestibulum bibendum ultrices ipsum, non sodales lectus. Cras eget orci eget elit blandit scelerisque at ut nulla. Integer ligula eros, eleifend quis sodales a, porttitor sit amet neque. Fusce mollis magna at lectus varius, quis suscipit mi cursus. Etiam id imperdiet metus, in malesuada quam. Aliquam facilisis nunc non sapien condimentum, quis iaculis nisl auctor. Nunc lorem sapien, interdum vel efficitur ac, dapibus a diam. Ut ante urna, sodales in bibendum vel, lacinia ut mauris. In vel placerat leo. In libero dui, tincidunt at sem id, faucibus sollicitudin elit.", "buttonText": "Sign chart", "checkbox": { From 0ad9c2919a0562f55948439ac8bbb13afdb0ba38 Mon Sep 17 00:00:00 2001 From: Louise Foussat Date: Fri, 26 Apr 2019 11:08:36 +0100 Subject: [PATCH 17/41] add little warning on type date --- docs/modular-steps-management.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/docs/modular-steps-management.md b/docs/modular-steps-management.md index 78263f64..ac6ed47e 100644 --- a/docs/modular-steps-management.md +++ b/docs/modular-steps-management.md @@ -54,7 +54,8 @@ #### Important indication: * The **index** property is used to order the inputs. It will not be passed onto the input. Be mindful not to set the same index twice. * The **type** property is required. It will be used to determine the kind of input should be generated. It is passed onto the input only if the input type attribute is required (type 'tel' or 'text' for example, but not for type 'select' - in this case, we will generate a select element) - * A special type 'countries' has been added to the classicals. It generate a `Select` (containing all the countries) with a search bar. 'Items' property is handled by the app. + * A special type 'countries' has been added to the classicals. It generate a `Select` (containing all the countries) with a search bar. 'Items' property is handled by the app. + * It's recommended to add 'min' and 'max' properties to input type 'date' (no default value are set). * `onChange` prop are ignored as the event is handled by the app. * For `switch` and `checkbox` input types, the default value has to be set as a boolean property named **value**. * More information for each inputs is available in the design documentation: @@ -103,6 +104,8 @@ Here is an example of the form step's attributes. It presents a form with two se "index": 2, "required": true, "type": "date", + "min": "1621-07-08", + "max": "2019-01-01", "label": "Date label", "value": "2000-01-01" }, From 8bf0bc3e7c12f84b7df56c6fb03136ee3a4cd1f0 Mon Sep 17 00:00:00 2001 From: Louise Foussat Date: Fri, 26 Apr 2019 15:42:51 +0100 Subject: [PATCH 18/41] form step example with concrete data --- docs/modular-steps-management.md | 52 +++++++++++++++++--------------- 1 file changed, 28 insertions(+), 24 deletions(-) diff --git a/docs/modular-steps-management.md b/docs/modular-steps-management.md index ac6ed47e..735e6362 100644 --- a/docs/modular-steps-management.md +++ b/docs/modular-steps-management.md @@ -76,88 +76,92 @@ Here is an example of the form step's attributes. It presents a form with two se "subtype": "form-step", "form": { "section1": { - "title": "My section title", + "title": "Identification", "inputs": { - "typeText": { + "firstName": { "index": 0, - "placeholder": "Text placeholder", + "placeholder": "First name", "maxLength": 50, "type": "text", "required": true }, - "typeTel": { + "tel": { "index": 1, "required": true, "type": "tel", - "label": "Tel label", + "label": "Phone number", "placeholder": "+333 33 33 33 33", "pattern": "[+][3][0-9]{2}[0-9]{2}[0-9]{2}[0-9]{2}[0-9]{2}" }, - "typeTextArea": { - "label": "Textarea label", + "medicalInfo": { + "label": "Medical informations", + "placeholder": "Medical Informations", "index": 7, "maxLength": 250, - "placeholder": "Textarea placeholder", "type": "textarea" }, - "typeDate": { + "dateOfBirth": { "index": 2, "required": true, "type": "date", + "label": "Date of birth", "min": "1621-07-08", - "max": "2019-01-01", - "label": "Date label", + "max": "1900-01-01", "value": "2000-01-01" }, - "typeCountries": { + "country": { "index": 4, "id": "countries", "type": "countries", "required": true, "emptyItem": { "label": "Select your country label" } }, - "typeSelect": { + "gender": { "index": 3, "type": "select", - "id": "typeSelect", + "id": "genders", "required": true, - "emptyItem": { "label": "Special emply item" }, + "emptyItem": { "label": "Select your gender" }, "items": [ + { "label": "Male", "data": "male" }, + { "label": "Female", "data": "female" } { "label": "Item 1", "data": "item1" }, { "label": "Item 2", "data": "item2" } ] }, - "typeRadio": { + "environment": { "index": 5, "type": "radio", "required": true, - "label": "Radio label - choose your radio", + "label": "Which environment do you live in ?", "inlineBlock": true, "items": [ + { "label": "City", "data": "city" }, + { "label": "Countryside", "data": "countryside" } { "label": "Radio 1", "data": "radio1" }, { "label": "Radio 2", "data": "radio2" } ] }, - "typeSwitch": { + "programmingAbilities": { "index": 6, "type": "switch", - "label": "Switch label", + "label": "I am new in programming", "value": true }, - "typeCheckbox": { + "generalConditions": { "index": 8, "type": "checkbox", - "label": "Checkbox label", + "label": "I have read and I accept the general conditions", "value": false } } }, "section2": { - "title": "My second section title", + "title": "More about you", "inputs": { - "typeText": { + "favoriteColor": { "index": 0, - "placeholder": "Text placeholder", + "placeholder": "Your favorite color", "type": "text", "required": true } From 6731e25e42f47c07326ea96a7a16b6cb2c4d738b Mon Sep 17 00:00:00 2001 From: Louise Foussat Date: Fri, 26 Apr 2019 15:52:10 +0100 Subject: [PATCH 19/41] corrections on jsonb --- docs/modular-steps-management.md | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/docs/modular-steps-management.md b/docs/modular-steps-management.md index 735e6362..941eb5ce 100644 --- a/docs/modular-steps-management.md +++ b/docs/modular-steps-management.md @@ -75,7 +75,7 @@ Here is an example of the form step's attributes. It presents a form with two se { "subtype": "form-step", "form": { - "section1": { + "identification": { "title": "Identification", "inputs": { "firstName": { @@ -95,7 +95,7 @@ Here is an example of the form step's attributes. It presents a form with two se }, "medicalInfo": { "label": "Medical informations", - "placeholder": "Medical Informations", + "placeholder": "Your medical Informations", "index": 7, "maxLength": 250, "type": "textarea" @@ -125,8 +125,6 @@ Here is an example of the form step's attributes. It presents a form with two se "items": [ { "label": "Male", "data": "male" }, { "label": "Female", "data": "female" } - { "label": "Item 1", "data": "item1" }, - { "label": "Item 2", "data": "item2" } ] }, "environment": { @@ -138,8 +136,6 @@ Here is an example of the form step's attributes. It presents a form with two se "items": [ { "label": "City", "data": "city" }, { "label": "Countryside", "data": "countryside" } - { "label": "Radio 1", "data": "radio1" }, - { "label": "Radio 2", "data": "radio2" } ] }, "programmingAbilities": { @@ -156,7 +152,7 @@ Here is an example of the form step's attributes. It presents a form with two se } } }, - "section2": { + "moreAboutYou": { "title": "More about you", "inputs": { "favoriteColor": { From 88a976ccd4b00fa8746619180e98d6f40f0bcf81 Mon Sep 17 00:00:00 2001 From: Louise Foussat Date: Fri, 26 Apr 2019 15:54:26 +0100 Subject: [PATCH 20/41] update picture of form step example --- docs/modular-steps-management.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/modular-steps-management.md b/docs/modular-steps-management.md index 941eb5ce..280f6daf 100644 --- a/docs/modular-steps-management.md +++ b/docs/modular-steps-management.md @@ -169,7 +169,7 @@ Here is an example of the form step's attributes. It presents a form with two se This 'form' step would look like this: -![form step example](https://user-images.githubusercontent.com/35296671/56800060-1a36a680-6812-11e9-9357-28311046641e.png) +![form step example](https://user-images.githubusercontent.com/35296671/56816457-7cf06800-683b-11e9-9003-6f83b4545033.png) ## Settings for a `document to sign` step The newly created child can be customized with these attributes : From 1f7435e436f5a1fa392ce972eeae2111325af661 Mon Sep 17 00:00:00 2001 From: Xavier Petit Date: Mon, 29 Apr 2019 02:34:18 +0100 Subject: [PATCH 21/41] Add Ubuntu installation scripts --- scripts/bash_tweaks.sh | 59 ++++++++ scripts/clean.sh | 55 ++++++++ scripts/common_packages.txt | 64 +++++++++ scripts/dconfig.txt | 131 ++++++++++++++++++ scripts/firewall.sh | 15 ++ scripts/fx.sh | 9 ++ scripts/go.sh | 24 ++++ scripts/grub.sh | 25 ++++ scripts/install_client.sh | 89 ++++++++++++ scripts/nodejs.sh | 10 ++ scripts/set.sh | 34 +++++ scripts/ssh.sh | 25 ++++ scripts/sublime.sh | 17 +++ scripts/system/etc/gdm3/PostLogin/Default | 73 ++++++++++ scripts/system/etc/gdm3/PostSession/Default | 25 ++++ .../system/etc/udev/rules.d/10-local.rules | 1 + scripts/system/usr/local/bin/lock_screen | 13 ++ scripts/system/usr/local/bin/suspend_session | 13 ++ .../share/applications/lock_screen.desktop | 8 ++ .../applications/suspend_session.desktop | 8 ++ .../usr/share/initramfs-tools/hooks/copy_mkfs | 22 +++ .../scripts/init-premount/reformat | 20 +++ scripts/ubuntu_tweaks.sh | 116 ++++++++++++++++ scripts/vscode.sh | 35 +++++ 24 files changed, 891 insertions(+) create mode 100755 scripts/bash_tweaks.sh create mode 100755 scripts/clean.sh create mode 100644 scripts/common_packages.txt create mode 100644 scripts/dconfig.txt create mode 100755 scripts/firewall.sh create mode 100755 scripts/fx.sh create mode 100755 scripts/go.sh create mode 100755 scripts/grub.sh create mode 100755 scripts/install_client.sh create mode 100755 scripts/nodejs.sh create mode 100755 scripts/set.sh create mode 100755 scripts/ssh.sh create mode 100755 scripts/sublime.sh create mode 100755 scripts/system/etc/gdm3/PostLogin/Default create mode 100755 scripts/system/etc/gdm3/PostSession/Default create mode 100644 scripts/system/etc/udev/rules.d/10-local.rules create mode 100755 scripts/system/usr/local/bin/lock_screen create mode 100755 scripts/system/usr/local/bin/suspend_session create mode 100644 scripts/system/usr/share/applications/lock_screen.desktop create mode 100644 scripts/system/usr/share/applications/suspend_session.desktop create mode 100755 scripts/system/usr/share/initramfs-tools/hooks/copy_mkfs create mode 100755 scripts/system/usr/share/initramfs-tools/scripts/init-premount/reformat create mode 100755 scripts/ubuntu_tweaks.sh create mode 100755 scripts/vscode.sh diff --git a/scripts/bash_tweaks.sh b/scripts/bash_tweaks.sh new file mode 100755 index 00000000..f876ed3e --- /dev/null +++ b/scripts/bash_tweaks.sh @@ -0,0 +1,59 @@ +#!/bin/bash + +# Configure Terminal + +SCRIPT_DIR="$(cd -P "$(dirname "$BASH_SOURCE")" && pwd)" +cd $SCRIPT_DIR +. set.sh + +# Makes bash case-insensitive +cat <> /etc/inputrc +set completion-ignore-case On +EOF + +# Enhance Linux prompt +cat < /etc/issue +Kernel build: \v +Kernel package: \r +Date: \d \t +IP address: \4 +Terminal: \l@\n.\O + +EOF + +# Enable Bash completion +apt-get -y install bash-completion + +cat <> /etc/bash.bashrc +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 + +# Set-up all users +for DIR in $(ls -1d /root /home/* 2>/dev/null || true) +do + # Hide login informations + touch $DIR/.hushlogin + + # Add convenient aliases & behaviors + cat <<-'EOF'>> $DIR/.bashrc + HISTCONTROL=ignoreboth + export HISTFILESIZE= + export HISTSIZE= + export HISTTIMEFORMAT="%F %T " + alias l="ls $LS_OPTIONS -al --si" + alias df="df --si" + alias du="du -cs --si" + alias free="free -h --si" + alias pstree="pstree -palU" + EOF + + # Fix rights + USR=$(echo "$DIR" | rev | cut -d/ -f1 | rev) + chown -R $USR:$USR $DIR +done diff --git a/scripts/clean.sh b/scripts/clean.sh new file mode 100755 index 00000000..21a0834f --- /dev/null +++ b/scripts/clean.sh @@ -0,0 +1,55 @@ +#!/bin/bash + +# Clean system + +SCRIPT_DIR="$(cd -P "$(dirname "$BASH_SOURCE")" && pwd)" +cd $SCRIPT_DIR +. set.sh + +# Purge useless packages +apt-get -y autoremove --purge +apt-get autoclean +apt-get clean +apt-get install + +rm -rf /root/.local + +# Remove connection logs +> /var/log/lastlog +> /var/log/wtmp +> /var/log/btmp + +# Remove machine ID +> /etc/machine-id + +# Remove logs +cd /var/log +rm -rf alternatives.log* +rm -rf apt/* +rm -rf auth.log +rm -rf dpkg.log* +rm -rf gpu-manager.log +rm -rf installer +rm -rf journal/d6e982aa8c9d4c1dbcbdcff195642300 +rm -rf kern.log +rm -rf syslog +rm -rf sysstat + +# Remove random seeds +rm -rf /var/lib/systemd/random-seed +rm -rf /var/lib/NetworkManager/secret_key + +# Remove network configs +rm -rf /etc/NetworkManager/system-connections/* +rm -rf /var/lib/bluetooth/* +rm -rf /var/lib/NetworkManager/* + +# Remove caches +rm -rf /var/lib/gdm3/.cache/* +rm -rf /root/.cache +rm -rf /home/student/.cache + +rm -rf /home/student/.sudo_as_admin_successful /home/student/.bash_logout + +rm -rf /tmp/* +rm -rf /tmp/.* || true diff --git a/scripts/common_packages.txt b/scripts/common_packages.txt new file mode 100644 index 00000000..2048b823 --- /dev/null +++ b/scripts/common_packages.txt @@ -0,0 +1,64 @@ +apache2-utils +apt-utils +arp-scan +autossh +bash-completion +binutils +build-essential +console-data +console-setup +cron +curl +dialog +dmidecode +dnsutils +file +firmware-linux-nonfree +git +hdparm +iftop +ifupdown +iotop +iptables +iputils-ping +isc-dhcp-client +isc-dhcp-common +jq +less +linux-headers-amd64 +linux-image-amd64 +lm-sensors +locales +lsb-release +lshw +lsof +lzop +man +mc +mdadm +moreutils +nano +net-tools +nmap +ntpdate +nvme-cli +pciutils +psmisc +python +python3 +rsync +rsyslog +ssh +stress +sudo +sysstat +telnet +tig +traceroute +tree +tzdata +unzip +usbutils +wget +zerofree +zip diff --git a/scripts/dconfig.txt b/scripts/dconfig.txt new file mode 100644 index 00000000..3057624f --- /dev/null +++ b/scripts/dconfig.txt @@ -0,0 +1,131 @@ +[org/gnome/desktop/calendar] +show-weekdate=true + +[org/gnome/desktop/wm/preferences] +resize-with-right-button=true + +[org/gnome/desktop/peripherals/keyboard] +delay=uint32 350 + +[desktop/ibus/panel/emoji] +unicode-hotkey=@as [] +hotkey=@as [] + +[org/gnome/desktop/peripherals/touchpad] +two-finger-scrolling-enabled=true +disable-while-typing=false + +[org/gnome/login-screen] +enable-smartcard-authentication=false +enable-fingerprint-authentication=false + +[org/gnome/desktop/privacy] +report-technical-problems=false +remember-recent-files=false + +[org/gnome/desktop/screensaver] +lock-enabled=false + +[org/gnome/desktop/search-providers] +disable-external=true + +[org/gnome/desktop/interface] +gtk-im-module='gtk-im-context-simple' +clock-show-seconds=true +enable-animations=false +cursor-blink=false +clock-show-weekday=true +gtk-theme='Yaru-dark' + +[org/gnome/terminal/legacy] +menu-accelerator-enabled=false + +[org/gnome/desktop/media-handling] +automount-open=false +automount=false +autorun-never=true + +[org/gnome/terminal/legacy/keybindings] +reset-and-clear='l' + +[org/gnome/terminal/legacy/profiles:/:b1dcc9dd-5262-4d8d-a863-c897e6d979b9] +allow-bold=false +default-size-rows=48 +bold-is-bright=true +audible-bell=false +scrollback-lines=2147483647 +cursor-shape='ibeam' +default-size-columns=160 + +[org/gnome/desktop/background] +show-desktop-icons=false + +[org/gnome/desktop/peripherals/mouse] +accel-profile='flat' + +[org/gnome/settings-daemon/plugins/color] +night-light-enabled=true +night-light-schedule-automatic=true + +[org/gnome/desktop/lockdown] +disable-print-setup=true +disable-printing=true +disable-user-switching=true +user-administration-disabled=true + +[org/gnome/settings-daemon/plugins/media-keys] +custom-keybindings=['/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom0/'] +screensaver='' + +[org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom0] +binding='l' +command='lock_screen' +name='Lock screen' + +[org/gnome/settings-daemon/plugins/smartcard] +active=false + +[org/gnome/settings-daemon/plugins/remote-display] +active=false + +[org/gnome/settings-daemon/plugins/sharing] +active=false + +[org/gnome/settings-daemon/plugins/screensaver-proxy] +active=false + +[org/gnome/settings-daemon/plugins/gsdwacom] +active=false + +[org/gnome/settings-daemon/plugins/power] +sleep-inactive-ac-type='nothing' +sleep-inactive-ac-timeout=0 + +[org/gnome/shell] +enable-hot-corners=true +favorite-apps=['firefox.desktop', 'org.gnome.Nautilus.desktop', 'org.gnome.Terminal.desktop', 'sublime_text.desktop', 'vscodium.desktop', 'org.gnome.Calculator.desktop', 'gnome-control-center.desktop', 'org.gnome.tweaks.desktop', 'lock_screen.desktop', 'suspend_session.desktop', 'yelp.desktop'] + +[org/gnome/system/location] +enabled=false + +[org/gnome/desktop/session] +idle-delay=uint32 0 + +[org/gnome/mutter] +center-new-windows=true + +[org/gnome/calculator] +source-currency='' +source-units='degree' +button-mode='advanced' +word-size=64 +show-zeroes=false +base=10 +angle-units='degrees' +accuracy=9 +show-thousands=false +window-position=(1906, 826) +refresh-interval=604800 +target-units='radian' +number-format='fixed' +target-currency='' diff --git a/scripts/firewall.sh b/scripts/firewall.sh new file mode 100755 index 00000000..78f1f66e --- /dev/null +++ b/scripts/firewall.sh @@ -0,0 +1,15 @@ +#!/bin/bash + +# Install firewall + +SCRIPT_DIR="$(cd -P "$(dirname "$BASH_SOURCE")" && pwd)" +cd $SCRIPT_DIR +. set.sh + +SSH_PORT=${1:-521} + +apt-get -y install ufw + +ufw logging off +ufw allow in "$SSH_PORT"/tcp +ufw --force enable diff --git a/scripts/fx.sh b/scripts/fx.sh new file mode 100755 index 00000000..07f724c2 --- /dev/null +++ b/scripts/fx.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +# Install FX: command-line JSON processing tool (https://github.com/antonmedv/fx) + +SCRIPT_DIR="$(cd -P "$(dirname "$BASH_SOURCE")" && pwd)" +cd $SCRIPT_DIR +. set.sh + +npm install -g fx diff --git a/scripts/go.sh b/scripts/go.sh new file mode 100755 index 00000000..d9409459 --- /dev/null +++ b/scripts/go.sh @@ -0,0 +1,24 @@ +#!/bin/bash + +# Install Go + +SCRIPT_DIR="$(cd -P "$(dirname "$BASH_SOURCE")" && pwd)" +cd $SCRIPT_DIR +. set.sh + +apt-get -y install golang + +# Set-up all users +for DIR in $(ls -1d /root /home/* 2>/dev/null || true) +do + # Add convenient aliases & behaviors + cat <<-'EOF'>> $DIR/.bashrc + GOPATH=$HOME/go + PATH=$PATH:$GOPATH/bin + alias gobuild='CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-s -w"' + EOF + + # Fix rights + USR=$(echo "$DIR" | rev | cut -d/ -f1 | rev) + chown -R $USR:$USR $DIR +done diff --git a/scripts/grub.sh b/scripts/grub.sh new file mode 100755 index 00000000..ad767811 --- /dev/null +++ b/scripts/grub.sh @@ -0,0 +1,25 @@ +#!/bin/bash + +# Install Grub + +SCRIPT_DIR="$(cd -P "$(dirname "$BASH_SOURCE")" && pwd)" +cd $SCRIPT_DIR +. set.sh + +DISK=$1 + +apt-get -y install grub-efi-amd64 + +sed -i -e 's/message=/message_null=/g' /etc/grub.d/10_linux + +cat <> /etc/default/grub +GRUB_TIMEOUT=0 +GRUB_RECORDFAIL_TIMEOUT=0 +GRUB_TERMINAL=console +GRUB_DISTRIBUTOR=`` +GRUB_DISABLE_OS_PROBER=true +GRUB_DISABLE_SUBMENU=y +EOF + +update-grub +grub-install $DISK diff --git a/scripts/install_client.sh b/scripts/install_client.sh new file mode 100755 index 00000000..d78c2fc0 --- /dev/null +++ b/scripts/install_client.sh @@ -0,0 +1,89 @@ +#!/bin/bash + +# Configure Z01 client + +# Log stdout & stderr +exec > >(tee -i /tmp/install_client.log) +exec 2>&1 + +SCRIPT_DIR="$(cd -P "$(dirname "$BASH_SOURCE")" && pwd)" +cd $SCRIPT_DIR +. set.sh + +# Set root password +passwd root + +# Remove user password +passwd -d student +cp /etc/shadow /etc/shadow- + +SSH_PORT=521 +DISK=$(lsblk -o tran,kname,hotplug,type,fstype -pr | + grep -e nvme -e sata | + grep '0 disk' | + cut -d' ' -f2 | + sort | + head -n1) + +apt-get update +apt-get -y upgrade +apt-get -y autoremove --purge + +. bash_tweaks.sh +. ssh.sh +. firewall.sh +. ubuntu_tweaks.sh +. grub.sh "$DISK" +. go.sh +. nodejs.sh +. fx.sh +. sublime.sh +. vscode.sh + +# Install additional packages +PKGS=" +emacs +f2fs-tools +golang-mode +vim +xfsprogs +" + +apt-get -y install $PKGS + +# Remove fsck because the system partition will be read-only (overlayroot) +rm /usr/share/initramfs-tools/hooks/fsck + +# Copy system files + +cp -r system /tmp +cd /tmp/system +sed -i -e "s|::DISK::|$DISK|g" etc/udev/rules.d/10-local.rules + +# Fourth local partition +PART=$(lsblk -o tran,kname,hotplug,type,fstype -pr | + grep -v usb | + grep '0 part' | + cut -d' ' -f2 | + sort | + head -n4 | + tail -n1) +sed -i -e "s|::PART::|$PART|g" usr/share/initramfs-tools/scripts/init-premount/reformat + +apt-get -y install overlayroot +echo overlayroot=\"device:dev=$DISK,recurse=0\" >> /etc/overlayroot.conf + +# Fix permissions +find . -type d -exec chmod 755 {} \; +find . -type f -exec chmod 644 {} \; +find . -type f -exec /bin/sh -c "file {} | grep -q 'shell script' && chmod +x {}" \; +cp --preserve=mode -RT . / + +cd $SCRIPT_DIR +rm -rf /tmp/system + +update-initramfs -u + +apt-get -y purge sudo + +. clean.sh diff --git a/scripts/nodejs.sh b/scripts/nodejs.sh new file mode 100755 index 00000000..c08f012a --- /dev/null +++ b/scripts/nodejs.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +# Install Node.js + +SCRIPT_DIR="$(cd -P "$(dirname "$BASH_SOURCE")" && pwd)" +cd $SCRIPT_DIR +. set.sh + +curl -sL https://deb.nodesource.com/setup_10.x | bash - +apt-get -y install nodejs diff --git a/scripts/set.sh b/scripts/set.sh new file mode 100755 index 00000000..690e3018 --- /dev/null +++ b/scripts/set.sh @@ -0,0 +1,34 @@ +#!/bin/bash + +# Set scripting variables + +# Treat unset variables as an error when substituting. +set -u + +# Exit immediately if a command exits with a non-zero status. +set -e + +# Set the variable corresponding to the return value of a pipeline is the status +# of the last command to exit with a non-zero status, or zero if no command +# exited with a non-zero status +set -o pipefail + +# Separate tokens on newlines only +IFS=' +' + +# The value of this parameter is expanded like PS1 and the expanded value is the +# prompt printed before the command line is echoed when the -x option is set +# (see The Set Builtin). The first character of the expanded value is replicated +# multiple times, as necessary, to indicate multiple levels of indirection. +# \D{%F %T} prints date like this : 2019-12-31 23:59:59 +PS4='-\D{%F %T} ' + +# Print commands and their arguments as they are executed. +set -x + +# Skip dialogs during apt-get install commands +export DEBIAN_FRONTEND=noninteractive # DEBIAN_PRIORITY=critical + +export LC_ALL=C LANG=C +export SHELL=/bin/bash diff --git a/scripts/ssh.sh b/scripts/ssh.sh new file mode 100755 index 00000000..3e0a5677 --- /dev/null +++ b/scripts/ssh.sh @@ -0,0 +1,25 @@ +#!/bin/bash + +# Install OpenSSH + +SCRIPT_DIR="$(cd -P "$(dirname "$BASH_SOURCE")" && pwd)" +cd $SCRIPT_DIR +. set.sh + +SSH_PORT=${1:-521} + +# Install dependencies +apt-get -y install ssh + +cat <> /etc/ssh/sshd_config +Port $SSH_PORT +PasswordAuthentication no +AllowUsers root +EOF + +mkdir -p /root/.ssh +chmod -f 700 /root/.ssh +# echo 'ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIH30lZP4V26RVWWvAW91jM7UBSN68+xkuJc5cRionpMc' >> /root/.ssh/authorized_keys +chmod -f 600 /root/.ssh/authorized_keys || true + +systemctl restart sshd.service diff --git a/scripts/sublime.sh b/scripts/sublime.sh new file mode 100755 index 00000000..b79ee4b1 --- /dev/null +++ b/scripts/sublime.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +# Install Sublime Text & Sublime Merge + +SCRIPT_DIR="$(cd -P "$(dirname "$BASH_SOURCE")" && pwd)" +cd $SCRIPT_DIR +. set.sh + +wget -qO - https://download.sublimetext.com/sublimehq-pub.gpg | apt-key add - +apt-get install -y apt-transport-https + +cat < /etc/apt/sources.list.d/sublime-text.list +deb https://download.sublimetext.com/ apt/stable/ +EOF + +apt-get update +apt-get install -y sublime-text sublime-merge libgtk2.0-0 diff --git a/scripts/system/etc/gdm3/PostLogin/Default b/scripts/system/etc/gdm3/PostLogin/Default new file mode 100755 index 00000000..2f709a79 --- /dev/null +++ b/scripts/system/etc/gdm3/PostLogin/Default @@ -0,0 +1,73 @@ +#!/bin/bash + +# Mount home as an overlay filesystem + +# Log stdout & stderr +exec > >(tee -i /tmp/gdm3_postlogin.log) +exec 2>&1 + +# Treat unset variables as an error when substituting. +set -u + +# Exit immediately if a command exits with a non-zero status. +set -e + +# Separate tokens on newlines only +IFS=' +' + +# The value of this parameter is expanded like PS1 and the expanded value is the +# prompt printed before the command line is echoed when the -x option is set +# (see The Set Builtin). The first character of the expanded value is replicated +# multiple times, as necessary, to indicate multiple levels of indirection. +# \D{%F %T} prints date like this : 2019-12-31 23:59:59 +PS4='-\D{%F %T} ' + +# Print commands and their arguments as they are executed. +set -x + +sleep 0.5 + +# Find the first removable F2FS partition +PART=$(lsblk -o tran,kname,hotplug,type,fstype -pr | + grep '1 part f2fs' | + cut -d' ' -f2 | + sort | + head -n1) + +# Make sure the mountpoints are free +( + lsof -t $HOME | xargs kill -9 + umount $HOME + umount /mnt +) || true + +if test "$PART" +then + mount -o noatime "$PART" /mnt +else + # No removable F2FS partition found, use the third local partition instead + PART=$(lsblk -o tran,kname,hotplug,type,fstype -pr | + grep -v usb | + grep '0 part' | + cut -d' ' -f2 | + sort | + head -n3 | + tail -n1) + + if test -z "$PART" + then + # No local partition found, error + exit 1 + fi + + # We don't care about data consistency since the partition is temporary + /sbin/mke2fs -t ext4 -O ^has_journal -F "$PART" + mount -o noatime,nobarrier "$PART" /mnt +fi + +USER_PATH=/mnt/.01/$USER +TEMP_PATH=/mnt/.01/tmp + +mkdir -p $USER_PATH $TEMP_PATH +mount -t overlay -o lowerdir=$HOME,upperdir=$USER_PATH,workdir=$TEMP_PATH overlay $HOME diff --git a/scripts/system/etc/gdm3/PostSession/Default b/scripts/system/etc/gdm3/PostSession/Default new file mode 100755 index 00000000..803df884 --- /dev/null +++ b/scripts/system/etc/gdm3/PostSession/Default @@ -0,0 +1,25 @@ +#!/bin/bash + +# Log stdout & stderr +exec > >(tee -i /tmp/gdm3_postsession.log) +exec 2>&1 + +# Exit immediately if a command exits with a non-zero status. +set -e + +# The value of this parameter is expanded like PS1 and the expanded value is the +# prompt printed before the command line is echoed when the -x option is set +# (see The Set Builtin). The first character of the expanded value is replicated +# multiple times, as necessary, to indicate multiple levels of indirection. +# \D{%F %T} prints date like this : 2019-12-31 23:59:59 +PS4='-\D{%F %T} ' + +# Print commands and their arguments as they are executed. +set -x + +passwd -d $USER +sync +sleep 0.5 +lsof -t $HOME | xargs kill || true +umount -l $HOME +umount -l /mnt diff --git a/scripts/system/etc/udev/rules.d/10-local.rules b/scripts/system/etc/udev/rules.d/10-local.rules new file mode 100644 index 00000000..dc335275 --- /dev/null +++ b/scripts/system/etc/udev/rules.d/10-local.rules @@ -0,0 +1 @@ +KERNEL=="::DISK::*", ENV{UDISKS_IGNORE}="1" diff --git a/scripts/system/usr/local/bin/lock_screen b/scripts/system/usr/local/bin/lock_screen new file mode 100755 index 00000000..d4f63f24 --- /dev/null +++ b/scripts/system/usr/local/bin/lock_screen @@ -0,0 +1,13 @@ +#!/bin/bash + +# Exits if a command fails +set -e + +if passwd -S | grep NP +then + # No password set, so ask user to set one + gnome-terminal.real -t "⁣" --geometry=40x10 --wait -- passwd + sleep 1 +fi + +i3lock -c000000 diff --git a/scripts/system/usr/local/bin/suspend_session b/scripts/system/usr/local/bin/suspend_session new file mode 100755 index 00000000..021e8bf1 --- /dev/null +++ b/scripts/system/usr/local/bin/suspend_session @@ -0,0 +1,13 @@ +#!/bin/bash + +# Exits if a command fails +set -e + +if passwd -S | grep NP +then + # No password set, so ask user to set one + gnome-terminal.real -t "⁣" --geometry=40x10 --wait -- passwd + sleep 1 +fi + +systemctl suspend diff --git a/scripts/system/usr/share/applications/lock_screen.desktop b/scripts/system/usr/share/applications/lock_screen.desktop new file mode 100644 index 00000000..2ff2a328 --- /dev/null +++ b/scripts/system/usr/share/applications/lock_screen.desktop @@ -0,0 +1,8 @@ +[Desktop Entry] +Name=Lock Screen +Comment=Sets a password if needed and then lock screen +Exec=/usr/local/bin/lock_screen +Icon=system-lock-screen +Terminal=false +Type=Application +StartupNotify=true diff --git a/scripts/system/usr/share/applications/suspend_session.desktop b/scripts/system/usr/share/applications/suspend_session.desktop new file mode 100644 index 00000000..4691bf3c --- /dev/null +++ b/scripts/system/usr/share/applications/suspend_session.desktop @@ -0,0 +1,8 @@ +[Desktop Entry] +Name=Suspend session +Comment=Sets a password if needed and then suspend session +Exec=/usr/local/bin/suspend_session +Icon=media-playback-pause +Terminal=false +Type=Application +StartupNotify=true diff --git a/scripts/system/usr/share/initramfs-tools/hooks/copy_mkfs b/scripts/system/usr/share/initramfs-tools/hooks/copy_mkfs new file mode 100755 index 00000000..8f5f117f --- /dev/null +++ b/scripts/system/usr/share/initramfs-tools/hooks/copy_mkfs @@ -0,0 +1,22 @@ +#!/bin/sh + +set -e + +PREREQ="" + +prereqs () { + echo "${PREREQ}" +} + +case "${1}" in + prereqs) + prereqs + exit 0 + ;; +esac + +. /usr/share/initramfs-tools/hook-functions + +copy_exec /sbin/mke2fs /bin + +exit 0 diff --git a/scripts/system/usr/share/initramfs-tools/scripts/init-premount/reformat b/scripts/system/usr/share/initramfs-tools/scripts/init-premount/reformat new file mode 100755 index 00000000..4a04b992 --- /dev/null +++ b/scripts/system/usr/share/initramfs-tools/scripts/init-premount/reformat @@ -0,0 +1,20 @@ +#!/bin/sh + +PREREQ="" +prereqs() +{ + echo "$PREREQ" +} + +case $1 in +prereqs) + prereqs + exit 0 + ;; +esac + +. /scripts/functions + +/bin/mke2fs -F -t ext4 -O ^has_journal ::PART:: > /dev/null 2>&1 + +exit 0 diff --git a/scripts/ubuntu_tweaks.sh b/scripts/ubuntu_tweaks.sh new file mode 100755 index 00000000..bb388b27 --- /dev/null +++ b/scripts/ubuntu_tweaks.sh @@ -0,0 +1,116 @@ +#!/bin/bash + +# Configure ubuntu desktop systems + +SCRIPT_DIR="$(cd -P "$(dirname "$BASH_SOURCE")" && pwd)" +cd "$SCRIPT_DIR" +. set.sh + +# Install dependencies +apt-get -y install lz4 + +# Change ext4 default mount options +sed -i -e 's/ errors=remount-ro/ noatime,nodelalloc,errors=remount-ro/g' /etc/fstab + +# Disable GTK hidden scroll bars +echo GTK_OVERLAY_SCROLLING=0 >> /etc/environment + +# Reveal boot messages +sed -i -e 's/TTYVTDisallocate=yes/TTYVTDisallocate=no/g' /etc/systemd/system/getty.target.wants/getty@tty1.service + +# Speedup boot +sed -i 's/MODULES=most/MODULES=dep/g' /etc/initramfs-tools/initramfs.conf +sed -i 's/COMPRESS=gzip/COMPRESS=lz4/g' /etc/initramfs-tools/initramfs.conf + +# Reveal autostart services +sed -i 's/NoDisplay=true/NoDisplay=false/g' /etc/xdg/autostart/*.desktop + +# Remove password complexity constraints +sed -i 's/ obscure / minlen=1 /g' /etc/pam.d/common-password + +# Remove splash screen (plymouth) and hide kernel output +sed -i 's/quiet splash/quiet vt.global_cursor_default=0 console=ttyS0/g' /etc/default/grub + +update-initramfs -u +update-grub + +# Disable swapfile +swapoff /swapfile || true +rm -f /swapfile +sed -i '/swapfile/d' /etc/fstab + +# Prevent gnome-shell segfault from happening +sed -i 's/#WaylandEnable=false/WaylandEnable=false/g' /etc/gdm3/custom.conf + +# Purge unused Ubuntu packages +PKGS=" +apport +bind9 +bolt +cups* +exim* +friendly-recovery +gnome-initial-setup +gnome-online-accounts +gnome-power-manager +gnome-software +gnome-software-common +memtest86+ +orca +popularity-contest +python3-update-manager +secureboot-db +spice-vdagent +ubuntu-report +ubuntu-software +unattended-upgrades +update-inetd +update-manager-core +update-notifier +update-notifier-common +whoopsie +xdg-desktop-portal +" + +apt-get -y purge $PKGS +apt-get -y autoremove --purge + +SERVICES=" +apt-daily-upgrade.timer +apt-daily.timer +console-setup.service +keyboard-setup.service +motd-news.timer +remote-fs.target +" +systemctl disable $SERVICES + +SERVICES=" +grub-common.service +NetworkManager-wait-online.service +plymouth-quit-wait.service +" +systemctl mask $SERVICES + +# Install packages +PKGS="$(cat common_packages.txt) +baobab +blender +chromium-browser +dconf-editor +firefox +gimp +gnome-calculator +gnome-system-monitor +gnome-tweaks +i3lock +mpv +zenity +" + +# Replace debian packages with ubuntu's +PKGS=${PKGS/linux-image-amd64/linux-image-generic} +PKGS=${PKGS/linux-headers-amd64/linux-headers-generic} +PKGS=${PKGS/firmware-linux-nonfree} + +apt-get -y install $PKGS diff --git a/scripts/vscode.sh b/scripts/vscode.sh new file mode 100755 index 00000000..cd2cd3ab --- /dev/null +++ b/scripts/vscode.sh @@ -0,0 +1,35 @@ +#!/bin/bash + +# Install VSCode + +SCRIPT_DIR="$(cd -P "$(dirname "$BASH_SOURCE")" && pwd)" +cd $SCRIPT_DIR +. set.sh + +wget -qO - https://gitlab.com/paulcarroty/vscodium-deb-rpm-repo/raw/master/pub.gpg | apt-key add - +echo 'deb https://gitlab.com/paulcarroty/vscodium-deb-rpm-repo/raw/repos/debs/ vscodium main' > /etc/apt/sources.list.d/vscodium.list +apt-get update && apt-get -y install vscodium + +# Set-up all users +for DIR in $(ls -1d /home/* 2>/dev/null || true) +do + # Add convenient aliases & behaviors + mkdir -p $DIR/.config/VSCodium/User + cat <<-'EOF'> $DIR/.config/VSCodium/User/settings.json + { + "telemetry.enableCrashReporter": false, + "update.enableWindowsBackgroundUpdates": false, + "update.mode": "none", + "update.showReleaseNotes": false, + "extensions.autoCheckUpdates": false, + "extensions.autoUpdate": false, + "workbench.enableExperiments": false, + "workbench.settings.enableNaturalLanguageSearch": false, + "npm.fetchOnlinePackageInfo": false + } + EOF + + # Fix rights + USR=$(echo "$DIR" | rev | cut -d/ -f1 | rev) + chown -R $USR:$USR $DIR +done From a6edfebefbd5edd5f3e81a8c44094bc3f35f5ce1 Mon Sep 17 00:00:00 2001 From: Xavier Petit Date: Mon, 29 Apr 2019 13:56:54 +0100 Subject: [PATCH 22/41] Fix bug --- scripts/install_client.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/install_client.sh b/scripts/install_client.sh index d78c2fc0..6c6417e2 100755 --- a/scripts/install_client.sh +++ b/scripts/install_client.sh @@ -71,7 +71,7 @@ PART=$(lsblk -o tran,kname,hotplug,type,fstype -pr | sed -i -e "s|::PART::|$PART|g" usr/share/initramfs-tools/scripts/init-premount/reformat apt-get -y install overlayroot -echo overlayroot=\"device:dev=$DISK,recurse=0\" >> /etc/overlayroot.conf +echo overlayroot=\"device:dev=$PART,recurse=0\" >> /etc/overlayroot.conf # Fix permissions find . -type d -exec chmod 755 {} \; From 44dadd114a7ea7175b41acfd78465610a2dc7a99 Mon Sep 17 00:00:00 2001 From: Xavier Petit Date: Mon, 29 Apr 2019 13:57:01 +0100 Subject: [PATCH 23/41] Remove snap applications --- scripts/ubuntu_tweaks.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/ubuntu_tweaks.sh b/scripts/ubuntu_tweaks.sh index bb388b27..c5912d3e 100755 --- a/scripts/ubuntu_tweaks.sh +++ b/scripts/ubuntu_tweaks.sh @@ -60,6 +60,7 @@ orca popularity-contest python3-update-manager secureboot-db +snapd spice-vdagent ubuntu-report ubuntu-software From 5e0512720037a5828014a6a0091ebd6308391727 Mon Sep 17 00:00:00 2001 From: Xavier Petit Date: Mon, 29 Apr 2019 17:33:11 +0100 Subject: [PATCH 24/41] Allow multiple types of F2FS disks --- scripts/system/etc/gdm3/PostLogin/Default | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/system/etc/gdm3/PostLogin/Default b/scripts/system/etc/gdm3/PostLogin/Default index 2f709a79..e39c9950 100755 --- a/scripts/system/etc/gdm3/PostLogin/Default +++ b/scripts/system/etc/gdm3/PostLogin/Default @@ -30,7 +30,7 @@ sleep 0.5 # Find the first removable F2FS partition PART=$(lsblk -o tran,kname,hotplug,type,fstype -pr | - grep '1 part f2fs' | + grep -e '1 part f2fs' -e '1 disk f2fs' | cut -d' ' -f2 | sort | head -n1) From a3ecc56a44aeae803b3f5b4d40ba8d24553b334a Mon Sep 17 00:00:00 2001 From: Xavier Petit Date: Mon, 29 Apr 2019 17:33:50 +0100 Subject: [PATCH 25/41] Do not remove sudo for now --- scripts/install_client.sh | 2 -- 1 file changed, 2 deletions(-) diff --git a/scripts/install_client.sh b/scripts/install_client.sh index 6c6417e2..c5659782 100755 --- a/scripts/install_client.sh +++ b/scripts/install_client.sh @@ -84,6 +84,4 @@ rm -rf /tmp/system update-initramfs -u -apt-get -y purge sudo - . clean.sh From 5347f984af72203227ee9c38e8162b1fbcfd5667 Mon Sep 17 00:00:00 2001 From: Xavier Petit Date: Tue, 30 Apr 2019 13:35:06 +0100 Subject: [PATCH 26/41] Fix home folder rights --- scripts/system/etc/gdm3/PostLogin/Default | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/system/etc/gdm3/PostLogin/Default b/scripts/system/etc/gdm3/PostLogin/Default index e39c9950..d0fa55e0 100755 --- a/scripts/system/etc/gdm3/PostLogin/Default +++ b/scripts/system/etc/gdm3/PostLogin/Default @@ -70,4 +70,5 @@ USER_PATH=/mnt/.01/$USER TEMP_PATH=/mnt/.01/tmp mkdir -p $USER_PATH $TEMP_PATH +chown -R $USER:$USER $USER_PATH $TEMP_PATH mount -t overlay -o lowerdir=$HOME,upperdir=$USER_PATH,workdir=$TEMP_PATH overlay $HOME From db60da7cdca81b2b9e71d6fe7da1070fc2ed81e7 Mon Sep 17 00:00:00 2001 From: Xavier Petit Date: Tue, 30 Apr 2019 22:05:52 +0100 Subject: [PATCH 27/41] Ignore chown failure --- scripts/bash_tweaks.sh | 2 +- scripts/go.sh | 2 +- scripts/vscode.sh | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/bash_tweaks.sh b/scripts/bash_tweaks.sh index f876ed3e..88ec69e1 100755 --- a/scripts/bash_tweaks.sh +++ b/scripts/bash_tweaks.sh @@ -55,5 +55,5 @@ do # Fix rights USR=$(echo "$DIR" | rev | cut -d/ -f1 | rev) - chown -R $USR:$USR $DIR + chown -R $USR:$USR $DIR || true done diff --git a/scripts/go.sh b/scripts/go.sh index d9409459..c3a27a4a 100755 --- a/scripts/go.sh +++ b/scripts/go.sh @@ -20,5 +20,5 @@ do # Fix rights USR=$(echo "$DIR" | rev | cut -d/ -f1 | rev) - chown -R $USR:$USR $DIR + chown -R $USR:$USR $DIR || true done diff --git a/scripts/vscode.sh b/scripts/vscode.sh index cd2cd3ab..ddc5292a 100755 --- a/scripts/vscode.sh +++ b/scripts/vscode.sh @@ -31,5 +31,5 @@ do # Fix rights USR=$(echo "$DIR" | rev | cut -d/ -f1 | rev) - chown -R $USR:$USR $DIR + chown -R $USR:$USR $DIR || true done From 3423c62d00266b69ca3d6a4aa03946cb44ddd9f2 Mon Sep 17 00:00:00 2001 From: Xavier Petit Date: Tue, 30 Apr 2019 22:07:16 +0100 Subject: [PATCH 28/41] Fix comment --- scripts/vscode.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/vscode.sh b/scripts/vscode.sh index ddc5292a..43728442 100755 --- a/scripts/vscode.sh +++ b/scripts/vscode.sh @@ -13,7 +13,7 @@ apt-get update && apt-get -y install vscodium # Set-up all users for DIR in $(ls -1d /home/* 2>/dev/null || true) do - # Add convenient aliases & behaviors + # Disable most of the telemetry and auto-updates mkdir -p $DIR/.config/VSCodium/User cat <<-'EOF'> $DIR/.config/VSCodium/User/settings.json { From c5dd0a98078ecc8ee6187e34f321121a6867a163 Mon Sep 17 00:00:00 2001 From: Xavier Petit Date: Tue, 30 Apr 2019 23:58:11 +0100 Subject: [PATCH 29/41] Add doc --- docs/ubuntu-installation.md | 64 +++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 docs/ubuntu-installation.md diff --git a/docs/ubuntu-installation.md b/docs/ubuntu-installation.md new file mode 100644 index 00000000..9799cadf --- /dev/null +++ b/docs/ubuntu-installation.md @@ -0,0 +1,64 @@ +# Ubuntu + +## OS Installation + +Download and boot the [last Ubuntu release](http://releases.ubuntu.com/19.04/ubuntu-19.04-desktop-amd64.iso). + +Follow the steps : + +![img1](https://user-images.githubusercontent.com/32063953/56804679-85867580-681e-11e9-8965-e87c6a89fac0.png) +![img2](https://user-images.githubusercontent.com/32063953/56963599-3eb3bb00-6b51-11e9-9778-4f3bb9993c74.png) +![img3](https://user-images.githubusercontent.com/32063953/56963600-3eb3bb00-6b51-11e9-94cc-279406f37def.png) + +The partitioning is : + +- 256 MB : EFI partition +- 20 GB : system partition +- 32 GB : unused partition (will be used later) +- rest : unused partition (will be used later) + +![img4](https://user-images.githubusercontent.com/32063953/56963602-3eb3bb00-6b51-11e9-8977-38e4e67d6ce1.png) +![img5](https://user-images.githubusercontent.com/32063953/56963603-3f4c5180-6b51-11e9-9349-46ab90287691.png) +![img6](https://user-images.githubusercontent.com/32063953/56963604-3f4c5180-6b51-11e9-8df2-5016771e6e07.png +) + +Remove the installation disk and then reboot. + +Skip the welcoming window. + +Don't install updates if Ubuntu asks to. The scripts will. + +![img8](https://user-images.githubusercontent.com/32063953/56804701-8d461a00-681e-11e9-8825-dfc69f8268bf.png) +![img9](https://user-images.githubusercontent.com/32063953/56804703-8d461a00-681e-11e9-840c-498ccab7d911.png) +![img10](https://user-images.githubusercontent.com/32063953/56804704-8ddeb080-681e-11e9-96ff-6c8783c5aacc.png) +![img11](https://user-images.githubusercontent.com/32063953/56804706-8ddeb080-681e-11e9-85e1-20c5b6956a36.png) + +## OS configuration + +```shell +student@tmp-hostname:~$ wget github.com/01-edu/public/archive/master.zip +student@tmp-hostname:~$ unzip master.zip +student@tmp-hostname:~$ cd public-master/scripts +student@tmp-hostname:~$ sudo ./install_client.sh +[...] +Ask for student user password (will be removed later) +[...] +Ask to set the root password +[...] +Long installation/configuration process +[...] +student@tmp-hostname:~$ cat dconfig.txt | dconf load / +student@tmp-hostname:~$ reboot +``` + +The system is now read-only, every data is written to a temporary partition. + +The session is password-less. + +To gain a superuser terminal with read/write access to the filesystem, type these commands: + +```shell +student@tmp-hostname:~$ su - +Password: +root@tmp-hostname:~# overlayroot-chroot +``` From f101c3990d0fc4d3530ec838f254280fda63346e Mon Sep 17 00:00:00 2001 From: Xavier Petit Date: Tue, 30 Apr 2019 23:58:22 +0100 Subject: [PATCH 30/41] Add useless package to purge --- scripts/ubuntu_tweaks.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/ubuntu_tweaks.sh b/scripts/ubuntu_tweaks.sh index c5912d3e..a1d4e139 100755 --- a/scripts/ubuntu_tweaks.sh +++ b/scripts/ubuntu_tweaks.sh @@ -49,6 +49,7 @@ bind9 bolt cups* exim* +fprintd friendly-recovery gnome-initial-setup gnome-online-accounts From be9a68fd3b2263983bb7e7edfdfdbd128aade7d3 Mon Sep 17 00:00:00 2001 From: Frenchris <34804391+Frenchris@users.noreply.github.com> Date: Sat, 27 Apr 2019 00:34:30 +0100 Subject: [PATCH 31/41] Trnaslation update --- subjects/doop.fr.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/subjects/doop.fr.md b/subjects/doop.fr.md index 8acbf79e..904d0217 100644 --- a/subjects/doop.fr.md +++ b/subjects/doop.fr.md @@ -10,10 +10,12 @@ Le programme doit être utilisé avec trois arguments: - Un opérateur - Une autre valeur -En cas d'argument invalide le programme affiche `0`. +En cas d'opérateur invalide le programme affiche `0`. En cas de nombre invalide d'arguments le programme affiche rien. +Le programme doit géré les opérations modulo et division par 0 comme dans les examples ci-dessous. + `fmt.Print` est autorisé. ### Utilisation @@ -23,8 +25,8 @@ student@ubuntu:~/piscine/test$ go build doop.go student@ubuntu:~/piscine/test$ ./doop student@ubuntu:~/piscine/test$ ./doop 1 + 1 2 -student@ubuntu:~/piscine/test$ ./doop hello + 1 -0 +student@ubuntu:~/piscine/test$ ./doop hello + 1 | cat -e +0$ student@ubuntu:~/piscine/test$ ./doop 1 p 1 0 student@ubuntu:~/piscine/test$ ./doop 1 + 1 From 3f984dd76ef901fe27d93b18511c61cd794a71de Mon Sep 17 00:00:00 2001 From: Frenchris <34804391+Frenchris@users.noreply.github.com> Date: Thu, 2 May 2019 15:10:02 +0100 Subject: [PATCH 32/41] formating --- subjects/{addprimesum.md => addprimesum.en.md} | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) rename subjects/{addprimesum.md => addprimesum.en.md} (71%) diff --git a/subjects/addprimesum.md b/subjects/addprimesum.en.md similarity index 71% rename from subjects/addprimesum.md rename to subjects/addprimesum.en.md index 344cf856..baa1cf9a 100644 --- a/subjects/addprimesum.md +++ b/subjects/addprimesum.en.md @@ -4,9 +4,9 @@ Write a program that takes a positive integer as argument and displays the sum of all prime numbers inferior or equal to it followed by a newline. -- If the number of arguments is not 1, or the argument is not a positive number, just display 0 followed by a newline. +- If the number of arguments is not 1, or if the argument is not a positive number, the program displays 0 followed by a newline. -Example of output : +Examples of outputs : ```console student@ubuntu:~/piscine/test$ go build @@ -17,4 +17,4 @@ student@ubuntu:~/piscine/test$ ./test 7 student@ubuntu:~/piscine/test$ ./test 57 0 student@ubuntu:~/piscine/test$ -``` \ No newline at end of file +``` From 89126087669bc4ff5851b38365448367423067ff Mon Sep 17 00:00:00 2001 From: Frenchris <34804391+Frenchris@users.noreply.github.com> Date: Thu, 2 May 2019 15:12:19 +0100 Subject: [PATCH 33/41] Formatting --- subjects/{doop.md => doop.en.md} | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) rename subjects/{doop.md => doop.en.md} (65%) diff --git a/subjects/doop.md b/subjects/doop.en.md similarity index 65% rename from subjects/doop.md rename to subjects/doop.en.md index 5fbbe91d..eb6abf9c 100644 --- a/subjects/doop.md +++ b/subjects/doop.en.md @@ -4,15 +4,15 @@ Write a program that takes three strings: -- The first and the third one are representations of base-10 signed integers that fit in an int. +- The first and the third one are representations of base-10 signed integers that fit in an int. - The second one is an arithmetic operator chosen from: `+ - * / %` - The program must display the result of the requested arithmetic operation, followed by a newline. If the number of parameters is not 3, the program just displays a newline. -- You can assume the string have no mistakes or extraneous characters. Negative numbers, in input or output, will have one and only one leading `-`. The result of the operation fits in an int. +- During tests the strings will have no mistakes or extraneous characters. Negative numbers, in input or output, will have one and only one leading `-`. The result of the operation will fit in an int. -Example of output : +Examples of outputs : ```console student@ubuntu:~/piscine/test$ go build @@ -25,4 +25,4 @@ student@ubuntu:~/piscine/test$ ./test "10" "+" "-43" student@ubuntu:~/piscine/test$ ./test student@ubuntu:~/piscine/test$ -``` \ No newline at end of file +``` From 564e9f6ee467a58ca23938fa8ba21efed46e99ec Mon Sep 17 00:00:00 2001 From: Frenchris <34804391+Frenchris@users.noreply.github.com> Date: Thu, 2 May 2019 15:13:15 +0100 Subject: [PATCH 34/41] Formating --- subjects/{printhex.md => printhex.en.md} | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) rename subjects/{printhex.md => printhex.en.md} (78%) diff --git a/subjects/printhex.md b/subjects/printhex.en.md similarity index 78% rename from subjects/printhex.md rename to subjects/printhex.en.md index f3b1d14a..efe74562 100644 --- a/subjects/printhex.md +++ b/subjects/printhex.en.md @@ -2,11 +2,11 @@ ### Instructions -Write a program that takes a positive (or zero) number expressed in base 10, and displays it in base 16 (lowercase letters) followed by a newline. +Write a program that takes a positive (or zero) number expressed in base 10, and displays it in base 16 ( with lowercase letters) followed by a newline. - If the number of parameters is not 1, the program displays a newline. -Example of output : +Examples of outputs : ```console student@ubuntu:~/piscine/test$ go build @@ -19,4 +19,4 @@ student@ubuntu:~/piscine/test$ ./test "5156454" student@ubuntu:~/piscine/test$ student@ubuntu:~/piscine/ -``` \ No newline at end of file +``` From ff60cfcf97c48ea587a71650f3e6a50ac332f78c Mon Sep 17 00:00:00 2001 From: Frenchris <34804391+Frenchris@users.noreply.github.com> Date: Thu, 2 May 2019 15:16:16 +0100 Subject: [PATCH 35/41] formating --- subjects/range.en.md | 24 ++++++++++++++++++++++++ subjects/range.md | 20 -------------------- 2 files changed, 24 insertions(+), 20 deletions(-) create mode 100644 subjects/range.en.md delete mode 100644 subjects/range.md diff --git a/subjects/range.en.md b/subjects/range.en.md new file mode 100644 index 00000000..babd2cfc --- /dev/null +++ b/subjects/range.en.md @@ -0,0 +1,24 @@ +## range + +### Instructions + +Write the function Range which must: + +- allocate (with make()) an array of integers. +- fill it with consecutive values that begin at `start` and end at `end` (Including `start` and `end` !) +- finally return that array. + +### Expected function + +```go +func Range(start, end int) []int { + +} +``` + +Examples of outputs : + +- With (1, 3) you will return an array containing 1, 2 and 3. +- With (-1, 2) you will return an array containing -1, 0, 1 and 2. +- With (0, 0) you will return an array containing 0. +- With (0, -3) you will return an array containing 0, -1, -2 and -3. diff --git a/subjects/range.md b/subjects/range.md deleted file mode 100644 index fd4fdd6d..00000000 --- a/subjects/range.md +++ /dev/null @@ -1,20 +0,0 @@ -## range - -### Instructions - -Write the following functions : - -```go -func Range(start, end int) []int{ - -} -``` - -It must allocate (with malloc()) an array of integers, fill it with consecutive values that begin at start and end at end (Including start and end !), then return a pointer to the first value of the array. - -Example of output : - -- With (1, 3) you will return an array containing 1, 2 and 3. -- With (-1, 2) you will return an array containing -1, 0, 1 and 2. -- With (0, 0) you will return an array containing 0. -- With (0, -3) you will return an array containing 0, -1, -2 and -3. \ No newline at end of file From c2603e89c88f8b2bf6e7e512c6dd3437a46efd68 Mon Sep 17 00:00:00 2001 From: Frenchris <34804391+Frenchris@users.noreply.github.com> Date: Thu, 2 May 2019 15:22:56 +0100 Subject: [PATCH 36/41] Formatting --- subjects/{sortlist.md => sortlist.en.md} | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) rename subjects/{sortlist.md => sortlist.en.md} (52%) diff --git a/subjects/sortlist.md b/subjects/sortlist.en.md similarity index 52% rename from subjects/sortlist.md rename to subjects/sortlist.en.md index 7dd66379..ef3c81ad 100644 --- a/subjects/sortlist.md +++ b/subjects/sortlist.en.md @@ -14,17 +14,17 @@ func SortList(l *node, func cmp(a,b int) bool) *node{ } ``` -This function must sort the list given as a parameter, using the function `cmp` to select the order to apply, and returns a pointer to the first element of the sorted list. +This function must sort the list given as a parameter using the function `cmp` to select the order to apply. It must then return a pointer to the first element of the sorted list. - Duplications must remain. -- Inputs will always be consistet. +- Inputs will always be consistent. -- You must use the type `Node` +- The type `Node` must be used. -- Functions passed as `cmp` will always return a boolean. If `a` and `b` are in the rigth order it returns `true`, otherwise it returns `false`. +- Functions passed as `cmp` will always return a boolean. If `a` and `b` are in the right order it returns `true`, otherwise it returns `false`. -- For example, the following function used as cmp will sort the list in ascending order : +- For example; the following function used as cmp will sort the list in ascending order : ```go func ascending(a, b int) { @@ -34,4 +34,4 @@ func ascending(a, b int) { return false } } -``` \ No newline at end of file +``` From 895396aeec1e3e5c6fafdef2fff2e82ce8c3140a Mon Sep 17 00:00:00 2001 From: Frenchris <34804391+Frenchris@users.noreply.github.com> Date: Thu, 2 May 2019 15:23:38 +0100 Subject: [PATCH 37/41] Formatting --- subjects/tabmult.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/subjects/tabmult.md b/subjects/tabmult.md index 2b3156c2..ae738db6 100644 --- a/subjects/tabmult.md +++ b/subjects/tabmult.md @@ -6,7 +6,7 @@ Write a program that displays a number's multiplication table. - The parameter will always be a strictly positive number that fits in an int, and said number times 9 will also fit in an int. -Example of output : +Examples of outputs : ```console student@ubuntu:~/piscine/test$ go build @@ -33,4 +33,4 @@ student@ubuntu:~/piscine/test$ ./test 19 student@ubuntu:~/piscine/test$ student@ubuntu:~/piscine/ -``` \ No newline at end of file +``` From 52a71d5facc1bb100ec84760d5dca0a35adcf6a2 Mon Sep 17 00:00:00 2001 From: Augusto Date: Thu, 2 May 2019 18:08:58 +0100 Subject: [PATCH 38/41] brainfuck exam exercise readme --- subjects/brainfuck.en.md | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 subjects/brainfuck.en.md diff --git a/subjects/brainfuck.en.md b/subjects/brainfuck.en.md new file mode 100644 index 00000000..896dd633 --- /dev/null +++ b/subjects/brainfuck.en.md @@ -0,0 +1,34 @@ +## brainfuck + +### Instructions + +Write a Brainfuck interpreter program. +The source code will be given as first parameter. +The code will always be valid, with no more than 4096 operations. +Brainfuck is a minimalist language. It consists of an array of bytes +(in our case, let's say 2048 bytes) initialized to zero, +and a pointer to its first byte. + +Every operator consists of a single character : +- '>' increment the pointer ; +- '<' decrement the pointer ; +- '+' increment the pointed byte ; +- '-' decrement the pointed byte ; +- '.' print the pointed byte on standard output ; +- '[' go to the matching ']' if the pointed byte is 0 (while start) ; +- ']' go to the matching '[' if the pointed byte is not 0 (while end). + +Any other character is a comment. + +And its output : + +```console +student@ubuntu:~/student/brainfuck$ go build +student@ubuntu:~/student/brainfuck$ ./brainfuck "++++++++++[>+++++++>++++++++++>+++>+<<<<-]>++.>+.+++++++..+++.>++.<<+++++++++++++++.>.+++.------.--------.>+.>." | cat -e +Hello World!$ +student@ubuntu:~/student/brainfuck$ ./brainfuck "+++++[>++++[>++++H>+++++i<<-]>>>++\n<<<<-]>>--------.>+++++.>." | cat -e +Hi$ +student@ubuntu:~/student/brainfuck$ ./brainfuck | cat -e +$ +student@ubuntu:~/student/brainfuck$ +``` From 3ea5759fbc8bbec7bd004a26dcba1a6cde445d70 Mon Sep 17 00:00:00 2001 From: Christopher Fremond Date: Fri, 3 May 2019 15:19:32 +0100 Subject: [PATCH 39/41] one example added --- subjects/brainfuck.en.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/subjects/brainfuck.en.md b/subjects/brainfuck.en.md index 896dd633..8964585b 100644 --- a/subjects/brainfuck.en.md +++ b/subjects/brainfuck.en.md @@ -10,6 +10,7 @@ Brainfuck is a minimalist language. It consists of an array of bytes and a pointer to its first byte. Every operator consists of a single character : + - '>' increment the pointer ; - '<' decrement the pointer ; - '+' increment the pointed byte ; @@ -20,7 +21,7 @@ Every operator consists of a single character : Any other character is a comment. -And its output : +Examples of outputs : ```console student@ubuntu:~/student/brainfuck$ go build @@ -28,6 +29,8 @@ student@ubuntu:~/student/brainfuck$ ./brainfuck "++++++++++[>+++++++>++++++++++> Hello World!$ student@ubuntu:~/student/brainfuck$ ./brainfuck "+++++[>++++[>++++H>+++++i<<-]>>>++\n<<<<-]>>--------.>+++++.>." | cat -e Hi$ +student@ubuntu:~/student/brainfuck$ ./brainfuck "++++++++++[>++++++++++>++++++++++>++++++++++<<<-]>---.>--.>-.>++++++++++." | cat -e +abc$ student@ubuntu:~/student/brainfuck$ ./brainfuck | cat -e $ student@ubuntu:~/student/brainfuck$ From cdfc5fbf24d2ee196d52cb1a2f3fd996c40c1099 Mon Sep 17 00:00:00 2001 From: Augusto Date: Fri, 3 May 2019 11:45:02 +0100 Subject: [PATCH 40/41] itoabase exam exercise readme --- subjects/itoabase.en.md | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 subjects/itoabase.en.md diff --git a/subjects/itoabase.en.md b/subjects/itoabase.en.md new file mode 100644 index 00000000..fe4348bf --- /dev/null +++ b/subjects/itoabase.en.md @@ -0,0 +1,23 @@ +## itoabase + +### Instructions + +Write a function that converts an integer value to a null-terminated string +using the specified base and stores the result in a char array that you must +allocate. + +The base is expressed as an integer, from 2 to 16. The characters comprising +the base are the digits from 0 to 9, followed by uppercase letter from A to F. + +For example, base 4 would be "0123" and base 16 "0123456789ABCDEF". + +If base is 10 and value is negative, the resulting string is preceded with a +minus sign (-). With any other base, value is always considered unsigned. + +### Expected function + +```go +func ItoaBase(value, base int) string { + +} +``` \ No newline at end of file From bb09f688931fe05858198895826f0bc9aadd48db Mon Sep 17 00:00:00 2001 From: Christopher Fremond Date: Fri, 3 May 2019 16:24:11 +0100 Subject: [PATCH 41/41] formatting --- subjects/itoabase.en.md | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/subjects/itoabase.en.md b/subjects/itoabase.en.md index fe4348bf..2a1040ed 100644 --- a/subjects/itoabase.en.md +++ b/subjects/itoabase.en.md @@ -2,17 +2,18 @@ ### Instructions -Write a function that converts an integer value to a null-terminated string -using the specified base and stores the result in a char array that you must -allocate. +Write a function that: + +- converts an integer value to a string using the specified base in the argument +- and then returns this string The base is expressed as an integer, from 2 to 16. The characters comprising -the base are the digits from 0 to 9, followed by uppercase letter from A to F. +the base are the digits from 0 to 9, followed by uppercase letters from A to F. -For example, base 4 would be "0123" and base 16 "0123456789ABCDEF". +For example, the base `4` would be the equivalent of "0123" and the base `16` would be the equivalent of "0123456789ABCDEF". -If base is 10 and value is negative, the resulting string is preceded with a -minus sign (-). With any other base, value is always considered unsigned. +If the value is negative, the resulting string has to be preceded with a +minus sign `-`. ### Expected function @@ -20,4 +21,4 @@ minus sign (-). With any other base, value is always considered unsigned. func ItoaBase(value, base int) string { } -``` \ No newline at end of file +```