From 550479613d4b87a26378b49007f9334dd088f81b Mon Sep 17 00:00:00 2001 From: Youngjin Han Date: Mon, 27 Apr 2020 20:49:10 +0900 Subject: [PATCH 01/35] Initail Commit --- youngjin.han/learnig.org | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 youngjin.han/learnig.org diff --git a/youngjin.han/learnig.org b/youngjin.han/learnig.org new file mode 100644 index 0000000..4875fb0 --- /dev/null +++ b/youngjin.han/learnig.org @@ -0,0 +1,4 @@ +learnig MY PROJECT -*- mode: org -*- + +* 2020-04-10 +** ungleich learing circle From 7e86b3ac4f00ee480202e1bab88e5f1042532d6a Mon Sep 17 00:00:00 2001 From: Youngjin Han Date: Fri, 1 May 2020 23:32:09 +0900 Subject: [PATCH 02/35] Learning Circle : Lecture 5 --- youngjin.han/learning-node02-2020.org | 59 +++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 youngjin.han/learning-node02-2020.org diff --git a/youngjin.han/learning-node02-2020.org b/youngjin.han/learning-node02-2020.org new file mode 100644 index 0000000..0985a88 --- /dev/null +++ b/youngjin.han/learning-node02-2020.org @@ -0,0 +1,59 @@ +*** Organisation #5: Emacs refresher +**** Lecture content +***** Objective: get confident with emacs commands +***** Find out and document how to do the following steps +****** DONE Search for something forward C-s + CLOSED: [2020-05-01 금 21:40] +****** DONE How to continue searching C-s C-s + CLOSED: [2020-05-01 금 21:43] +****** DONE Search for something backward C-r + CLOSED: [2020-05-01 금 21:55] +****** DONE Search for regular expressions instead of string (forward, backward) C-M-s C-M-r + CLOSED: [2020-05-01 금 22:25] +****** DONE Go to the beginning of the line C-a + CLOSED: [2020-05-01 금 22:16] +****** DONE Go to the end of the line C-e + CLOSED: [2020-05-01 금 22:16] +****** DONE Delete a word in front (to the right of the cursor) M-d + CLOSED: [2020-05-01 금 22:17] +****** DONE Delete a word in back (to the left of the cursor) M-BackSpace + CLOSED: [2020-05-01 금 22:18] +****** DONE List all "occurences" of a word in a file M-s o + CLOSED: [2020-05-01 금 22:53] +******* You can copy above instructions into an emacs buffer +******* And test it by showing all occurences of the word "Search" +****** DONE Search (GREP) for a word in all files in a directory RECURSIVELY M-x rgrep + CLOSED: [2020-05-01 금 22:46] +****** DONE Save the CURRENT buffer C-x C-s + CLOSED: [2020-05-01 금 21:55] +****** DONE Save ALL open files C-x-s + CLOSED: [2020-05-01 금 22:22] +****** DONE Split the window/buffer vertically C-x 2 + CLOSED: [2020-05-01 금 21:48] +****** DONE Split the window/buffer horizontally C-x 3 + CLOSED: [2020-05-01 금 21:48] +****** DONE Switch between the different windows C-x o + CLOSED: [2020-05-01 금 21:48] +****** DONE Close all buffers besides the active one C-x 1 + CLOSED: [2020-05-01 금 21:47] +******* Don't kill it! +****** DONE Close only the active buffer C-x 0 + CLOSED: [2020-05-01 금 21:54] +******* Don't kill it! +****** DONE Kill the active buffer C-x k + CLOSED: [2020-05-01 금 21:44] +****** DONE Describe/Explain the difference between closing and killing + CLOSED: [2020-05-01 금 22:09] +******* closing is that emac do not display the buffer. and the contents on the buffer are kept on behined screen. +******* killing is that emac delete the buffer. and if contents are not stored, it is losted +****** DONE Switch between buffers that are not shown C-x b + CLOSED: [2020-05-01 금 21:51] +******* DONE Document two very similar, but slightly different ways + CLOSED: [2020-05-01 금 23:28] +******** C-x b is that the selected buffer is displayed on the focused window +******** C-x 4 b is that the selected buffer is displayed on the new window +***** Outcome +****** DONE Document all above commands in your learning org sheet + CLOSED: [2020-05-01 금 23:28] +****** DONE Share your documentation at the end of the session (not before) + CLOSED: [2020-05-01 금 23:28] From ece44fce1daf00735787611e56bcc5b105b6753e Mon Sep 17 00:00:00 2001 From: Youngjin Han Date: Sat, 2 May 2020 01:25:50 +0900 Subject: [PATCH 03/35] Learning Circle : Lecture 4 - Bonus Track Update --- youngjin.han/learning-node02-2020.org | 1 + youngjin.han/todo-node02-2020.org | 4 ++++ youngjin.han/todo.org | 7 +++++++ 3 files changed, 12 insertions(+) create mode 100644 youngjin.han/todo-node02-2020.org create mode 100644 youngjin.han/todo.org diff --git a/youngjin.han/learning-node02-2020.org b/youngjin.han/learning-node02-2020.org index 0985a88..77e8a8e 100644 --- a/youngjin.han/learning-node02-2020.org +++ b/youngjin.han/learning-node02-2020.org @@ -1,3 +1,4 @@ +* 2020-05-01 *** Organisation #5: Emacs refresher **** Lecture content ***** Objective: get confident with emacs commands diff --git a/youngjin.han/todo-node02-2020.org b/youngjin.han/todo-node02-2020.org new file mode 100644 index 0000000..4e82efc --- /dev/null +++ b/youngjin.han/todo-node02-2020.org @@ -0,0 +1,4 @@ +* Tasks +** TODO [#A] +SCHEDULED: <2020-05-02 토> +[[mu4e:msgid:m2lfme852e.fsf@mail.ungleich.ch][test10]] diff --git a/youngjin.han/todo.org b/youngjin.han/todo.org new file mode 100644 index 0000000..217dbf9 --- /dev/null +++ b/youngjin.han/todo.org @@ -0,0 +1,7 @@ +* Tasks +** TODO [#A] +SCHEDULED: <2020-05-02 토> +[[mu4e:msgid:87ees5joa4.fsf@ungleich.ch][emac email test title]] +** TODO [#A] test +SCHEDULED: <2020-05-02 토> +[[mu4e:msgid:70488FB5-1CAC-4A97-84E9-8DC0BB6B9592@postech.ac.kr][Re: emac email test title]] From 1087ac1ae72c20468a9dc6cbc6eddbfbd2d15af8 Mon Sep 17 00:00:00 2001 From: Youngjin Han Date: Sun, 3 May 2020 19:16:06 +0900 Subject: [PATCH 04/35] Learning Circle : Lecture 1,2,3,4 Content Update --- youngjin.han/learning-node02-2020.org | 80 +++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) diff --git a/youngjin.han/learning-node02-2020.org b/youngjin.han/learning-node02-2020.org index 77e8a8e..b41f2ae 100644 --- a/youngjin.han/learning-node02-2020.org +++ b/youngjin.han/learning-node02-2020.org @@ -1,3 +1,83 @@ +* 2020-04-23 +*** Organisation #1: org-mode introduction +**** Lecture content +***** Install emacs +***** Install org-mode +***** Create a function that opens ~/learning.org in your ~/.emacs +***** Bind that function to "f3" (configure it in .emacs) +***** Create a new item named "2020-04-10" +****** Create a sub item "ungleich learning circle" +* 2020-04-24 +*** Organisation #2: Creating, managing and sharing with "magit" +**** Lecture content +***** Install "magit" for emacs +***** Bind C-x g to open magit-status in ~/.emacs +***** Create a new directory ~/ungleich-learning-circle/ (with emacs) +****** Use C-h b in dired mode to find out how to +***** Create a sub directory ~/ungleich-learning-circle/YOURNAME/ (with emacs) +***** Move your previously created learning.org file into ~/ungleich-learning-circle/YOURNAME/ (with emacs) +***** Initialise it with git (with magit) +***** Create the repo "ungleich-learning-circle" on code.ungleich.ch under your username +***** Add your remote on code.ungleich.ch to your local git repo with magit +***** Push your repo +***** Add a new remote of a another participant +***** Move your ~/learning.org to ~/notes +***** Commit that file with magit +***** Push the repo with magit +***** Merging the remote repo with the command line +***** End result: everyone has everything of everyone else +* 2020-04-27 +*** Organisation #3: Managing your emails +**** Lecture content +***** Objective +****** Be able to manage all your mails in mu4e +***** Description +****** All email is synchronised using isync/mbsync +****** Email is indexed with mu (xapian backend) +****** Email is viewed in mu4e +****** All new emails arrive in the inbox +***** Steps +****** Install mu4e +****** Start mu4e in emacs +****** Configure mbsync for your ungleich mail account +******* Synchronise all mails into ~/Maildir/ungleich +******* This structure leaves room for other mail accounts, like ~/Maildir/gmail +****** Verify that mbsync synchronises the mail +****** Index mails using `mu` on the command line (only first time) +****** Configure mu4e to get email with mbsync -a +****** Configure mu4e to "archive" emails into ~/Maildir/ungleich/YEAR/ +******* This gives you a good performance / organisation for the next decades +****** Configure mu4e/emacs for sending emails +****** Send other participants an email via mu4e +****** Verify that it arrives +****** "Archive" it afterwards +* 2020-04-29 +*** Organisation #4: Organising yourself +**** Lecture content +***** Objective: have a todo list based on org mode +***** Steps +****** Configure the "org-directory" to be ~/ungleich-learning-circle/USERNAME/ +******* This is important as it will be used by the todo function later +****** Extend your function from the organisation #1 session +******* Instead of opening a fixed file, we include two variable parts: +******** The hostname of the machine +******** The year +******* Pressing F3 should open ~/ungleich-learning-circle/USERNAME/learning-$(hostname)-$(year).org +******** we call this "your personal agenda" +****** Configure mu4e to create a org-mode tasks from an email +******* Store these tasks in ~/ungleich-learning-circle/USERNAME/todo.org +****** Configure emacs to open the "org-agenda" with "C-c a" +****** List all TODO entries +****** List the agenda of the day +****** List the agenda of the week +****** Bind F8 to open the "org-todo-list" +****** Create some sample tasks in it +***** From now on, maintaining tasks should be +****** Pressing F3 to open your personal "logfile" +****** Adding a TODO item +****** Pressing F8 to see the tasks with priorities +***** Bonus tasks +****** Configure mu4e to store org-mode tasks in .../todo-$(hostname)-$(year).org * 2020-05-01 *** Organisation #5: Emacs refresher **** Lecture content From 635550e1a516349fe4c10634e2f1929fb23cb06f Mon Sep 17 00:00:00 2001 From: Youngjin Han Date: Sun, 3 May 2020 19:29:11 +0900 Subject: [PATCH 05/35] Learning Circle : clean up remote repository --- youngjin.han/{learnig.org => learning.org} | 0 youngjin.han/todo.org | 8 +------- 2 files changed, 1 insertion(+), 7 deletions(-) rename youngjin.han/{learnig.org => learning.org} (100%) diff --git a/youngjin.han/learnig.org b/youngjin.han/learning.org similarity index 100% rename from youngjin.han/learnig.org rename to youngjin.han/learning.org diff --git a/youngjin.han/todo.org b/youngjin.han/todo.org index 217dbf9..358960e 100644 --- a/youngjin.han/todo.org +++ b/youngjin.han/todo.org @@ -1,7 +1 @@ -* Tasks -** TODO [#A] -SCHEDULED: <2020-05-02 토> -[[mu4e:msgid:87ees5joa4.fsf@ungleich.ch][emac email test title]] -** TODO [#A] test -SCHEDULED: <2020-05-02 토> -[[mu4e:msgid:70488FB5-1CAC-4A97-84E9-8DC0BB6B9592@postech.ac.kr][Re: emac email test title]] +* Mail TODO Tasks From 63196382707a4802a6c2516e0625deaf9bc145bf Mon Sep 17 00:00:00 2001 From: Youngjin Han Date: Sun, 3 May 2020 21:37:53 +0900 Subject: [PATCH 06/35] Learning Circle : clean up headline on todo file --- youngjin.han/todo-node02-2020.org | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/youngjin.han/todo-node02-2020.org b/youngjin.han/todo-node02-2020.org index 4e82efc..358960e 100644 --- a/youngjin.han/todo-node02-2020.org +++ b/youngjin.han/todo-node02-2020.org @@ -1,4 +1 @@ -* Tasks -** TODO [#A] -SCHEDULED: <2020-05-02 토> -[[mu4e:msgid:m2lfme852e.fsf@mail.ungleich.ch][test10]] +* Mail TODO Tasks From 9e07b9b21cc3d61eb24f07f48e6b3c11aaf572b1 Mon Sep 17 00:00:00 2001 From: Youngjin Han Date: Mon, 4 May 2020 22:35:58 +0900 Subject: [PATCH 07/35] Learning Circle : commit initial manifest for cdist --- youngjin.han/dot-cdist/initial | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 youngjin.han/dot-cdist/initial diff --git a/youngjin.han/dot-cdist/initial b/youngjin.han/dot-cdist/initial new file mode 100644 index 0000000..e69de29 From 5f5c31f896c74e508101a9baf1a7eb93830ad231 Mon Sep 17 00:00:00 2001 From: Youngjin Han Date: Mon, 4 May 2020 22:44:17 +0900 Subject: [PATCH 08/35] Learning Circle : update file name --- youngjin.han/dot-cdist/{initial => init} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename youngjin.han/dot-cdist/{initial => init} (100%) diff --git a/youngjin.han/dot-cdist/initial b/youngjin.han/dot-cdist/init similarity index 100% rename from youngjin.han/dot-cdist/initial rename to youngjin.han/dot-cdist/init From f7409f9de707b3b137cb88f4d2c9525270ae7856 Mon Sep 17 00:00:00 2001 From: Youngjin Han Date: Tue, 5 May 2020 00:01:32 +0900 Subject: [PATCH 09/35] Learning Circle : update cdist init file --- youngjin.han/dot-cdist/init | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/youngjin.han/dot-cdist/init b/youngjin.han/dot-cdist/init index e69de29..cd3f05c 100644 --- a/youngjin.han/dot-cdist/init +++ b/youngjin.han/dot-cdist/init @@ -0,0 +1,9 @@ +__file /etc/cdist-configured + +case "$__target_host" in + localhost) + __motd + __timezone Asia/Seoul + __package emacs --state present + ;; +esac From bace4a52cb23e2763e5cd20442c0f9cfd7ded973 Mon Sep 17 00:00:00 2001 From: Youngjin Han Date: Tue, 5 May 2020 01:04:57 +0900 Subject: [PATCH 10/35] Learning Circle : cdist #1 --- youngjin.han/dot-cdist/{ => manifest}/init | 1 - youngjin.han/learning-node02-2020.org | 192 ++++++++++++--------- 2 files changed, 115 insertions(+), 78 deletions(-) rename youngjin.han/dot-cdist/{ => manifest}/init (91%) diff --git a/youngjin.han/dot-cdist/init b/youngjin.han/dot-cdist/manifest/init similarity index 91% rename from youngjin.han/dot-cdist/init rename to youngjin.han/dot-cdist/manifest/init index cd3f05c..ad77f58 100644 --- a/youngjin.han/dot-cdist/init +++ b/youngjin.han/dot-cdist/manifest/init @@ -2,7 +2,6 @@ __file /etc/cdist-configured case "$__target_host" in localhost) - __motd __timezone Asia/Seoul __package emacs --state present ;; diff --git a/youngjin.han/learning-node02-2020.org b/youngjin.han/learning-node02-2020.org index b41f2ae..9460122 100644 --- a/youngjin.han/learning-node02-2020.org +++ b/youngjin.han/learning-node02-2020.org @@ -1,83 +1,39 @@ -* 2020-04-23 -*** Organisation #1: org-mode introduction -**** Lecture content -***** Install emacs -***** Install org-mode -***** Create a function that opens ~/learning.org in your ~/.emacs -***** Bind that function to "f3" (configure it in .emacs) -***** Create a new item named "2020-04-10" -****** Create a sub item "ungleich learning circle" -* 2020-04-24 -*** Organisation #2: Creating, managing and sharing with "magit" -**** Lecture content -***** Install "magit" for emacs -***** Bind C-x g to open magit-status in ~/.emacs -***** Create a new directory ~/ungleich-learning-circle/ (with emacs) -****** Use C-h b in dired mode to find out how to -***** Create a sub directory ~/ungleich-learning-circle/YOURNAME/ (with emacs) -***** Move your previously created learning.org file into ~/ungleich-learning-circle/YOURNAME/ (with emacs) -***** Initialise it with git (with magit) -***** Create the repo "ungleich-learning-circle" on code.ungleich.ch under your username -***** Add your remote on code.ungleich.ch to your local git repo with magit -***** Push your repo -***** Add a new remote of a another participant -***** Move your ~/learning.org to ~/notes -***** Commit that file with magit -***** Push the repo with magit -***** Merging the remote repo with the command line -***** End result: everyone has everything of everyone else -* 2020-04-27 -*** Organisation #3: Managing your emails +* 2020-05-04 +*** cdist #1: Introduction **** Lecture content ***** Objective -****** Be able to manage all your mails in mu4e -***** Description -****** All email is synchronised using isync/mbsync -****** Email is indexed with mu (xapian backend) -****** Email is viewed in mu4e -****** All new emails arrive in the inbox +****** Begin to use cdist ***** Steps -****** Install mu4e -****** Start mu4e in emacs -****** Configure mbsync for your ungleich mail account -******* Synchronise all mails into ~/Maildir/ungleich -******* This structure leaves room for other mail accounts, like ~/Maildir/gmail -****** Verify that mbsync synchronises the mail -****** Index mails using `mu` on the command line (only first time) -****** Configure mu4e to get email with mbsync -a -****** Configure mu4e to "archive" emails into ~/Maildir/ungleich/YEAR/ -******* This gives you a good performance / organisation for the next decades -****** Configure mu4e/emacs for sending emails -****** Send other participants an email via mu4e -****** Verify that it arrives -****** "Archive" it afterwards -* 2020-04-29 -*** Organisation #4: Organising yourself -**** Lecture content -***** Objective: have a todo list based on org mode -***** Steps -****** Configure the "org-directory" to be ~/ungleich-learning-circle/USERNAME/ -******* This is important as it will be used by the todo function later -****** Extend your function from the organisation #1 session -******* Instead of opening a fixed file, we include two variable parts: -******** The hostname of the machine -******** The year -******* Pressing F3 should open ~/ungleich-learning-circle/USERNAME/learning-$(hostname)-$(year).org -******** we call this "your personal agenda" -****** Configure mu4e to create a org-mode tasks from an email -******* Store these tasks in ~/ungleich-learning-circle/USERNAME/todo.org -****** Configure emacs to open the "org-agenda" with "C-c a" -****** List all TODO entries -****** List the agenda of the day -****** List the agenda of the week -****** Bind F8 to open the "org-todo-list" -****** Create some sample tasks in it -***** From now on, maintaining tasks should be -****** Pressing F3 to open your personal "logfile" -****** Adding a TODO item -****** Pressing F8 to see the tasks with priorities -***** Bonus tasks -****** Configure mu4e to store org-mode tasks in .../todo-$(hostname)-$(year).org +****** DONE Checkout cdist quickstart https://www.cdi.st/manual/latest/cdist-quickstart.html + CLOSED: [2020-05-04 월 22:32] +****** DONE Install cdist locally + CLOSED: [2020-05-04 월 22:32] +****** DONE Create a new cdist configuration directory in ~/ungleich-learning-circle/USERNAME/dot-cdist + CLOSED: [2020-05-04 월 22:32] +****** DONE Create an empty initial manifest ("use touch") + CLOSED: [2020-05-04 월 22:32] +****** DONE Commit that status + CLOSED: [2020-05-04 월 22:37] +****** DONE Ensure that you can login as root to localhost via ssh without a password + CLOSED: [2020-05-04 월 22:37] +****** DONE Configure cdist to configures the motd of your localhost + CLOSED: [2020-05-05 화 00:42] +******* DONE Ensure you have a case block matching on $__target_host + CLOSED: [2020-05-05 화 00:21] +******* DONE Use the -c parameter to cdist to specify the configuration directory + CLOSED: [2020-05-04 월 23:58] +******* DONE Use the -vv parameter to get more verbose output + CLOSED: [2020-05-04 월 23:57] +******* DONE Search for / understand what MOTD stands for + CLOSED: [2020-05-05 화 00:41] +****** DONE Configure cdist to create the file /etc/cdist-configured + CLOSED: [2020-05-04 월 23:33] +****** DONE Configure cdist to setup the timezone on your local computer + CLOSED: [2020-05-04 월 23:33] +****** DONE Configure cdist to ensure emacs is installed + CLOSED: [2020-05-04 월 23:47] +****** DONE Ensure that in the end all changes are committed in your repository + CLOSED: [2020-05-05 화 00:42] * 2020-05-01 *** Organisation #5: Emacs refresher **** Lecture content @@ -132,9 +88,91 @@ ******* DONE Document two very similar, but slightly different ways CLOSED: [2020-05-01 금 23:28] ******** C-x b is that the selected buffer is displayed on the focused window +******** C-x C-b is that all buffers is dispalayed on the new window ******** C-x 4 b is that the selected buffer is displayed on the new window ***** Outcome ****** DONE Document all above commands in your learning org sheet CLOSED: [2020-05-01 금 23:28] ****** DONE Share your documentation at the end of the session (not before) CLOSED: [2020-05-01 금 23:28] + +* 2020-04-29 +*** Organisation #4: Organising yourself +**** Lecture content +***** Objective: have a todo list based on org mode +***** Steps +****** Configure the "org-directory" to be ~/ungleich-learning-circle/USERNAME/ +******* This is important as it will be used by the todo function later +****** Extend your function from the organisation #1 session +******* Instead of opening a fixed file, we include two variable parts: +******** The hostname of the machine +******** The year +******* Pressing F3 should open ~/ungleich-learning-circle/USERNAME/learning-$(hostname)-$(year).org +******** we call this "your personal agenda" +****** Configure mu4e to create a org-mode tasks from an email +******* Store these tasks in ~/ungleich-learning-circle/USERNAME/todo.org +****** Configure emacs to open the "org-agenda" with "C-c a" +****** List all TODO entries +****** List the agenda of the day +****** List the agenda of the week +****** Bind F8 to open the "org-todo-list" +****** Create some sample tasks in it +***** From now on, maintaining tasks should be +****** Pressing F3 to open your personal "logfile" +****** Adding a TODO item +****** Pressing F8 to see the tasks with priorities +***** Bonus tasks +****** Configure mu4e to store org-mode tasks in .../todo-$(hostname)-$(year).org +* 2020-04-27 +*** Organisation #3: Managing your emails +**** Lecture content +***** Objective +****** Be able to manage all your mails in mu4e +***** Description +****** All email is synchronised using isync/mbsync +****** Email is indexed with mu (xapian backend) +****** Email is viewed in mu4e +****** All new emails arrive in the inbox +***** Steps +****** Install mu4e +****** Start mu4e in emacs +****** Configure mbsync for your ungleich mail account +******* Synchronise all mails into ~/Maildir/ungleich +******* This structure leaves room for other mail accounts, like ~/Maildir/gmail +****** Verify that mbsync synchronises the mail +****** Index mails using `mu` on the command line (only first time) +****** Configure mu4e to get email with mbsync -a +****** Configure mu4e to "archive" emails into ~/Maildir/ungleich/YEAR/ +******* This gives you a good performance / organisation for the next decades +****** Configure mu4e/emacs for sending emails +****** Send other participants an email via mu4e +****** Verify that it arrives +****** "Archive" it afterwards +* 2020-04-24 +*** Organisation #2: Creating, managing and sharing with "magit" +**** Lecture content +***** Install "magit" for emacs +***** Bind C-x g to open magit-status in ~/.emacs +***** Create a new directory ~/ungleich-learning-circle/ (with emacs) +****** Use C-h b in dired mode to find out how to +***** Create a sub directory ~/ungleich-learning-circle/YOURNAME/ (with emacs) +***** Move your previously created learning.org file into ~/ungleich-learning-circle/YOURNAME/ (with emacs) +***** Initialise it with git (with magit) +***** Create the repo "ungleich-learning-circle" on code.ungleich.ch under your username +***** Add your remote on code.ungleich.ch to your local git repo with magit +***** Push your repo +***** Add a new remote of a another participant +***** Move your ~/learning.org to ~/notes +***** Commit that file with magit +***** Push the repo with magit +***** Merging the remote repo with the command line +***** End result: everyone has everything of everyone else +* 2020-04-23 +*** Organisation #1: org-mode introduction +**** Lecture content +***** Install emacs +***** Install org-mode +***** Create a function that opens ~/learning.org in your ~/.emacs +***** Bind that function to "f3" (configure it in .emacs) +***** Create a new item named "2020-04-10" +****** Create a sub item "ungleich learning circle" From d6402038c5ebdc34f9f606280ab173b6ee13ac98 Mon Sep 17 00:00:00 2001 From: Youngjin Han Date: Wed, 6 May 2020 23:04:02 +0900 Subject: [PATCH 11/35] Learning Circle : cdist #2 --- .gitignore | 1 + youngjin.han/cdist.org | 5 + youngjin.han/dot-cdist/manifest/init | 3 +- .../dot-cdist/type/__my_computer/manifest | 349 ++++++++++++++++++ .../dot-cdist/type/__my_computer/singleton | 0 youngjin.han/learning-node02-2020.org | 39 ++ 6 files changed, 396 insertions(+), 1 deletion(-) create mode 100644 .gitignore create mode 100644 youngjin.han/cdist.org create mode 100755 youngjin.han/dot-cdist/type/__my_computer/manifest create mode 100644 youngjin.han/dot-cdist/type/__my_computer/singleton diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..8963821 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/youngjin.han/dot-cdist/type/__my_computer/manifest~ diff --git a/youngjin.han/cdist.org b/youngjin.han/cdist.org new file mode 100644 index 0000000..d4d9312 --- /dev/null +++ b/youngjin.han/cdist.org @@ -0,0 +1,5 @@ +* non-singleton needs poress ID. +* singletion should be carried out by itself. +* verbosity level display me cdist processing information. +** '-v' is light information. +** '-vv' and '-vvv' iform me more cidst processing information (e.g. debug, verbose and etc) diff --git a/youngjin.han/dot-cdist/manifest/init b/youngjin.han/dot-cdist/manifest/init index ad77f58..1645f89 100644 --- a/youngjin.han/dot-cdist/manifest/init +++ b/youngjin.han/dot-cdist/manifest/init @@ -2,7 +2,8 @@ __file /etc/cdist-configured case "$__target_host" in localhost) + __motd __timezone Asia/Seoul - __package emacs --state present + __my_computer ;; esac diff --git a/youngjin.han/dot-cdist/type/__my_computer/manifest b/youngjin.han/dot-cdist/type/__my_computer/manifest new file mode 100755 index 0000000..23f356a --- /dev/null +++ b/youngjin.han/dot-cdist/type/__my_computer/manifest @@ -0,0 +1,349 @@ +#!/bin/sh -e + +packages_to_install="zsh mosh emacs nmap sipcals" + +__apt_update_index +for package in $package_to_install; + do require="__apt_update_index" __package $package --state=present +done + +__require="__package/emacs" \ +__directory ~/.emacs.d + +__require="__package/emacs __directory/~/.emacs.d" \ +__file ~/.emacs.d/init.el \ +--owner root \ +--group root \ +--mode 0644 \ +--source - << EOF +;;; init.el --- GNU Emacs Configuration + +;; Copyright (C) 2014 Terencio Agozzino + +;; Author: Terencio Agozzino +;; Created: February 16, 2014 +;; Homepage: https://github.com/rememberYou/.emacs.d +;; Keywords: abbrev, convenience, faces, maint, outlines, vc + +;; This program is free software. You can redistribute it and/or modify it under +;; the terms of the Do What The Fuck You Want To Public License, version 2 as +;; published by Sam Hocevar. +;; +;; 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. +;; +;; You should have received a copy of the Do What The Fuck You Want To Public +;; License along with this program. If not, see http://www.wtfpl.net/. + +;;; Commentary: + +;; Following lines build the configuration code out of the config.el file. + +;;; Code: + +;; Make startup faster by reducing the frequency of garbage +;; collection. +(setq gc-cons-threshold (* 50 1000 1000)) + +(require 'package) +(package-initialize) + +(if (file-exists-p (expand-file-name "00_global_config.el" user-emacs-directory)) + (load-file (expand-file-name "00_global_config.el" user-emacs-directory))) + +(if (file-exists-p (expand-file-name "10_magit_config.el" user-emacs-directory)) + (load-file (expand-file-name "10_magit_config.el" user-emacs-directory))) + +(if (file-exists-p (expand-file-name "20_mu4e_config.el" user-emacs-directory)) + (load-file (expand-file-name "20_mu4e_config.el" user-emacs-directory))) + +(if (file-exists-p (expand-file-name "21_smtp_config.el" user-emacs-directory)) + (load-file (expand-file-name "21_smtp_config.el" user-emacs-directory))) + +(if (file-exists-p (expand-file-name "30_agenda_config.el" user-emacs-directory)) + (load-file (expand-file-name "30_agenda_config.el" user-emacs-directory))) + +(if (file-exists-p (expand-file-name "99_custom_config.el" user-emacs-directory)) + (load-file (expand-file-name "99_custom_config.el" user-emacs-directory))) + +(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. + '(org-agenda-files + (quote + ("~/ungleich-learning-circle/youngjin.han/todo-node02-2020.org" "~/ungleich-learning-circle/youngjin.han/learning-node02-2020.org"))) + '(package-selected-packages (quote (zenburn-theme magit))) + '(xterm-mouse-mode 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. +) + +;; Make gc pauses faster by decreasing the threshold. +(setq gc-cons-threshold (* 2 1000 1000)) + +;;; init.el ends here +EOF + +__require="__package/emacs __directory/~/.emacs.d __file/~/.emacs.d/init.el" \ +__file ~/.emacs.d/00_global_config.el \ +--owner root \ +--group root \ +--mode 0644 \ +--source - << EOF +;; Added by Package.el. This must come before configurations of +;; installed packages. Don't delete this line. If you don't want it, +;; just comment it out by adding a semicolon to the start of the line. +;; You may delete these explanatory comments. +(package-initialize) + +;; load emacs 24's package system. Add MELPA repository. +(when (>= emacs-major-version 24) + (require 'package) + (add-to-list + 'package-archives + ;; '("melpa" . "http://stable.melpa.org/packages/") ; many packages won't show if using stable + '("melpa" . "http://melpa.milkbox.net/packages/") + ;; '("org" . "http://orgmode.org/elpa/") + t)) + +(setq auth-sources '("~/.authinfo.gpg" + "~/.authinfo")) + +(setq-default +;; ad-redefinition-action 'accept ; Silence warnings for redefinition +;; cursor-in-non-selected-windows t ; Hide the cursor in inactive windows +;; display-time-default-load-average nil ; Don't display load average +;; fill-column 80 ; Set width for automatic line breaks + help-window-select t ; Focus new help windows when opened + indent-tabs-mode nil ; Prefers spaces over tabs + inhibit-startup-screen t ; Disable start-up screen +;; initial-scratch-message "" ; Empty the initial *scratch* buffer +;; kill-ring-max 128 ; Maximum length of kill ring +;; load-prefer-newer t ; Prefers the newest version of a file +;; mark-ring-max 128 ; Maximum length of mark ring +;; scroll-conservatively most-positive-fixnum ; Always scroll by one line +;; select-enable-clipboard t ; Merge system's and Emacs' clipboard + tab-width 4 ; Set width for tabs +;; use-package-always-ensure t ; Avoid the :ensure keyword for each package +;; user-full-name "Terencio Agozzino" ; Set the full name of the current user +;; user-mail-address "terencio.agozzino@gmail.com" ; Set the email address of the current user + vc-follow-symlinks t ; Always follow the symlinks +;; view-read-only t ; Always open read-only buffers in view-mode +) +(cd "~/") ; Move to the user directory +(column-number-mode 1) ; Show the column number +(display-time-mode 1) ; Enable time in the mode-line +(fset 'yes-or-no-p 'y-or-n-p) ; Replace yes/no prompts with y/n +(global-hl-line-mode) ; Hightlight current line +;; (set-default-coding-systems 'utf-8) ; Default to utf-8 encoding +;; (show-paren-mode 1) ; Show the parent + +;; use variable-pitch fonts for some headings and titles +(setq zenburn-use-variable-pitch t) + +;; scale headings in org-mode +(setq zenburn-scale-org-headlines t) + +;; scale headings in outline-mode +(setq zenburn-scale-outline-headlines t) + +(setq zenburn-override-colors-alist + '(("zenburn-bg+05" . "#282828") + ("zenburn-bg+1" . "#2F2F2F") + ("zenburn-bg+2" . "#3F3F3F") + ("zenburn-bg+3" . "#4F4F4F"))) +(load-theme 'zenburn t) + +(set-face-attribute 'default nil :font "Source Code Pro Medium") +(set-fontset-font t 'latin "Noto Sans") +(set-frame-font "DejaVu Sans Mono-18" nil t) + +;;문법 강조를 활성화 +(global-font-lock-mode t) +(transient-mark-mode 1) + +(when window-system + (menu-bar-mode -1) ; Disable the menu bar + (scroll-bar-mode -1) ; Disable the scroll bar + (tool-bar-mode -1) ; Disable the tool bar + (tooltip-mode -1)) ; Disable the tooltips + +;; org-mode 설정 +;; org-mode 활성화 +(require 'org) + +;; org-mode를 .org로 끝나는 파일에서 활성화 +(add-to-list 'auto-mode-alist '("\\.org$" . org-mode)) + +;; (global-set-key (kbd "") (lambda () (interactive) (find-file (concat "~/ungleich-learning-circle/youngjin.han/learning-"(system-name)"-"(substring (current-time-string) -4 nil)".org")))) +(global-set-key (kbd "") (lambda () (interactive) (find-file (concat "~/ungleich-learning-circle/youngjin.han/learning-"(system-name)"-"(format-time-string "%Y")".org")))) + +(setq org-directory (expand-file-name "~/ungleich-learning-circle/youngjin.han")) + +(use-package window + :ensure nil + :bind (("C-x 3" . hsplit-last-buffer) + ("C-x 2" . vsplit-last-buffer)) + :preface + (defun hsplit-last-buffer () + "Gives the focus to the last created horizontal window." + (interactive) + (split-window-horizontally) + (other-window 1)) + + (defun vsplit-last-buffer () + "Gives the focus to the last created vertical window." + (interactive) + (split-window-vertically) + (other-window 1))) +EOF + +__require="__package/emacs __directory/~/.emacs.d __file/~/.emacs.d/init.el" \ +__file ~/.emacs.d/10_magit_config.el \ +--owner root \ +--group root \ +--mode 0644 \ +--source - << EOF +;; Added by Package.el. This must come before configurations of +;; installed packages. Don't delete this line. If you don't want it, +;; just comment it out by adding a semicolon to the start of the line. +;; You may delete these explanatory comments. +(require 'magit) + +(global-set-key (kbd "C-x g") 'magit-status) +EOF + +__require="__package/emacs __directory/~/.emacs.d __file/~/.emacs.d/init.el" \ +__file ~/.emacs.d/20_mu4e_config.el \ +--owner root \ +--group root \ +--mode 0644 \ +--source - << EOF +;; Added by Package.el. This must come before configurations of +;; installed packages. Don't delete this line. If you don't want it, +;; just comment it out by adding a semicolon to the start of the line. +;; You may delete these explanatory comments. +(add-to-list 'load-path "/usr/local/share/emacs/site-lisp/mu4e") + +(require 'mu4e) + +;; location of my maildir +(setq mu4e-maildir (expand-file-name "~/.maildir/ungleich/youngjin.han@ungleich.ch/")) + +(setq mu4e-maildir-shortcuts + '( (:maildir "/Inbox" :key ?i) + (:maildir "/archive" :key ?a) + (:maildir "/drafts" :key ?d) + (:maildir "/sent" :key ?s) + (:maildir "/trash" :key ?t))) + +;; these are actually the defaults +(setq + mu4e-refile-folder "/archive" ;; saved messages + mu4e-drafts-folder "/drafts" ;; unfinished messages + mu4e-sent-folder "/sent" ;; folder for sent messages + mu4e-trash-folder "/trash") ;; trashed messages + +(setq + mu4e-index-cleanup nil ;; don't do a full cleanup check + mu4e-index-lazy-check t) ;; don't consider up-to-date dirs + +(setq + mu4e-get-mail-command "mbsync -a" ;; or fetchmail, or ... + mu4e-update-interval 300) ;; update every 5 minutes + +;; show images +(setq mu4e-show-images t) + +(setq mu4e-reply-to-address "youngjin.han@ungleich.ch" + user-mail-address "youngjin.han@ungleich.ch" + user-full-name "YOUNGJIN.HAN") + +;; spell check +(add-hook 'mu4e-compose-mode-hook + (defun my-do-compose-stuff () + "My settings for message composition." + (set-fill-column 72) + (flyspell-mode))) + +;;rename files when moving +;;NEEDED FOR MBSYNC +(setq mu4e-change-filenames-when-moving t) + +;;store org-mode links to messages +(require 'org-mu4e) + +(define-key mu4e-headers-mode-map (kbd "C-c c") 'mu4e-org-store-and-capture) +(define-key mu4e-view-mode-map (kbd "C-c c") 'mu4e-org-store-and-capture) + +(setq mu4e-headers-skip-duplicates nil) + +;;store link to message if in header view, not to header query +(setq org-mu4e-link-query-in-headers-mode nil) +EOF + +__require="__package/emacs __directory/~/.emacs.d __file/~/.emacs.d/init.el" \ +__file ~/.emacs.d/21_smtp_config.el \ +--owner root \ +--group root \ +--mode 0644 \ +--source - << EOF +;; Added by Package.el. This must come before configurations of +;; installed packages. Don't delete this line. If you don't want it, +;; just comment it out by adding a semicolon to the start of the line. +;; You may delete these explanatory comments. +(require 'smtpmail) + +;; smtp +(setq message-send-mail-function 'smtpmail-send-it + smtpmail-starttls-credentials + '(("smtp.ungleich.ch" 587 nil nil)) + smtpmail-default-smtp-server "smtp.ungleich.ch" + smtpmail-smtp-server "smtp.ungleich.ch" + smtpmail-smtp-service 587 + smtpmail-auth-credentials "~/.authinfo" + smtpmail-debug-info t) +EOF + +__require="__package/emacs __directory/~/.emacs.d __file/~/.emacs.d/init.el" \ +__file ~/.emacs.d/30_agenda_config.el \ +--owner root \ +--group root \ +--mode 0644 \ +--source - << EOF +;; Added by Package.el. This must come before configurations of +;; installed packages. Don't delete this line. If you don't want it, +;; just comment it out by adding a semicolon to the start of the line. +;; You may delete these explanatory comments. +(require 'org-agenda) + +(global-set-key (kbd "C-c a") 'org-agenda) + +(require 'org-capture) + +(setq org-capture-templates + '(("t" "todo" entry (file+headline (concat "~/ungleich-learning-circle/youngjin.han/todo-"(system-name)"-"(format-time-string "%Y")".org") "Tasks") + "* TODO [#A] %?\nSCHEDULED: %(org-insert-time-stamp (org-read-date nil t \"+0d\"))\n%a\n"))) + +(global-set-key (kbd "") 'org-todo-list) + +(setq org-log-done 'time) +EOF + +__require="__package/emacs __directory/~/.emacs.d __file/~/.emacs.d/init.el" \ +__file ~/.emacs.d/99_custom_config.el \ +--owner root \ +--group root \ +--mode 0644 \ +--source - << EOF +;; Added by Package.el. This must come before configurations of +;; installed packages. Don't delete this line. If you don't want it, +;; just comment it out by adding a semicolon to the start of the line. +;; You may delete these explanatory comments. +EOF diff --git a/youngjin.han/dot-cdist/type/__my_computer/singleton b/youngjin.han/dot-cdist/type/__my_computer/singleton new file mode 100644 index 0000000..e69de29 diff --git a/youngjin.han/learning-node02-2020.org b/youngjin.han/learning-node02-2020.org index 9460122..1fb6d2c 100644 --- a/youngjin.han/learning-node02-2020.org +++ b/youngjin.han/learning-node02-2020.org @@ -1,3 +1,42 @@ +* 2020-05-06 +** cdist #2: Your first cdist type +**** Lecture content +***** Objective +****** Begin to understand how cdist types function +***** Steps +****** DONE Create a new type named `__my_computer` + CLOSED: [2020-05-06 수 22:53] +******* DONE Mark the type as a singleton type + CLOSED: [2020-05-06 수 22:53] +******* DONE Create a `manifest` file in it + CLOSED: [2020-05-06 수 22:53] +******* DONE Use this type to install the following packages: zsh, mosh, emacs, nmap, sipcalc + CLOSED: [2020-05-06 수 22:53] +******* DONE Edit the *initial manifest* and use **__my_computer** for **localhost** + CLOSED: [2020-05-06 수 22:53] +******* DONE Match using the $__target_host variable + CLOSED: [2020-05-06 수 22:53] +****** DONE Modify your type to use a *for loop* to install the packages + CLOSED: [2020-05-06 수 22:53] +****** DONE Deploy / manage your ~/.emacs file in this type + CLOSED: [2020-05-06 수 22:53] +******* DONE Ensure that permissions and ownership are correct + CLOSED: [2020-05-06 수 22:53] +****** DONE Use different *verbosity* levels when configuring + CLOSED: [2020-05-06 수 22:54] +****** DONE Ensure that all your changes are committed and pushed in your ungleich-learning-circle repository + CLOSED: [2020-05-06 수 22:54] +******* DONE Use magit inside emacs for that + CLOSED: [2020-05-06 수 22:54] +***** DONE Documentation steps to be done in cdist.org + CLOSED: [2020-05-06 수 23:02] +****** DONE Create a new org document named `cdist.org` in the same folder as the learning.org file + CLOSED: [2020-05-06 수 23:02] +****** DONE Explain the difference between a singleton and non-singleton type + CLOSED: [2020-05-06 수 23:02] +****** DONE Explain the difference between the different verbosity levels + CLOSED: [2020-05-06 수 23:02] +****** Document (copy&paste) some of the cdist runs in a "log" section``` * 2020-05-04 *** cdist #1: Introduction **** Lecture content From 4f7f7995eaceaf0f4a9042561c8f1bf90e5cc116 Mon Sep 17 00:00:00 2001 From: Youngjin Han Date: Wed, 6 May 2020 23:43:58 +0900 Subject: [PATCH 12/35] Learning Circle : cdist #2 update verbosity log --- youngjin.han/cdist.org | 236 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 236 insertions(+) diff --git a/youngjin.han/cdist.org b/youngjin.han/cdist.org index d4d9312..f92d03f 100644 --- a/youngjin.han/cdist.org +++ b/youngjin.han/cdist.org @@ -3,3 +3,239 @@ * verbosity level display me cdist processing information. ** '-v' is light information. ** '-vv' and '-vvv' iform me more cidst processing information (e.g. debug, verbose and etc) +* Log verbosity +** -v +INFO: localhost: Starting configuration run +INFO: localhost: Processing __apt_update_index/ +INFO: localhost: Processing __motd/ +INFO: localhost: Finished successful run in 2.45 seconds +** -vv +VERBOSE: cdist: version 6.5.5-2-gd4059fd2 +INFO: localhost: Starting configuration run +VERBOSE: localhost: Running global explorers +VERBOSE: localhost: Running initial manifest /tmp/tmplx_30ksy/421aa90e079fa326b6494f812ad13e79/data/conf/manifest/init +VERBOSE: localhost: Preparing object __file/etc/cdist-configured +VERBOSE: localhost: Running manifest and explorers for __file/etc/cdist-configured +VERBOSE: localhost: Running type explorers for +VERBOSE: localhost: Running object __file/etc/cdist-configured +VERBOSE: localhost: Preparing object __timezone/Asia/Seoul +VERBOSE: localhost: Running manifest and explorers for __timezone/Asia/Seoul +VERBOSE: localhost: Running type explorers for +VERBOSE: localhost: Running type manifest /tmp/tmplx_30ksy/421aa90e079fa326b6494f812ad13e79/data/conf/type/__timezone/manifest for object __timezone/Asia/Seoul +VERBOSE: localhost: Preparing object __my_computer/ +VERBOSE: localhost: Running manifest and explorers for __my_computer/ +VERBOSE: localhost: Running type explorers for +VERBOSE: localhost: Running type manifest /tmp/tmplx_30ksy/421aa90e079fa326b6494f812ad13e79/data/conf/type/__my_computer/manifest for object __my_computer/ +VERBOSE: localhost: Preparing object __motd/ +VERBOSE: localhost: Running manifest and explorers for __motd/ +VERBOSE: localhost: Running type explorers for +VERBOSE: localhost: Running type manifest /tmp/tmplx_30ksy/421aa90e079fa326b6494f812ad13e79/data/conf/type/__motd/manifest for object __motd/ +VERBOSE: localhost: Preparing object __apt_update_index/ +VERBOSE: localhost: Running manifest and explorers for __apt_update_index/ +VERBOSE: localhost: Running type explorers for +VERBOSE: localhost: Running object __apt_update_index/ +INFO: localhost: Processing __apt_update_index/ +VERBOSE: localhost: Preparing object __file/home/jafo/.emacs.d/30_agenda_config.el +VERBOSE: localhost: Running manifest and explorers for __file/home/jafo/.emacs.d/30_agenda_config.el +VERBOSE: localhost: Running type explorers for +VERBOSE: localhost: Running object __file/home/jafo/.emacs.d/30_agenda_config.el +VERBOSE: localhost: Preparing object __file/home/jafo/.emacs.d/00_global_config.el +VERBOSE: localhost: Running manifest and explorers for __file/home/jafo/.emacs.d/00_global_config.el +VERBOSE: localhost: Running type explorers for +VERBOSE: localhost: Running object __file/home/jafo/.emacs.d/00_global_config.el +VERBOSE: localhost: Preparing object __file/home/jafo/.emacs.d/10_magit_config.el +VERBOSE: localhost: Running manifest and explorers for __file/home/jafo/.emacs.d/10_magit_config.el +VERBOSE: localhost: Running type explorers for +VERBOSE: localhost: Running object __file/home/jafo/.emacs.d/10_magit_config.el +VERBOSE: localhost: Preparing object __file/home/jafo/.emacs.d/20_mu4e_config.el +VERBOSE: localhost: Running manifest and explorers for __file/home/jafo/.emacs.d/20_mu4e_config.el +VERBOSE: localhost: Running type explorers for +VERBOSE: localhost: Running object __file/home/jafo/.emacs.d/20_mu4e_config.el +VERBOSE: localhost: Preparing object __file/home/jafo/.emacs.d/init.el +VERBOSE: localhost: Running manifest and explorers for __file/home/jafo/.emacs.d/init.el +VERBOSE: localhost: Running type explorers for +VERBOSE: localhost: Running object __file/home/jafo/.emacs.d/init.el +VERBOSE: localhost: Preparing object __file/home/jafo/.emacs.d/21_smtp_config.el +VERBOSE: localhost: Running manifest and explorers for __file/home/jafo/.emacs.d/21_smtp_config.el +VERBOSE: localhost: Running type explorers for +VERBOSE: localhost: Running object __file/home/jafo/.emacs.d/21_smtp_config.el +VERBOSE: localhost: Preparing object __file/home/jafo/.emacs.d/99_custom_config.el +VERBOSE: localhost: Running manifest and explorers for __file/home/jafo/.emacs.d/99_custom_config.el +VERBOSE: localhost: Running type explorers for +VERBOSE: localhost: Running object __file/home/jafo/.emacs.d/99_custom_config.el +VERBOSE: localhost: Preparing object __file/etc/motd.tail +VERBOSE: localhost: Running manifest and explorers for __file/etc/motd.tail +VERBOSE: localhost: Running type explorers for +VERBOSE: localhost: Running object __file/etc/motd.tail +VERBOSE: localhost: Preparing object __directory/home/jafo/.emacs.d +VERBOSE: localhost: Running manifest and explorers for __directory/home/jafo/.emacs.d +VERBOSE: localhost: Running type explorers for +VERBOSE: localhost: Running object __directory/home/jafo/.emacs.d +VERBOSE: localhost: Preparing object __package/tzdata +VERBOSE: localhost: Running manifest and explorers for __package/tzdata +VERBOSE: localhost: Running type explorers for +VERBOSE: localhost: Running type manifest /tmp/tmplx_30ksy/421aa90e079fa326b6494f812ad13e79/data/conf/type/__package/manifest for object __package/tzdata +VERBOSE: localhost: Running object __my_computer/ +VERBOSE: localhost: Running object __motd/ +INFO: localhost: Processing __motd/ +VERBOSE: localhost: Preparing object __package_apt/tzdata +VERBOSE: localhost: Running manifest and explorers for __package_apt/tzdata +VERBOSE: localhost: Running type explorers for +VERBOSE: localhost: Running object __package_apt/tzdata +VERBOSE: localhost: Running object __package/tzdata +VERBOSE: localhost: Preparing object __link/etc/localtime +VERBOSE: localhost: Running manifest and explorers for __link/etc/localtime +VERBOSE: localhost: Running type explorers for +VERBOSE: localhost: Running object __link/etc/localtime +VERBOSE: localhost: Running object __timezone/Asia/Seoul +INFO: localhost: Finished successful run in 2.42 seconds +VERBOSE: config: Total processing time for 1 host(s): 2.424041986465454 +** -vvv +VERBOSE: cdist: version 6.5.5-2-gd4059fd2 +DEBUG: inventory: Host 'localhost' not found, skipped +DEBUG: config: Base root path for target host "localhost" is "/tmp/tmp4qn81ovh/421aa90e079fa326b6494f812ad13e79" +DEBUG: localhost: remote_exec for host "localhost": ssh -o User=root -o ControlPath=/tmp/tmppv2p77_1/s -o ControlMaster=auto -o ControlPersist=2h +DEBUG: localhost: remote_copy for host "localhost": scp -o User=root -q -o ControlPath=/tmp/tmppv2p77_1/s -o ControlMaster=auto -o ControlPersist=2h +DEBUG: localhost: address family: 0 +DEBUG: localhost: derived host_name for host "localhost": localhost +DEBUG: localhost: derived host_fqdn for host "localhost": localhost +DEBUG: localhost: target_host for host "localhost": ('localhost', 'localhost', 'localhost') +INFO: localhost: Starting configuration run +DEBUG: localhost: Checking conf_dir /usr/local/lib/python3.5/dist-packages/cdist/conf ... +DEBUG: localhost: Checking conf_dir /home/jafo/.cdist ... +DEBUG: localhost: Checking conf_dir /home/jafo/ungleich-learning-circle/youngjin.han/dot-cdist/ ... +VERBOSE: localhost: Running global explorers +DEBUG: localhost: Running global explorers sequentially +VERBOSE: localhost: Running initial manifest /tmp/tmp4qn81ovh/421aa90e079fa326b6494f812ad13e79/data/conf/manifest/init +DEBUG: localhost: /tmp/tmp4qn81ovh/421aa90e079fa326b6494f812ad13e79/data/conf/manifest/init is NOT executable, running it with /bin/sh -e +DEBUG: localhost: Iteration in sequential mode +VERBOSE: localhost: Preparing object __file/etc/cdist-configured +VERBOSE: localhost: Running manifest and explorers for __file/etc/cdist-configured +VERBOSE: localhost: Running type explorers for +VERBOSE: localhost: Running object __file/etc/cdist-configured +DEBUG: localhost: Generating code for __file/etc/cdist-configured +DEBUG: localhost: /tmp/tmp4qn81ovh/421aa90e079fa326b6494f812ad13e79/data/conf/type/__file/gencode-local is NOT executable, running it with /bin/sh -e +DEBUG: localhost: /tmp/tmp4qn81ovh/421aa90e079fa326b6494f812ad13e79/data/conf/type/__file/gencode-remote is NOT executable, running it with /bin/sh -e +VERBOSE: localhost: Preparing object __timezone/Asia/Seoul +VERBOSE: localhost: Running manifest and explorers for __timezone/Asia/Seoul +VERBOSE: localhost: Running type explorers for +VERBOSE: localhost: Running type manifest /tmp/tmp4qn81ovh/421aa90e079fa326b6494f812ad13e79/data/conf/type/__timezone/manifest for object __timezone/Asia/Seoul +DEBUG: localhost: /tmp/tmp4qn81ovh/421aa90e079fa326b6494f812ad13e79/data/conf/type/__timezone/manifest is NOT executable, running it with /bin/sh -e +VERBOSE: localhost: Preparing object __my_computer/ +VERBOSE: localhost: Running manifest and explorers for __my_computer/ +VERBOSE: localhost: Running type explorers for +VERBOSE: localhost: Running type manifest /tmp/tmp4qn81ovh/421aa90e079fa326b6494f812ad13e79/data/conf/type/__my_computer/manifest for object __my_computer/ +DEBUG: localhost: /tmp/tmp4qn81ovh/421aa90e079fa326b6494f812ad13e79/data/conf/type/__my_computer/manifest is executable, running it +VERBOSE: localhost: Preparing object __motd/ +VERBOSE: localhost: Running manifest and explorers for __motd/ +VERBOSE: localhost: Running type explorers for +VERBOSE: localhost: Running type manifest /tmp/tmp4qn81ovh/421aa90e079fa326b6494f812ad13e79/data/conf/type/__motd/manifest for object __motd/ +DEBUG: localhost: /tmp/tmp4qn81ovh/421aa90e079fa326b6494f812ad13e79/data/conf/type/__motd/manifest is NOT executable, running it with /bin/sh -e +DEBUG: localhost: Iteration in sequential mode +VERBOSE: localhost: Preparing object __apt_update_index/ +VERBOSE: localhost: Running manifest and explorers for __apt_update_index/ +VERBOSE: localhost: Running type explorers for +VERBOSE: localhost: Running object __apt_update_index/ +DEBUG: localhost: Generating code for __apt_update_index/ +DEBUG: localhost: /tmp/tmp4qn81ovh/421aa90e079fa326b6494f812ad13e79/data/conf/type/__apt_update_index/gencode-remote is NOT executable, running it with /bin/sh -e +INFO: localhost: Processing __apt_update_index/ +VERBOSE: localhost: Preparing object __file/home/jafo/.emacs.d/30_agenda_config.el +VERBOSE: localhost: Running manifest and explorers for __file/home/jafo/.emacs.d/30_agenda_config.el +VERBOSE: localhost: Running type explorers for +VERBOSE: localhost: Running object __file/home/jafo/.emacs.d/30_agenda_config.el +DEBUG: localhost: Generating code for __file/home/jafo/.emacs.d/30_agenda_config.el +DEBUG: localhost: /tmp/tmp4qn81ovh/421aa90e079fa326b6494f812ad13e79/data/conf/type/__file/gencode-local is NOT executable, running it with /bin/sh -e +DEBUG: localhost: /tmp/tmp4qn81ovh/421aa90e079fa326b6494f812ad13e79/data/conf/type/__file/gencode-remote is NOT executable, running it with /bin/sh -e +VERBOSE: localhost: Preparing object __file/home/jafo/.emacs.d/00_global_config.el +VERBOSE: localhost: Running manifest and explorers for __file/home/jafo/.emacs.d/00_global_config.el +VERBOSE: localhost: Running type explorers for +VERBOSE: localhost: Running object __file/home/jafo/.emacs.d/00_global_config.el +DEBUG: localhost: Generating code for __file/home/jafo/.emacs.d/00_global_config.el +DEBUG: localhost: /tmp/tmp4qn81ovh/421aa90e079fa326b6494f812ad13e79/data/conf/type/__file/gencode-local is NOT executable, running it with /bin/sh -e +DEBUG: localhost: /tmp/tmp4qn81ovh/421aa90e079fa326b6494f812ad13e79/data/conf/type/__file/gencode-remote is NOT executable, running it with /bin/sh -e +VERBOSE: localhost: Preparing object __file/home/jafo/.emacs.d/10_magit_config.el +VERBOSE: localhost: Running manifest and explorers for __file/home/jafo/.emacs.d/10_magit_config.el +VERBOSE: localhost: Running type explorers for +VERBOSE: localhost: Running object __file/home/jafo/.emacs.d/10_magit_config.el +DEBUG: localhost: Generating code for __file/home/jafo/.emacs.d/10_magit_config.el +DEBUG: localhost: /tmp/tmp4qn81ovh/421aa90e079fa326b6494f812ad13e79/data/conf/type/__file/gencode-local is NOT executable, running it with /bin/sh -e +DEBUG: localhost: /tmp/tmp4qn81ovh/421aa90e079fa326b6494f812ad13e79/data/conf/type/__file/gencode-remote is NOT executable, running it with /bin/sh -e +VERBOSE: localhost: Preparing object __file/home/jafo/.emacs.d/20_mu4e_config.el +VERBOSE: localhost: Running manifest and explorers for __file/home/jafo/.emacs.d/20_mu4e_config.el +VERBOSE: localhost: Running type explorers for +VERBOSE: localhost: Running object __file/home/jafo/.emacs.d/20_mu4e_config.el +DEBUG: localhost: Generating code for __file/home/jafo/.emacs.d/20_mu4e_config.el +DEBUG: localhost: /tmp/tmp4qn81ovh/421aa90e079fa326b6494f812ad13e79/data/conf/type/__file/gencode-local is NOT executable, running it with /bin/sh -e +DEBUG: localhost: /tmp/tmp4qn81ovh/421aa90e079fa326b6494f812ad13e79/data/conf/type/__file/gencode-remote is NOT executable, running it with /bin/sh -e +VERBOSE: localhost: Preparing object __file/home/jafo/.emacs.d/init.el +VERBOSE: localhost: Running manifest and explorers for __file/home/jafo/.emacs.d/init.el +VERBOSE: localhost: Running type explorers for +VERBOSE: localhost: Running object __file/home/jafo/.emacs.d/init.el +DEBUG: localhost: Generating code for __file/home/jafo/.emacs.d/init.el +DEBUG: localhost: /tmp/tmp4qn81ovh/421aa90e079fa326b6494f812ad13e79/data/conf/type/__file/gencode-local is NOT executable, running it with /bin/sh -e +DEBUG: localhost: /tmp/tmp4qn81ovh/421aa90e079fa326b6494f812ad13e79/data/conf/type/__file/gencode-remote is NOT executable, running it with /bin/sh -e +VERBOSE: localhost: Preparing object __file/home/jafo/.emacs.d/21_smtp_config.el +VERBOSE: localhost: Running manifest and explorers for __file/home/jafo/.emacs.d/21_smtp_config.el +VERBOSE: localhost: Running type explorers for +VERBOSE: localhost: Running object __file/home/jafo/.emacs.d/21_smtp_config.el +DEBUG: localhost: Generating code for __file/home/jafo/.emacs.d/21_smtp_config.el +DEBUG: localhost: /tmp/tmp4qn81ovh/421aa90e079fa326b6494f812ad13e79/data/conf/type/__file/gencode-local is NOT executable, running it with /bin/sh -e +DEBUG: localhost: /tmp/tmp4qn81ovh/421aa90e079fa326b6494f812ad13e79/data/conf/type/__file/gencode-remote is NOT executable, running it with /bin/sh -e +VERBOSE: localhost: Preparing object __file/home/jafo/.emacs.d/99_custom_config.el +VERBOSE: localhost: Running manifest and explorers for __file/home/jafo/.emacs.d/99_custom_config.el +VERBOSE: localhost: Running type explorers for +VERBOSE: localhost: Running object __file/home/jafo/.emacs.d/99_custom_config.el +DEBUG: localhost: Generating code for __file/home/jafo/.emacs.d/99_custom_config.el +DEBUG: localhost: /tmp/tmp4qn81ovh/421aa90e079fa326b6494f812ad13e79/data/conf/type/__file/gencode-local is NOT executable, running it with /bin/sh -e +DEBUG: localhost: /tmp/tmp4qn81ovh/421aa90e079fa326b6494f812ad13e79/data/conf/type/__file/gencode-remote is NOT executable, running it with /bin/sh -e +VERBOSE: localhost: Preparing object __file/etc/motd.tail +VERBOSE: localhost: Running manifest and explorers for __file/etc/motd.tail +VERBOSE: localhost: Running type explorers for +VERBOSE: localhost: Running object __file/etc/motd.tail +DEBUG: localhost: Generating code for __file/etc/motd.tail +DEBUG: localhost: /tmp/tmp4qn81ovh/421aa90e079fa326b6494f812ad13e79/data/conf/type/__file/gencode-local is NOT executable, running it with /bin/sh -e +DEBUG: localhost: /tmp/tmp4qn81ovh/421aa90e079fa326b6494f812ad13e79/data/conf/type/__file/gencode-remote is NOT executable, running it with /bin/sh -e +VERBOSE: localhost: Preparing object __directory/home/jafo/.emacs.d +VERBOSE: localhost: Running manifest and explorers for __directory/home/jafo/.emacs.d +VERBOSE: localhost: Running type explorers for +VERBOSE: localhost: Running object __directory/home/jafo/.emacs.d +DEBUG: localhost: Generating code for __directory/home/jafo/.emacs.d +DEBUG: localhost: /tmp/tmp4qn81ovh/421aa90e079fa326b6494f812ad13e79/data/conf/type/__directory/gencode-remote is NOT executable, running it with /bin/sh -e +VERBOSE: localhost: Preparing object __package/tzdata +VERBOSE: localhost: Running manifest and explorers for __package/tzdata +VERBOSE: localhost: Running type explorers for +VERBOSE: localhost: Running type manifest /tmp/tmp4qn81ovh/421aa90e079fa326b6494f812ad13e79/data/conf/type/__package/manifest for object __package/tzdata +DEBUG: localhost: /tmp/tmp4qn81ovh/421aa90e079fa326b6494f812ad13e79/data/conf/type/__package/manifest is NOT executable, running it with /bin/sh -e +VERBOSE: localhost: Running object __my_computer/ +DEBUG: localhost: Generating code for __my_computer/ +VERBOSE: localhost: Running object __motd/ +DEBUG: localhost: Generating code for __motd/ +DEBUG: localhost: /tmp/tmp4qn81ovh/421aa90e079fa326b6494f812ad13e79/data/conf/type/__motd/gencode-remote is NOT executable, running it with /bin/sh -e +INFO: localhost: Processing __motd/ +DEBUG: localhost: Iteration in sequential mode +VERBOSE: localhost: Preparing object __package_apt/tzdata +VERBOSE: localhost: Running manifest and explorers for __package_apt/tzdata +VERBOSE: localhost: Running type explorers for +VERBOSE: localhost: Running object __package_apt/tzdata +DEBUG: localhost: Generating code for __package_apt/tzdata +DEBUG: localhost: /tmp/tmp4qn81ovh/421aa90e079fa326b6494f812ad13e79/data/conf/type/__package_apt/gencode-remote is NOT executable, running it with /bin/sh -e +DEBUG: localhost: Iteration in sequential mode +VERBOSE: localhost: Running object __package/tzdata +DEBUG: localhost: Generating code for __package/tzdata +DEBUG: localhost: Iteration in sequential mode +VERBOSE: localhost: Preparing object __link/etc/localtime +VERBOSE: localhost: Running manifest and explorers for __link/etc/localtime +VERBOSE: localhost: Running type explorers for +VERBOSE: localhost: Running object __link/etc/localtime +DEBUG: localhost: Generating code for __link/etc/localtime +DEBUG: localhost: /tmp/tmp4qn81ovh/421aa90e079fa326b6494f812ad13e79/data/conf/type/__link/gencode-remote is NOT executable, running it with /bin/sh -e +VERBOSE: localhost: Running object __timezone/Asia/Seoul +DEBUG: localhost: Generating code for __timezone/Asia/Seoul +DEBUG: localhost: /tmp/tmp4qn81ovh/421aa90e079fa326b6494f812ad13e79/data/conf/type/__timezone/gencode-remote is NOT executable, running it with /bin/sh -e +DEBUG: localhost: Iteration in sequential mode +DEBUG: localhost: Running cleanup commands +Exit request sent. +DEBUG: localhost: cache subpath: 421aa90e079fa326b6494f812ad13e79 +INFO: localhost: Finished successful run in 2.47 seconds +VERBOSE: config: Total processing time for 1 host(s): 2.4723527431488037 + From d8df3dbfcf61cdc3b01ba1fe6d432f82476c0251 Mon Sep 17 00:00:00 2001 From: Youngjin Han Date: Wed, 6 May 2020 23:47:42 +0900 Subject: [PATCH 13/35] Learning Circle : cdist #2 update cdist.org --- .gitignore | 1 + youngjin.han/cdist.org | 14 ++++++++------ 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index 8963821..1be44a1 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ /youngjin.han/dot-cdist/type/__my_computer/manifest~ +/youngjin.han/cdist.org~ diff --git a/youngjin.han/cdist.org b/youngjin.han/cdist.org index f92d03f..4609010 100644 --- a/youngjin.han/cdist.org +++ b/youngjin.han/cdist.org @@ -1,9 +1,11 @@ -* non-singleton needs poress ID. -* singletion should be carried out by itself. -* verbosity level display me cdist processing information. -** '-v' is light information. -** '-vv' and '-vvv' iform me more cidst processing information (e.g. debug, verbose and etc) -* Log verbosity +* singleton / non-singleton +** non-singleton needs process ID. +** singletion should be carried out by itself. +* verbosity +** verbosity level display me cdist processing information. +*** '-v' is light information. +*** '-vv' and '-vvv' iform me more cidst processing information (e.g. debug, verbose and etc) +* log : verbosity ** -v INFO: localhost: Starting configuration run INFO: localhost: Processing __apt_update_index/ From 182b2aa9df16dd34e46ae38ae04876b1ee282b96 Mon Sep 17 00:00:00 2001 From: Youngjin Han Date: Sat, 9 May 2020 00:25:57 +0900 Subject: [PATCH 14/35] Learning Circle : cdist #3 initial commit --- .../type/__colourful_file/file/colourful | 9 ++++++++ .../dot-cdist/type/__colourful_file/manifest | 14 +++++++++++++ .../type/__colourful_file/parameter/optional | 1 + .../dot-cdist/type/__colourful_file/singleton | 0 youngjin.han/learning-node02-2020.org | 21 +++++++++++++++++++ 5 files changed, 45 insertions(+) create mode 100644 youngjin.han/dot-cdist/type/__colourful_file/file/colourful create mode 100644 youngjin.han/dot-cdist/type/__colourful_file/manifest create mode 100644 youngjin.han/dot-cdist/type/__colourful_file/parameter/optional create mode 100644 youngjin.han/dot-cdist/type/__colourful_file/singleton diff --git a/youngjin.han/dot-cdist/type/__colourful_file/file/colourful b/youngjin.han/dot-cdist/type/__colourful_file/file/colourful new file mode 100644 index 0000000..79fda42 --- /dev/null +++ b/youngjin.han/dot-cdist/type/__colourful_file/file/colourful @@ -0,0 +1,9 @@ +colour=\ +yellow\ +black\ +white\ +grey\ +puple\ +green\ +red\ +blue \ No newline at end of file diff --git a/youngjin.han/dot-cdist/type/__colourful_file/manifest b/youngjin.han/dot-cdist/type/__colourful_file/manifest new file mode 100644 index 0000000..7248b48 --- /dev/null +++ b/youngjin.han/dot-cdist/type/__colourful_file/manifest @@ -0,0 +1,14 @@ +#!/bin/sh -e + +__file ~/colourful +printf "colour=" > ~/colourful + +# parameter with multiple values +if [ -f "$__object/parameter/colour" ]; then + colour="$(cat "$__object/parameter/colour")" + echo $colour >> ~/colourful +# for alias in $(cat "$__object/parameter/colour"); do +# echo $alias >> ~/colourful +# done +fi + diff --git a/youngjin.han/dot-cdist/type/__colourful_file/parameter/optional b/youngjin.han/dot-cdist/type/__colourful_file/parameter/optional new file mode 100644 index 0000000..b0d95fa --- /dev/null +++ b/youngjin.han/dot-cdist/type/__colourful_file/parameter/optional @@ -0,0 +1 @@ +colour diff --git a/youngjin.han/dot-cdist/type/__colourful_file/singleton b/youngjin.han/dot-cdist/type/__colourful_file/singleton new file mode 100644 index 0000000..e69de29 diff --git a/youngjin.han/learning-node02-2020.org b/youngjin.han/learning-node02-2020.org index 1fb6d2c..fa69ac2 100644 --- a/youngjin.han/learning-node02-2020.org +++ b/youngjin.han/learning-node02-2020.org @@ -1,3 +1,24 @@ +* 2020-05-08 +*** cdist #3: type parameters +**** Lecture content +***** TODO Create a new type named *__colourful_file* +****** TODO The objective is to create a type that creates colourful file +****** TODO The content of the file should be "colour=...", where "..." is a colour specified by a parameter +****** TODO Add an *optional parameter* named *colour* +****** TODO Use the **__file** type inside your type to create a file +****** TODO Use the *$__object_id* variable inside your type +***** TODO Extend your type to be more colourful +****** TODO Modify the *optional parameter* to be able to be specified *multiple times* +****** TODO For each time it is specified, add a line "colour=..." to the file +***** TODO Create a new type *__my_dotfiles* +****** TODO Objective is to manage the dotfiles in your home directory +****** TODO Make it a *singleton* type +****** TODO Create a sub directory *files* in the type +****** TODO Add your .emacs config to the files folder +****** TODO Add a *for* loop to your type to deploy .[A-z]* to your home directory +****** TODO Add a .bashrc or .zshrc to the files folder (depending on your shell) +****** TODO In the initial manifest, add __my_dotfiles when the target host is localhost +***** TODO As usual commit all changes to your ungleich-learning-circle repo * 2020-05-06 ** cdist #2: Your first cdist type **** Lecture content From 2a07d12665d4173e13737314e2c8202fd89b76de Mon Sep 17 00:00:00 2001 From: Youngjin Han Date: Sat, 9 May 2020 00:27:49 +0900 Subject: [PATCH 15/35] Learning Circle : cdist #3 2nd commit --- youngjin.han/dot-cdist/manifest/init | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/youngjin.han/dot-cdist/manifest/init b/youngjin.han/dot-cdist/manifest/init index 1645f89..2bca0b6 100644 --- a/youngjin.han/dot-cdist/manifest/init +++ b/youngjin.han/dot-cdist/manifest/init @@ -4,6 +4,12 @@ case "$__target_host" in localhost) __motd __timezone Asia/Seoul +# __my_computer + __colourful_file --colour yellow + ;; + jafo.laptop) + __motd + __timezone Asia/Seoul __my_computer ;; esac From 46e78f1a15b10ed0becda53de6adc4a99b516053 Mon Sep 17 00:00:00 2001 From: Youngjin Han Date: Wed, 13 May 2020 23:37:30 +0900 Subject: [PATCH 16/35] Learning Circle : cidst #5 - initial commit --- youngjin.han/dot-cdist/manifest/init | 9 +++- .../dot-cdist/type/__colourful_file/manifest | 0 .../dot-cdist/type/__my_nginx/manifest | 8 +++ .../dot-cdist/type/__my_nginx/singleton | 0 .../type/__my_nginx_site/gencode-remote | 1 + .../type/__my_nginx_site/gencode-remote~ | 1 + .../dot-cdist/type/__my_nginx_site/manifest | 42 +++++++++++++++ .../dot-cdist/type/__my_nginx_site/manifest~ | 42 +++++++++++++++ youngjin.han/learning-node02-2020.org | 52 +++++++++++++++++++ 9 files changed, 153 insertions(+), 2 deletions(-) mode change 100644 => 100755 youngjin.han/dot-cdist/type/__colourful_file/manifest create mode 100755 youngjin.han/dot-cdist/type/__my_nginx/manifest create mode 100644 youngjin.han/dot-cdist/type/__my_nginx/singleton create mode 100644 youngjin.han/dot-cdist/type/__my_nginx_site/gencode-remote create mode 100644 youngjin.han/dot-cdist/type/__my_nginx_site/gencode-remote~ create mode 100755 youngjin.han/dot-cdist/type/__my_nginx_site/manifest create mode 100755 youngjin.han/dot-cdist/type/__my_nginx_site/manifest~ diff --git a/youngjin.han/dot-cdist/manifest/init b/youngjin.han/dot-cdist/manifest/init index 2bca0b6..5d18418 100644 --- a/youngjin.han/dot-cdist/manifest/init +++ b/youngjin.han/dot-cdist/manifest/init @@ -5,11 +5,16 @@ case "$__target_host" in __motd __timezone Asia/Seoul # __my_computer - __colourful_file --colour yellow +# __colourful_file --colour yellow + __my_nginx_site $__target_host ;; jafo.laptop) __motd __timezone Asia/Seoul - __my_computer +# __my_computer + ;; + *) +# __my_nginx + __my_nginx_site $__target_host ;; esac diff --git a/youngjin.han/dot-cdist/type/__colourful_file/manifest b/youngjin.han/dot-cdist/type/__colourful_file/manifest old mode 100644 new mode 100755 diff --git a/youngjin.han/dot-cdist/type/__my_nginx/manifest b/youngjin.han/dot-cdist/type/__my_nginx/manifest new file mode 100755 index 0000000..90602ab --- /dev/null +++ b/youngjin.han/dot-cdist/type/__my_nginx/manifest @@ -0,0 +1,8 @@ +#!/bin/sh -e + +# update package index +__apt_update_index + +require="__apt_update_index" __package nginx --state=present + + diff --git a/youngjin.han/dot-cdist/type/__my_nginx/singleton b/youngjin.han/dot-cdist/type/__my_nginx/singleton new file mode 100644 index 0000000..e69de29 diff --git a/youngjin.han/dot-cdist/type/__my_nginx_site/gencode-remote b/youngjin.han/dot-cdist/type/__my_nginx_site/gencode-remote new file mode 100644 index 0000000..608991e --- /dev/null +++ b/youngjin.han/dot-cdist/type/__my_nginx_site/gencode-remote @@ -0,0 +1 @@ +echo "sudo service nginx reload" diff --git a/youngjin.han/dot-cdist/type/__my_nginx_site/gencode-remote~ b/youngjin.han/dot-cdist/type/__my_nginx_site/gencode-remote~ new file mode 100644 index 0000000..9adb30b --- /dev/null +++ b/youngjin.han/dot-cdist/type/__my_nginx_site/gencode-remote~ @@ -0,0 +1 @@ +echo "service nginx reload" diff --git a/youngjin.han/dot-cdist/type/__my_nginx_site/manifest b/youngjin.han/dot-cdist/type/__my_nginx_site/manifest new file mode 100755 index 0000000..907798b --- /dev/null +++ b/youngjin.han/dot-cdist/type/__my_nginx_site/manifest @@ -0,0 +1,42 @@ +#!/bin/sh -e + +nginx_config_dir="/etc/nginx/conf.d" +domain="$__object_id" + +__directory /var/www/html/$domain \ + --parents --mode 0644 + +require="__directory//var/www/html/$domain" \ + __file /var/www/html/$domain/index.html \ + --source - --mode 0644 << EOF +Hello Cdist!!! +EOF + +__my_nginx + +# configure nginx +require="__my_nginx" \ + __file "$nginx_config_dir/${domain}.conf" \ + --mode 0644 --source - << EOF +server { + listen 80; + listen [::]:80; + + server_name $domaini; + + access_log /var/log/nginx/access.log; + + client_max_body_size 256m; + + location / { + root /var/www/html/$domain; + index index.html index.htm; + } + + error_page 500 502 503 504 /50x.html; + + location = /50x.html { + root /var/www/html/$domain; + } +} +EOF diff --git a/youngjin.han/dot-cdist/type/__my_nginx_site/manifest~ b/youngjin.han/dot-cdist/type/__my_nginx_site/manifest~ new file mode 100755 index 0000000..56e3762 --- /dev/null +++ b/youngjin.han/dot-cdist/type/__my_nginx_site/manifest~ @@ -0,0 +1,42 @@ +#!/bin/sh -e + +nginx_config_dir="/etc/nginx/conf.d" +domain="$__object_id" + +__directory /var/www/html/$domain \ + --parents --mode 0644 + +require="__directory//var/www/html/$domain" \ + __file /var/www/html/$domain/index.html \ + --source - --mode 0644 << EOF +Hello Cdist!!! +EOF + +__my_nginx + +# configure nginx +require="__my_nginx" \ + __file "$nginx_config_dir/${domain}.conf" \ + --mode 0644 --source - << EOF +server { + listen 80; + listen [::]:80; + + server_name $domain; + + access_log /var/log/nginx/access.log; + + client_max_body_size 256m; + + location / { + root /var/www/html/$domain; + index index.html index.htm; + } + + error_page 500 502 503 504 /50x.html; + + location = /50x.html { + root /var/www/html/$domain; + } +} +EOF diff --git a/youngjin.han/learning-node02-2020.org b/youngjin.han/learning-node02-2020.org index fa69ac2..05d6388 100644 --- a/youngjin.han/learning-node02-2020.org +++ b/youngjin.han/learning-node02-2020.org @@ -1,3 +1,55 @@ +* 2020-05-13 +*** cdist #5: Generating Code & Exploring +**** Lecture content +***** Objective + - Understand how to *generate code* and when to use it + - Exploring explorers +***** Code generation steps + - Modify the previously created type *__my_nginx_site* + - Read about cdist messaging + - If there was a change in the nginx configuration file, reload nginx +***** Explorer steps + - Modify the *__my_nginx_site* type to use the *os explorer* + - Adjust your type to work on Alpine Linux and Debian (or two + other Linux distributions of your choice) + - Set the nginx configuration directory accordingly +***** Documentation + - Explain the following in your cdist.org file + - What is the difference between gencode-remote and the remote code? + - What is the difference between gencode-local and gencode-remote? + - Locate a type that comes with upstream cdist that uses + gencode-local - which one is it? Why does it need gencode-local? +* 2020-05-11 +*** cdist #4: Requirements +**** Lecture content +***** Objective +****** Understand how requirements work +***** DONE Create a new type *__my_nginx* + CLOSED: [2020-05-12 화 02:22] +****** Make it a *singleton* +****** Make it install nginx +****** Configure a host with it +****** Usually nginx is configured includes some files +****** On the target host find out which directory nginx includes +****** We name this directory *nginx_config_dir* +***** DONE Create a new type *__my_nginx_site* + CLOSED: [2020-05-12 화 02:22] +****** Assume the *object_id* is a *domain* +****** In the __my_nginx_site create a file inside the *nginx_config_dir* +****** The filename is *${domain}.conf* +****** When using *__file*, it should *require* the *nginx package* +******* Read about cdist dependencies +****** The file should be a valid nginx configuration +****** The *server name* should be set to the specified domain +****** The *root* directive should point to /var/www/html/DOMAIN +******* (replace DOMAIN with the actual domain) +***** Use both types in the initial manifest to configure the target host +****** Create at least two domains +***** Configure the target host +****** Verify that the configuration files are properly created +***** Delete the nginx package manually on the target host +***** Comment out *__my_nginx* from the initial manifest, keep the *__my_nginx_site* +****** Explain the error that you get (in your cdist.org file) * 2020-05-08 *** cdist #3: type parameters **** Lecture content From 7a5c11a44fdd58ec9fb2c13ef2ca2bd03aec8c8c Mon Sep 17 00:00:00 2001 From: Youngjin Han Date: Thu, 14 May 2020 00:02:17 +0900 Subject: [PATCH 17/35] Learning Circle : cdist #5 - update 1 --- youngjin.han/dot-cdist/type/__my_nginx_site/manifest | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/youngjin.han/dot-cdist/type/__my_nginx_site/manifest b/youngjin.han/dot-cdist/type/__my_nginx_site/manifest index 907798b..56e3762 100755 --- a/youngjin.han/dot-cdist/type/__my_nginx_site/manifest +++ b/youngjin.han/dot-cdist/type/__my_nginx_site/manifest @@ -22,7 +22,7 @@ server { listen 80; listen [::]:80; - server_name $domaini; + server_name $domain; access_log /var/log/nginx/access.log; From 18f5b6abfbb77274d88568293abd18da93c8a7cb Mon Sep 17 00:00:00 2001 From: Youngjin Han Date: Thu, 14 May 2020 00:08:42 +0900 Subject: [PATCH 18/35] Learning Circle : cdist #5 - update 2 --- youngjin.han/dot-cdist/type/__my_nginx_site/manifest | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/youngjin.han/dot-cdist/type/__my_nginx_site/manifest b/youngjin.han/dot-cdist/type/__my_nginx_site/manifest index 56e3762..0b17ddf 100755 --- a/youngjin.han/dot-cdist/type/__my_nginx_site/manifest +++ b/youngjin.han/dot-cdist/type/__my_nginx_site/manifest @@ -1,5 +1,17 @@ #!/bin/sh -e +os=$(cat "$__global/explorer/os") + +case "$os" in + devuan) + : + ;; + *) + echo "OS $os currently not supported" >&2 + exit 1 + ;; +esac + nginx_config_dir="/etc/nginx/conf.d" domain="$__object_id" From d869b8c9386df7e54b8bf5d6e862e1651af15da1 Mon Sep 17 00:00:00 2001 From: Youngjin Han Date: Thu, 14 May 2020 00:55:29 +0900 Subject: [PATCH 19/35] Learning Circle : cdist #5 - update 3 --- youngjin.han/cdist.org | 5 +++++ youngjin.han/dot-cdist/type/__my_nginx_site/manifest | 4 ++-- youngjin.han/learning-node02-2020.org | 9 ++++++--- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/youngjin.han/cdist.org b/youngjin.han/cdist.org index 4609010..4e9c0bc 100644 --- a/youngjin.han/cdist.org +++ b/youngjin.han/cdist.org @@ -1,3 +1,8 @@ +* cidst #5 + - gencode-remote : is executed on the target + - remote code : behave as if it where ssh (e.g. ssh -o User=root) + - gencode-local : is executed locally + - __file has gencode-local that is need to excute and debug commands * singleton / non-singleton ** non-singleton needs process ID. ** singletion should be carried out by itself. diff --git a/youngjin.han/dot-cdist/type/__my_nginx_site/manifest b/youngjin.han/dot-cdist/type/__my_nginx_site/manifest index 0b17ddf..1e08e8b 100755 --- a/youngjin.han/dot-cdist/type/__my_nginx_site/manifest +++ b/youngjin.han/dot-cdist/type/__my_nginx_site/manifest @@ -5,11 +5,11 @@ os=$(cat "$__global/explorer/os") case "$os" in devuan) : - ;; + ;; *) echo "OS $os currently not supported" >&2 exit 1 - ;; + ;; esac nginx_config_dir="/etc/nginx/conf.d" diff --git a/youngjin.han/learning-node02-2020.org b/youngjin.han/learning-node02-2020.org index 05d6388..10f0f3d 100644 --- a/youngjin.han/learning-node02-2020.org +++ b/youngjin.han/learning-node02-2020.org @@ -4,16 +4,19 @@ ***** Objective - Understand how to *generate code* and when to use it - Exploring explorers -***** Code generation steps +***** DONE Code generation steps + CLOSED: [2020-05-14 목 00:54] - Modify the previously created type *__my_nginx_site* - Read about cdist messaging - If there was a change in the nginx configuration file, reload nginx -***** Explorer steps +***** DONE Explorer steps + CLOSED: [2020-05-14 목 00:54] - Modify the *__my_nginx_site* type to use the *os explorer* - Adjust your type to work on Alpine Linux and Debian (or two other Linux distributions of your choice) - Set the nginx configuration directory accordingly -***** Documentation +***** DONE Documentation + CLOSED: [2020-05-14 목 00:54] - Explain the following in your cdist.org file - What is the difference between gencode-remote and the remote code? - What is the difference between gencode-local and gencode-remote? From c4d7a41bc75d19a6608493bc7438b7c5a1dceebf Mon Sep 17 00:00:00 2001 From: Youngjin Han Date: Wed, 13 May 2020 18:02:09 +0200 Subject: [PATCH 20/35] Delete gencode-remote~ --- youngjin.han/dot-cdist/type/__my_nginx_site/gencode-remote~ | 1 - 1 file changed, 1 deletion(-) delete mode 100644 youngjin.han/dot-cdist/type/__my_nginx_site/gencode-remote~ diff --git a/youngjin.han/dot-cdist/type/__my_nginx_site/gencode-remote~ b/youngjin.han/dot-cdist/type/__my_nginx_site/gencode-remote~ deleted file mode 100644 index 9adb30b..0000000 --- a/youngjin.han/dot-cdist/type/__my_nginx_site/gencode-remote~ +++ /dev/null @@ -1 +0,0 @@ -echo "service nginx reload" From 549b45fc4ff1eda0c799ea17d4c0225f86ed7124 Mon Sep 17 00:00:00 2001 From: Youngjin Han Date: Wed, 13 May 2020 18:02:20 +0200 Subject: [PATCH 21/35] Delete manifest~ --- .../dot-cdist/type/__my_nginx_site/manifest~ | 42 ------------------- 1 file changed, 42 deletions(-) delete mode 100755 youngjin.han/dot-cdist/type/__my_nginx_site/manifest~ diff --git a/youngjin.han/dot-cdist/type/__my_nginx_site/manifest~ b/youngjin.han/dot-cdist/type/__my_nginx_site/manifest~ deleted file mode 100755 index 56e3762..0000000 --- a/youngjin.han/dot-cdist/type/__my_nginx_site/manifest~ +++ /dev/null @@ -1,42 +0,0 @@ -#!/bin/sh -e - -nginx_config_dir="/etc/nginx/conf.d" -domain="$__object_id" - -__directory /var/www/html/$domain \ - --parents --mode 0644 - -require="__directory//var/www/html/$domain" \ - __file /var/www/html/$domain/index.html \ - --source - --mode 0644 << EOF -Hello Cdist!!! -EOF - -__my_nginx - -# configure nginx -require="__my_nginx" \ - __file "$nginx_config_dir/${domain}.conf" \ - --mode 0644 --source - << EOF -server { - listen 80; - listen [::]:80; - - server_name $domain; - - access_log /var/log/nginx/access.log; - - client_max_body_size 256m; - - location / { - root /var/www/html/$domain; - index index.html index.htm; - } - - error_page 500 502 503 504 /50x.html; - - location = /50x.html { - root /var/www/html/$domain; - } -} -EOF From 65ddc29dbde9fd7c4525ea8e05b2d2cb48cdbce8 Mon Sep 17 00:00:00 2001 From: Youngjin Han Date: Fri, 15 May 2020 19:50:26 +0900 Subject: [PATCH 22/35] Learning Circle : cdist #6 - update contents --- .gitignore | 2 + youngjin.han/learning-node02-2020.org | 109 ++++++++++++++++++-------- 2 files changed, 78 insertions(+), 33 deletions(-) diff --git a/.gitignore b/.gitignore index 1be44a1..a7ddd91 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ /youngjin.han/dot-cdist/type/__my_computer/manifest~ /youngjin.han/cdist.org~ +/youngjin.han/dot-cdist/type/__colourful_file/file/colourful~ +/youngjin.han/dot-cdist/type/__colourful_file/manifest~ diff --git a/youngjin.han/learning-node02-2020.org b/youngjin.han/learning-node02-2020.org index 10f0f3d..88b148b 100644 --- a/youngjin.han/learning-node02-2020.org +++ b/youngjin.han/learning-node02-2020.org @@ -1,3 +1,46 @@ +* 2020-05-15 +*** cdist #6: Glueing it together +**** Lecture content +***** Objective + - Apply learnings from the previous cdist sessions +***** Steps 1: *__all_in_one* (1.25h) + - Create a new type named *__all_in_one* + - Decide yourself whether it is a singleton or not + - Reason why in your cdist.org file + - It should work on alpine, debian and fedora + - It accepts the following parameters: + - *--with-x* (boolean) + - *--extra-packages* (optional multiple) + - On Alpine, it should install netcat-openbsd and tshark + - On Debian, it should install netcat tshark + - On Fedora, it should install nmap-ncat wireshark-cli + - On all operating systems install socat sipcalc sudo + - If the detected operating system is neither + Alpine/Debian/Fedora, output an error message and abort the + manifest with exit code 1 + - Additionally install all packages specified by the *--extra-packages* parameter +***** Steps 2: *__firewall* (1.25h) + - Create a new type *__my_firewall* + - Add a *type explorer* to find out whether nft is present on + the target system + - Add a required parameter named *file* + - If the type explorer does not detect nft on the target system, + abort with an error message + - Deploy the specified file to */etc/my-nftables* + - Add a *type explorer* that reads the current nft rules + - If the rules are different on the target host, apply the new + ruleset by generating code in *gencode-remote* + - If the filename specified by the *file* parameter is *-* (the + minus sign), then the type should read from *stdin* +***** Step 3: manifest (0.5h) + - Create a new manifest in the folder that contains the initial manifest + - Name the new manifest *firewall* + - Source the *firewall* manifest in the *initial* manifest + - In the *firewall* manifest, match on *localhost* + - Install nftables + - Use the *__firewall* type + - Use correct *require* parameter to ensure that nftables is + installed before the *__firewall* type is run * 2020-05-13 *** cdist #5: Generating Code & Exploring **** Lecture content @@ -26,53 +69,53 @@ *** cdist #4: Requirements **** Lecture content ***** Objective -****** Understand how requirements work + - Understand how requirements work ***** DONE Create a new type *__my_nginx* CLOSED: [2020-05-12 화 02:22] -****** Make it a *singleton* -****** Make it install nginx -****** Configure a host with it -****** Usually nginx is configured includes some files -****** On the target host find out which directory nginx includes -****** We name this directory *nginx_config_dir* + - Make it a *singleton* + - Make it install nginx + - Configure a host with it + - Usually nginx is configured includes some files + - On the target host find out which directory nginx includes + - We name this directory *nginx_config_dir* ***** DONE Create a new type *__my_nginx_site* CLOSED: [2020-05-12 화 02:22] -****** Assume the *object_id* is a *domain* -****** In the __my_nginx_site create a file inside the *nginx_config_dir* -****** The filename is *${domain}.conf* -****** When using *__file*, it should *require* the *nginx package* -******* Read about cdist dependencies -****** The file should be a valid nginx configuration -****** The *server name* should be set to the specified domain -****** The *root* directive should point to /var/www/html/DOMAIN -******* (replace DOMAIN with the actual domain) + - Assume the *object_id* is a *domain* + - In the __my_nginx_site create a file inside the *nginx_config_dir* + - The filename is *${domain}.conf* + - When using *__file*, it should *require* the *nginx package* + - Read about cdist dependencies + - The file should be a valid nginx configuration + - The *server name* should be set to the specified domain + - The *root* directive should point to /var/www/html/DOMAIN + - (replace DOMAIN with the actual domain) ***** Use both types in the initial manifest to configure the target host -****** Create at least two domains + - Create at least two domains ***** Configure the target host -****** Verify that the configuration files are properly created + - Verify that the configuration files are properly created ***** Delete the nginx package manually on the target host ***** Comment out *__my_nginx* from the initial manifest, keep the *__my_nginx_site* -****** Explain the error that you get (in your cdist.org file) + - Explain the error that you get (in your cdist.org file) * 2020-05-08 *** cdist #3: type parameters **** Lecture content ***** TODO Create a new type named *__colourful_file* -****** TODO The objective is to create a type that creates colourful file -****** TODO The content of the file should be "colour=...", where "..." is a colour specified by a parameter -****** TODO Add an *optional parameter* named *colour* -****** TODO Use the **__file** type inside your type to create a file -****** TODO Use the *$__object_id* variable inside your type + - The objective is to create a type that creates colourful file + - The content of the file should be "colour=...", where "..." is a colour specified by a parameter + - Add an *optional parameter* named *colour* + - Use the **__file** type inside your type to create a file + - Use the *$__object_id* variable inside your type ***** TODO Extend your type to be more colourful -****** TODO Modify the *optional parameter* to be able to be specified *multiple times* -****** TODO For each time it is specified, add a line "colour=..." to the file + - Modify the *optional parameter* to be able to be specified *multiple times* + - For each time it is specified, add a line "colour=..." to the file ***** TODO Create a new type *__my_dotfiles* -****** TODO Objective is to manage the dotfiles in your home directory -****** TODO Make it a *singleton* type -****** TODO Create a sub directory *files* in the type -****** TODO Add your .emacs config to the files folder -****** TODO Add a *for* loop to your type to deploy .[A-z]* to your home directory -****** TODO Add a .bashrc or .zshrc to the files folder (depending on your shell) -****** TODO In the initial manifest, add __my_dotfiles when the target host is localhost + - Objective is to manage the dotfiles in your home directory + - Make it a *singleton* type + - Create a sub directory *files* in the type + - Add your .emacs config to the files folder + - Add a *for* loop to your type to deploy .[A-z]* to your home directory + - Add a .bashrc or .zshrc to the files folder (depending on your shell) + - In the initial manifest, add __my_dotfiles when the target host is localhost ***** TODO As usual commit all changes to your ungleich-learning-circle repo * 2020-05-06 ** cdist #2: Your first cdist type From 91061f07fe3d7a10f584632f1d9721a0fa0d3487 Mon Sep 17 00:00:00 2001 From: Youngjin Han Date: Fri, 15 May 2020 21:13:35 +0900 Subject: [PATCH 23/35] Learning Circle : cdist #3 - update __my_dotfile --- youngjin.han/dot-cdist/manifest/init | 5 +- .../type/__colourful_file/file/colourful | 9 -- .../dot-cdist/type/__colourful_file/manifest | 12 +- .../parameter/{optional => optional_multiple} | 0 .../type/__my_dotfiles/files/.bashrc | 115 ++++++++++++++++++ .../type/__my_dotfiles/files/.profile | 24 ++++ .../dot-cdist/type/__my_dotfiles/manifest | 10 ++ .../dot-cdist/type/__my_dotfiles/singleton | 0 .../dot-cdist/type/__my_nginx_site/manifest | 4 +- youngjin.han/learning-node02-2020.org | 24 ++-- 10 files changed, 176 insertions(+), 27 deletions(-) delete mode 100644 youngjin.han/dot-cdist/type/__colourful_file/file/colourful rename youngjin.han/dot-cdist/type/__colourful_file/parameter/{optional => optional_multiple} (100%) create mode 100644 youngjin.han/dot-cdist/type/__my_dotfiles/files/.bashrc create mode 100644 youngjin.han/dot-cdist/type/__my_dotfiles/files/.profile create mode 100755 youngjin.han/dot-cdist/type/__my_dotfiles/manifest create mode 100644 youngjin.han/dot-cdist/type/__my_dotfiles/singleton diff --git a/youngjin.han/dot-cdist/manifest/init b/youngjin.han/dot-cdist/manifest/init index 5d18418..48e4995 100644 --- a/youngjin.han/dot-cdist/manifest/init +++ b/youngjin.han/dot-cdist/manifest/init @@ -5,8 +5,9 @@ case "$__target_host" in __motd __timezone Asia/Seoul # __my_computer -# __colourful_file --colour yellow - __my_nginx_site $__target_host +# __colourful_file --colour yellow --colour blue --colour red --colour green +# __my_dotfiles +# __my_nginx_site $__target_host ;; jafo.laptop) __motd diff --git a/youngjin.han/dot-cdist/type/__colourful_file/file/colourful b/youngjin.han/dot-cdist/type/__colourful_file/file/colourful deleted file mode 100644 index 79fda42..0000000 --- a/youngjin.han/dot-cdist/type/__colourful_file/file/colourful +++ /dev/null @@ -1,9 +0,0 @@ -colour=\ -yellow\ -black\ -white\ -grey\ -puple\ -green\ -red\ -blue \ No newline at end of file diff --git a/youngjin.han/dot-cdist/type/__colourful_file/manifest b/youngjin.han/dot-cdist/type/__colourful_file/manifest index 7248b48..493b7d1 100755 --- a/youngjin.han/dot-cdist/type/__colourful_file/manifest +++ b/youngjin.han/dot-cdist/type/__colourful_file/manifest @@ -1,14 +1,14 @@ #!/bin/sh -e __file ~/colourful -printf "colour=" > ~/colourful +printf "colour=\n" > ~/colourful # parameter with multiple values if [ -f "$__object/parameter/colour" ]; then - colour="$(cat "$__object/parameter/colour")" - echo $colour >> ~/colourful -# for alias in $(cat "$__object/parameter/colour"); do -# echo $alias >> ~/colourful -# done +# colour="$(cat "$__object/parameter/colour")" +# printf "$colour\n" >> ~/colourful + for alias in $(cat "$__object/parameter/colour"); do + printf "$alias\n" >> ~/colourful + done fi diff --git a/youngjin.han/dot-cdist/type/__colourful_file/parameter/optional b/youngjin.han/dot-cdist/type/__colourful_file/parameter/optional_multiple similarity index 100% rename from youngjin.han/dot-cdist/type/__colourful_file/parameter/optional rename to youngjin.han/dot-cdist/type/__colourful_file/parameter/optional_multiple diff --git a/youngjin.han/dot-cdist/type/__my_dotfiles/files/.bashrc b/youngjin.han/dot-cdist/type/__my_dotfiles/files/.bashrc new file mode 100644 index 0000000..2a25145 --- /dev/null +++ b/youngjin.han/dot-cdist/type/__my_dotfiles/files/.bashrc @@ -0,0 +1,115 @@ +# ~/.bashrc: executed by bash(1) for non-login shells. +# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc) +# for examples + +# If not running interactively, don't do anything +case $- in + *i*) ;; + *) return;; +esac + +# don't put duplicate lines or lines starting with space in the history. +# See bash(1) for more options +HISTCONTROL=ignoreboth + +# append to the history file, don't overwrite it +shopt -s histappend + +# for setting history length see HISTSIZE and HISTFILESIZE in bash(1) +HISTSIZE=1000 +HISTFILESIZE=2000 + +# check the window size after each command and, if necessary, +# update the values of LINES and COLUMNS. +shopt -s checkwinsize + +# If set, the pattern "**" used in a pathname expansion context will +# match all files and zero or more directories and subdirectories. +#shopt -s globstar + +# make less more friendly for non-text input files, see lesspipe(1) +#[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)" + +# set variable identifying the chroot you work in (used in the prompt below) +if [ -z "${debian_chroot:-}" ] && [ -r /etc/debian_chroot ]; then + debian_chroot=$(cat /etc/debian_chroot) +fi + +# set a fancy prompt (non-color, unless we know we "want" color) +case "$TERM" in + xterm-color|*-256color) color_prompt=yes;; +esac + +# uncomment for a colored prompt, if the terminal has the capability; turned +# off by default to not distract the user: the focus in a terminal window +# should be on the output of commands, not on the prompt +#force_color_prompt=yes + +if [ -n "$force_color_prompt" ]; then + if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then + # We have color support; assume it's compliant with Ecma-48 + # (ISO/IEC-6429). (Lack of such support is extremely rare, and such + # a case would tend to support setf rather than setaf.) + color_prompt=yes + else + color_prompt= + fi +fi + +if [ "$color_prompt" = yes ]; then + PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ ' +else + PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ ' +fi +unset color_prompt force_color_prompt + +# If this is an xterm set the title to user@host:dir +case "$TERM" in +xterm*|rxvt*) + PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1" + ;; +*) + ;; +esac + +# enable color support of ls and also add handy aliases +if [ -x /usr/bin/dircolors ]; then + test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)" + alias ls='ls --color=auto' + alias dir='dir --color=auto' + alias vdir='vdir --color=auto' + + alias grep='grep --color=auto' + alias fgrep='fgrep --color=auto' + alias egrep='egrep --color=auto' +fi + +# colored GCC warnings and errors +#export GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01' + +export TERM=xterm-256color + +# some more ls aliases +alias ll='ls -alF' +alias la='ls -A' +alias l='ls -CF' + +# Alias definitions. +# You may want to put all your additions into a separate file like +# ~/.bash_aliases, instead of adding them here directly. +# See /usr/share/doc/bash-doc/examples in the bash-doc package. + +if [ -f ~/.bash_aliases ]; then + . ~/.bash_aliases +fi + +# enable programmable completion features (you don't need to enable +# this, if it's already enabled in /etc/bash.bashrc and /etc/profile +# sources /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 diff --git a/youngjin.han/dot-cdist/type/__my_dotfiles/files/.profile b/youngjin.han/dot-cdist/type/__my_dotfiles/files/.profile new file mode 100644 index 0000000..6a098ff --- /dev/null +++ b/youngjin.han/dot-cdist/type/__my_dotfiles/files/.profile @@ -0,0 +1,24 @@ +# ~/.profile: executed by the command interpreter for login shells. +# This file is not read by bash(1), if ~/.bash_profile or ~/.bash_login +# exists. +# see /usr/share/doc/bash/examples/startup-files for examples. +# the files are located in the bash-doc package. + +# the default umask is set in /etc/profile; for setting the umask +# for ssh logins, install and configure the libpam-umask package. +#umask 022 + +# if running bash +if [ -n "$BASH_VERSION" ]; then + # include .bashrc if it exists + if [ -f "$HOME/.bashrc" ]; then + . "$HOME/.bashrc" + fi +fi + +# set PATH so it includes user's private bin if it exists +if [ -d "$HOME/bin" ] ; then + PATH="$HOME/bin:$PATH" +fi + +export PATH=$PATH:/sbin:/usr/sbin diff --git a/youngjin.han/dot-cdist/type/__my_dotfiles/manifest b/youngjin.han/dot-cdist/type/__my_dotfiles/manifest new file mode 100755 index 0000000..b3de322 --- /dev/null +++ b/youngjin.han/dot-cdist/type/__my_dotfiles/manifest @@ -0,0 +1,10 @@ +#!/bin/sh -e + +cd "$__type/files/" +dotfiles=$(ls -a .[A-z]*) + +for df in $dotfiles; do + __file ~/$df \ + --mode 0644 --source "$__type/files/$df" +done + diff --git a/youngjin.han/dot-cdist/type/__my_dotfiles/singleton b/youngjin.han/dot-cdist/type/__my_dotfiles/singleton new file mode 100644 index 0000000..e69de29 diff --git a/youngjin.han/dot-cdist/type/__my_nginx_site/manifest b/youngjin.han/dot-cdist/type/__my_nginx_site/manifest index 1e08e8b..d0330fc 100755 --- a/youngjin.han/dot-cdist/type/__my_nginx_site/manifest +++ b/youngjin.han/dot-cdist/type/__my_nginx_site/manifest @@ -16,11 +16,11 @@ nginx_config_dir="/etc/nginx/conf.d" domain="$__object_id" __directory /var/www/html/$domain \ - --parents --mode 0644 + --parents --mode 0755 require="__directory//var/www/html/$domain" \ __file /var/www/html/$domain/index.html \ - --source - --mode 0644 << EOF + --mode 0644 --source - << EOF Hello Cdist!!! EOF diff --git a/youngjin.han/learning-node02-2020.org b/youngjin.han/learning-node02-2020.org index 88b148b..2034589 100644 --- a/youngjin.han/learning-node02-2020.org +++ b/youngjin.han/learning-node02-2020.org @@ -89,26 +89,33 @@ - The *server name* should be set to the specified domain - The *root* directive should point to /var/www/html/DOMAIN - (replace DOMAIN with the actual domain) -***** Use both types in the initial manifest to configure the target host +***** DONE Use both types in the initial manifest to configure the target host + CLOSED: [2020-05-15 금 21:07] - Create at least two domains -***** Configure the target host +***** DONE Configure the target host + CLOSED: [2020-05-15 금 21:08] - Verify that the configuration files are properly created -***** Delete the nginx package manually on the target host -***** Comment out *__my_nginx* from the initial manifest, keep the *__my_nginx_site* +***** DONE Delete the nginx package manually on the target host + CLOSED: [2020-05-15 금 21:08] +***** DONE Comment out *__my_nginx* from the initial manifest, keep the *__my_nginx_site* + CLOSED: [2020-05-15 금 21:08] - Explain the error that you get (in your cdist.org file) * 2020-05-08 *** cdist #3: type parameters **** Lecture content -***** TODO Create a new type named *__colourful_file* +***** DONE Create a new type named *__colourful_file* + CLOSED: [2020-05-15 금 20:29] - The objective is to create a type that creates colourful file - The content of the file should be "colour=...", where "..." is a colour specified by a parameter - Add an *optional parameter* named *colour* - Use the **__file** type inside your type to create a file - Use the *$__object_id* variable inside your type -***** TODO Extend your type to be more colourful +***** DONE Extend your type to be more colourful + CLOSED: [2020-05-15 금 20:29] - Modify the *optional parameter* to be able to be specified *multiple times* - For each time it is specified, add a line "colour=..." to the file -***** TODO Create a new type *__my_dotfiles* +***** DONE Create a new type *__my_dotfiles* + CLOSED: [2020-05-15 금 21:07] - Objective is to manage the dotfiles in your home directory - Make it a *singleton* type - Create a sub directory *files* in the type @@ -116,7 +123,8 @@ - Add a *for* loop to your type to deploy .[A-z]* to your home directory - Add a .bashrc or .zshrc to the files folder (depending on your shell) - In the initial manifest, add __my_dotfiles when the target host is localhost -***** TODO As usual commit all changes to your ungleich-learning-circle repo +***** DONE As usual commit all changes to your ungleich-learning-circle repo + CLOSED: [2020-05-15 금 21:07] * 2020-05-06 ** cdist #2: Your first cdist type **** Lecture content From a21705179c924dbe14f8567692f6e35bade24c7e Mon Sep 17 00:00:00 2001 From: Youngjin Han Date: Sat, 16 May 2020 00:05:44 +0900 Subject: [PATCH 24/35] Learning Circle : cidst #6 :Initial commit --- youngjin.han/dot-cdist/manifest/init | 6 ++- .../dot-cdist/type/__all_in_one/manifest | 44 +++++++++++++++++++ .../type/__all_in_one/parameter/boolean | 1 + .../__all_in_one/parameter/optional_multiple | 1 + .../dot-cdist/type/__my_firewall/manifest | 11 +++++ .../dot-cdist/type/__my_firewall/manifest~ | 44 +++++++++++++++++++ .../type/__my_firewall/parameter/required | 1 + .../dot-cdist/type/__my_firewall/singleton | 0 youngjin.han/learning-node02-2020.org | 3 +- 9 files changed, 108 insertions(+), 3 deletions(-) create mode 100755 youngjin.han/dot-cdist/type/__all_in_one/manifest create mode 100644 youngjin.han/dot-cdist/type/__all_in_one/parameter/boolean create mode 100644 youngjin.han/dot-cdist/type/__all_in_one/parameter/optional_multiple create mode 100755 youngjin.han/dot-cdist/type/__my_firewall/manifest create mode 100755 youngjin.han/dot-cdist/type/__my_firewall/manifest~ create mode 100644 youngjin.han/dot-cdist/type/__my_firewall/parameter/required create mode 100644 youngjin.han/dot-cdist/type/__my_firewall/singleton diff --git a/youngjin.han/dot-cdist/manifest/init b/youngjin.han/dot-cdist/manifest/init index 48e4995..1de48dc 100644 --- a/youngjin.han/dot-cdist/manifest/init +++ b/youngjin.han/dot-cdist/manifest/init @@ -2,12 +2,14 @@ __file /etc/cdist-configured case "$__target_host" in localhost) - __motd - __timezone Asia/Seoul +# __motd +# __timezone Asia/Seoul # __my_computer # __colourful_file --colour yellow --colour blue --colour red --colour green # __my_dotfiles # __my_nginx_site $__target_host +# __all_in_one $__target_host --with-x --extra-packages tree --extra-packages htop + __my_firewall --file /etc/my-nftables ;; jafo.laptop) __motd diff --git a/youngjin.han/dot-cdist/type/__all_in_one/manifest b/youngjin.han/dot-cdist/type/__all_in_one/manifest new file mode 100755 index 0000000..ee5f9a7 --- /dev/null +++ b/youngjin.han/dot-cdist/type/__all_in_one/manifest @@ -0,0 +1,44 @@ +#!/bin/sh -e + +os="$(cat "$__global/explorer/os")" +default_package_name="socat sipalc sudo" + +if [ -f "$__object/parameter/with-x" ]; then + with_x="$(cat "$__object/parameter/with-x")" +else + with_x="$__object_id" +fi + +case "$os" in + alpine) + name_netcat="netcat-openbsd" + name_wireshark="tshark" + ;; + debian) + name_netcat="netcat" + name_wireshark="tshark" + ;; + fedora) + name_netcat="nmap-ncat" + name_wireshark="wireshark-cli" + ;; + *) + echo "Don't know how to manage packages on: $os" >&2 + exit 1 + : + ;; +esac + +all_package_name="$default_package_name $name_netcat $name_wireshark" + +__package_update_index + +for package in $all_package_name; + do require="__apt_update_index" __package $package --state=present +done + +if [ -f "$__object/parameter/extra-packages" ]; then + for package in $(cat "$__object/parameter/extra-packages"); do + require="__apt_update_index" __package $package --state=present + done +fi diff --git a/youngjin.han/dot-cdist/type/__all_in_one/parameter/boolean b/youngjin.han/dot-cdist/type/__all_in_one/parameter/boolean new file mode 100644 index 0000000..836c0dd --- /dev/null +++ b/youngjin.han/dot-cdist/type/__all_in_one/parameter/boolean @@ -0,0 +1 @@ +with-x diff --git a/youngjin.han/dot-cdist/type/__all_in_one/parameter/optional_multiple b/youngjin.han/dot-cdist/type/__all_in_one/parameter/optional_multiple new file mode 100644 index 0000000..2cfc07b --- /dev/null +++ b/youngjin.han/dot-cdist/type/__all_in_one/parameter/optional_multiple @@ -0,0 +1 @@ +extra-packages diff --git a/youngjin.han/dot-cdist/type/__my_firewall/manifest b/youngjin.han/dot-cdist/type/__my_firewall/manifest new file mode 100755 index 0000000..bc33c7a --- /dev/null +++ b/youngjin.han/dot-cdist/type/__my_firewall/manifest @@ -0,0 +1,11 @@ +#!/bin/sh -e + +if [ -x nft ]; then + echo "nft is founded" +else + echo "nft is not founded" + exit 1 +fi + +__file /etc/my_nftables \ + --mode 0644 diff --git a/youngjin.han/dot-cdist/type/__my_firewall/manifest~ b/youngjin.han/dot-cdist/type/__my_firewall/manifest~ new file mode 100755 index 0000000..ee5f9a7 --- /dev/null +++ b/youngjin.han/dot-cdist/type/__my_firewall/manifest~ @@ -0,0 +1,44 @@ +#!/bin/sh -e + +os="$(cat "$__global/explorer/os")" +default_package_name="socat sipalc sudo" + +if [ -f "$__object/parameter/with-x" ]; then + with_x="$(cat "$__object/parameter/with-x")" +else + with_x="$__object_id" +fi + +case "$os" in + alpine) + name_netcat="netcat-openbsd" + name_wireshark="tshark" + ;; + debian) + name_netcat="netcat" + name_wireshark="tshark" + ;; + fedora) + name_netcat="nmap-ncat" + name_wireshark="wireshark-cli" + ;; + *) + echo "Don't know how to manage packages on: $os" >&2 + exit 1 + : + ;; +esac + +all_package_name="$default_package_name $name_netcat $name_wireshark" + +__package_update_index + +for package in $all_package_name; + do require="__apt_update_index" __package $package --state=present +done + +if [ -f "$__object/parameter/extra-packages" ]; then + for package in $(cat "$__object/parameter/extra-packages"); do + require="__apt_update_index" __package $package --state=present + done +fi diff --git a/youngjin.han/dot-cdist/type/__my_firewall/parameter/required b/youngjin.han/dot-cdist/type/__my_firewall/parameter/required new file mode 100644 index 0000000..f73f309 --- /dev/null +++ b/youngjin.han/dot-cdist/type/__my_firewall/parameter/required @@ -0,0 +1 @@ +file diff --git a/youngjin.han/dot-cdist/type/__my_firewall/singleton b/youngjin.han/dot-cdist/type/__my_firewall/singleton new file mode 100644 index 0000000..e69de29 diff --git a/youngjin.han/learning-node02-2020.org b/youngjin.han/learning-node02-2020.org index 2034589..52a96fb 100644 --- a/youngjin.han/learning-node02-2020.org +++ b/youngjin.han/learning-node02-2020.org @@ -3,7 +3,8 @@ **** Lecture content ***** Objective - Apply learnings from the previous cdist sessions -***** Steps 1: *__all_in_one* (1.25h) +***** DONE Steps 1: *__all_in_one* (1.25h) + CLOSED: [2020-05-15 금 23:16] - Create a new type named *__all_in_one* - Decide yourself whether it is a singleton or not - Reason why in your cdist.org file From e28b8cbcbd2ec11fc90256bfede4eae3f5e6d401 Mon Sep 17 00:00:00 2001 From: Youngjin Han Date: Sun, 17 May 2020 23:43:35 +0900 Subject: [PATCH 25/35] Learning Circle : cdist #6 - update 1 --- .gitignore | 1 + youngjin.han/dot-cdist/manifest/init | 2 +- .../dot-cdist/type/__all_in_one/manifest | 12 +- .../dot-cdist/type/__all_in_one/singleton | 0 youngjin.han/learning-node02-2020.org | 273 +++++++----------- 5 files changed, 116 insertions(+), 172 deletions(-) create mode 100644 youngjin.han/dot-cdist/type/__all_in_one/singleton diff --git a/.gitignore b/.gitignore index a7ddd91..64f6feb 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ /youngjin.han/cdist.org~ /youngjin.han/dot-cdist/type/__colourful_file/file/colourful~ /youngjin.han/dot-cdist/type/__colourful_file/manifest~ +/youngjin.han/dot-cdist/type/__all_in_one/manifest~ diff --git a/youngjin.han/dot-cdist/manifest/init b/youngjin.han/dot-cdist/manifest/init index 1de48dc..0e17cc0 100644 --- a/youngjin.han/dot-cdist/manifest/init +++ b/youngjin.han/dot-cdist/manifest/init @@ -8,7 +8,7 @@ case "$__target_host" in # __colourful_file --colour yellow --colour blue --colour red --colour green # __my_dotfiles # __my_nginx_site $__target_host -# __all_in_one $__target_host --with-x --extra-packages tree --extra-packages htop +# __all_in_one --with-x --extra-packages tree --extra-packages htop __my_firewall --file /etc/my-nftables ;; jafo.laptop) diff --git a/youngjin.han/dot-cdist/type/__all_in_one/manifest b/youngjin.han/dot-cdist/type/__all_in_one/manifest index ee5f9a7..cf18e7b 100755 --- a/youngjin.han/dot-cdist/type/__all_in_one/manifest +++ b/youngjin.han/dot-cdist/type/__all_in_one/manifest @@ -1,12 +1,10 @@ #!/bin/sh -e os="$(cat "$__global/explorer/os")" -default_package_name="socat sipalc sudo" +default_package_name="socat sipcalc sudo" if [ -f "$__object/parameter/with-x" ]; then with_x="$(cat "$__object/parameter/with-x")" -else - with_x="$__object_id" fi case "$os" in @@ -14,7 +12,7 @@ case "$os" in name_netcat="netcat-openbsd" name_wireshark="tshark" ;; - debian) + debian|devuan) name_netcat="netcat" name_wireshark="tshark" ;; @@ -33,12 +31,12 @@ all_package_name="$default_package_name $name_netcat $name_wireshark" __package_update_index -for package in $all_package_name; - do require="__apt_update_index" __package $package --state=present +for package in $all_package_name; do + require="__package_update_index" __package $package --state=present done if [ -f "$__object/parameter/extra-packages" ]; then for package in $(cat "$__object/parameter/extra-packages"); do - require="__apt_update_index" __package $package --state=present + require="__package_update_index" __package $package --state=present done fi diff --git a/youngjin.han/dot-cdist/type/__all_in_one/singleton b/youngjin.han/dot-cdist/type/__all_in_one/singleton new file mode 100644 index 0000000..e69de29 diff --git a/youngjin.han/learning-node02-2020.org b/youngjin.han/learning-node02-2020.org index 52a96fb..40443ae 100644 --- a/youngjin.han/learning-node02-2020.org +++ b/youngjin.han/learning-node02-2020.org @@ -20,7 +20,7 @@ Alpine/Debian/Fedora, output an error message and abort the manifest with exit code 1 - Additionally install all packages specified by the *--extra-packages* parameter -***** Steps 2: *__firewall* (1.25h) +***** TODO Steps 2: *__firewall* (1.25h) - Create a new type *__my_firewall* - Add a *type explorer* to find out whether nft is present on the target system @@ -33,7 +33,7 @@ ruleset by generating code in *gencode-remote* - If the filename specified by the *file* parameter is *-* (the minus sign), then the type should read from *stdin* -***** Step 3: manifest (0.5h) +***** TODO Step 3: manifest (0.5h) - Create a new manifest in the folder that contains the initial manifest - Name the new manifest *firewall* - Source the *firewall* manifest in the *initial* manifest @@ -127,201 +127,146 @@ ***** DONE As usual commit all changes to your ungleich-learning-circle repo CLOSED: [2020-05-15 금 21:07] * 2020-05-06 -** cdist #2: Your first cdist type +*** cdist #2: Your first cdist type **** Lecture content ***** Objective ****** Begin to understand how cdist types function ***** Steps -****** DONE Create a new type named `__my_computer` - CLOSED: [2020-05-06 수 22:53] -******* DONE Mark the type as a singleton type - CLOSED: [2020-05-06 수 22:53] -******* DONE Create a `manifest` file in it - CLOSED: [2020-05-06 수 22:53] -******* DONE Use this type to install the following packages: zsh, mosh, emacs, nmap, sipcalc - CLOSED: [2020-05-06 수 22:53] -******* DONE Edit the *initial manifest* and use **__my_computer** for **localhost** - CLOSED: [2020-05-06 수 22:53] -******* DONE Match using the $__target_host variable - CLOSED: [2020-05-06 수 22:53] -****** DONE Modify your type to use a *for loop* to install the packages - CLOSED: [2020-05-06 수 22:53] -****** DONE Deploy / manage your ~/.emacs file in this type - CLOSED: [2020-05-06 수 22:53] -******* DONE Ensure that permissions and ownership are correct - CLOSED: [2020-05-06 수 22:53] -****** DONE Use different *verbosity* levels when configuring - CLOSED: [2020-05-06 수 22:54] -****** DONE Ensure that all your changes are committed and pushed in your ungleich-learning-circle repository - CLOSED: [2020-05-06 수 22:54] -******* DONE Use magit inside emacs for that - CLOSED: [2020-05-06 수 22:54] -***** DONE Documentation steps to be done in cdist.org - CLOSED: [2020-05-06 수 23:02] -****** DONE Create a new org document named `cdist.org` in the same folder as the learning.org file - CLOSED: [2020-05-06 수 23:02] -****** DONE Explain the difference between a singleton and non-singleton type - CLOSED: [2020-05-06 수 23:02] -****** DONE Explain the difference between the different verbosity levels - CLOSED: [2020-05-06 수 23:02] -****** Document (copy&paste) some of the cdist runs in a "log" section``` +****** Create a new type named `__my_computer` + - Mark the type as a singleton type + - Create a `manifest` file in it + - Use this type to install the following packages: zsh, mosh, emacs, nmap, sipcalc + - Edit the *initial manifest* and use **__my_computer** for **localhost** + - Match using the $__target_host variable +****** Modify your type to use a *for loop* to install the packages +****** Deploy / manage your ~/.emacs file in this type + - Ensure that permissions and ownership are correct +****** Use different *verbosity* levels when configuring +****** Ensure that all your changes are committed and pushed in your ungleich-learning-circle repository + - Use magit inside emacs for that +***** Documentation steps to be done in cdist.org + - Create a new org document named `cdist.org` in the same folder as the learning.org file + - Explain the difference between a singleton and non-singleton type + - Explain the difference between the different verbosity levels + - Document (copy&paste) some of the cdist runs in a "log" section``` * 2020-05-04 *** cdist #1: Introduction **** Lecture content ***** Objective -****** Begin to use cdist + - Begin to use cdist ***** Steps -****** DONE Checkout cdist quickstart https://www.cdi.st/manual/latest/cdist-quickstart.html - CLOSED: [2020-05-04 월 22:32] -****** DONE Install cdist locally - CLOSED: [2020-05-04 월 22:32] -****** DONE Create a new cdist configuration directory in ~/ungleich-learning-circle/USERNAME/dot-cdist - CLOSED: [2020-05-04 월 22:32] -****** DONE Create an empty initial manifest ("use touch") - CLOSED: [2020-05-04 월 22:32] -****** DONE Commit that status - CLOSED: [2020-05-04 월 22:37] -****** DONE Ensure that you can login as root to localhost via ssh without a password - CLOSED: [2020-05-04 월 22:37] -****** DONE Configure cdist to configures the motd of your localhost - CLOSED: [2020-05-05 화 00:42] -******* DONE Ensure you have a case block matching on $__target_host - CLOSED: [2020-05-05 화 00:21] -******* DONE Use the -c parameter to cdist to specify the configuration directory - CLOSED: [2020-05-04 월 23:58] -******* DONE Use the -vv parameter to get more verbose output - CLOSED: [2020-05-04 월 23:57] -******* DONE Search for / understand what MOTD stands for - CLOSED: [2020-05-05 화 00:41] -****** DONE Configure cdist to create the file /etc/cdist-configured - CLOSED: [2020-05-04 월 23:33] -****** DONE Configure cdist to setup the timezone on your local computer - CLOSED: [2020-05-04 월 23:33] -****** DONE Configure cdist to ensure emacs is installed - CLOSED: [2020-05-04 월 23:47] -****** DONE Ensure that in the end all changes are committed in your repository - CLOSED: [2020-05-05 화 00:42] + - Checkout cdist quickstart https://www.cdi.st/manual/latest/cdist-quickstart.html + - Install cdist locally + - Create a new cdist configuration directory in ~/ungleich-learning-circle/USERNAME/dot-cdist + - Create an empty initial manifest ("use touch") + - Commit that status + - Ensure that you can login as root to localhost via ssh without a password + - Configure cdist to configures the motd of your localhost + - Ensure you have a case block matching on $__target_host + - Use the -c parameter to cdist to specify the configuration directory + - Use the -vv parameter to get more verbose output + - Search for / understand what MOTD stands for + - Configure cdist to create the file /etc/cdist-configured + - Configure cdist to setup the timezone on your local computer + - Configure cdist to ensure emacs is installed + - Ensure that in the end all changes are committed in your repository * 2020-05-01 *** Organisation #5: Emacs refresher **** Lecture content ***** Objective: get confident with emacs commands ***** Find out and document how to do the following steps -****** DONE Search for something forward C-s - CLOSED: [2020-05-01 금 21:40] -****** DONE How to continue searching C-s C-s - CLOSED: [2020-05-01 금 21:43] -****** DONE Search for something backward C-r - CLOSED: [2020-05-01 금 21:55] -****** DONE Search for regular expressions instead of string (forward, backward) C-M-s C-M-r - CLOSED: [2020-05-01 금 22:25] -****** DONE Go to the beginning of the line C-a - CLOSED: [2020-05-01 금 22:16] -****** DONE Go to the end of the line C-e - CLOSED: [2020-05-01 금 22:16] -****** DONE Delete a word in front (to the right of the cursor) M-d - CLOSED: [2020-05-01 금 22:17] -****** DONE Delete a word in back (to the left of the cursor) M-BackSpace - CLOSED: [2020-05-01 금 22:18] -****** DONE List all "occurences" of a word in a file M-s o - CLOSED: [2020-05-01 금 22:53] -******* You can copy above instructions into an emacs buffer -******* And test it by showing all occurences of the word "Search" -****** DONE Search (GREP) for a word in all files in a directory RECURSIVELY M-x rgrep - CLOSED: [2020-05-01 금 22:46] -****** DONE Save the CURRENT buffer C-x C-s - CLOSED: [2020-05-01 금 21:55] -****** DONE Save ALL open files C-x-s - CLOSED: [2020-05-01 금 22:22] -****** DONE Split the window/buffer vertically C-x 2 - CLOSED: [2020-05-01 금 21:48] -****** DONE Split the window/buffer horizontally C-x 3 - CLOSED: [2020-05-01 금 21:48] -****** DONE Switch between the different windows C-x o - CLOSED: [2020-05-01 금 21:48] -****** DONE Close all buffers besides the active one C-x 1 - CLOSED: [2020-05-01 금 21:47] -******* Don't kill it! -****** DONE Close only the active buffer C-x 0 - CLOSED: [2020-05-01 금 21:54] -******* Don't kill it! -****** DONE Kill the active buffer C-x k - CLOSED: [2020-05-01 금 21:44] -****** DONE Describe/Explain the difference between closing and killing - CLOSED: [2020-05-01 금 22:09] -******* closing is that emac do not display the buffer. and the contents on the buffer are kept on behined screen. -******* killing is that emac delete the buffer. and if contents are not stored, it is losted -****** DONE Switch between buffers that are not shown C-x b - CLOSED: [2020-05-01 금 21:51] -******* DONE Document two very similar, but slightly different ways - CLOSED: [2020-05-01 금 23:28] -******** C-x b is that the selected buffer is displayed on the focused window -******** C-x C-b is that all buffers is dispalayed on the new window -******** C-x 4 b is that the selected buffer is displayed on the new window + - Search for something forward C-s + - How to continue searching C-s C-s + - Search for something backward C-r + - Search for regular expressions instead of string (forward, backward) C-M-s C-M-r + - Go to the beginning of the line C-a + - Go to the end of the line C-e + - Delete a word in front (to the right of the cursor) M-d + - Delete a word in back (to the left of the cursor) M-BackSpace + - List all "occurences" of a word in a file M-s o + - You can copy above instructions into an emacs buffer + - And test it by showing all occurences of the word "Search" + - Search (GREP) for a word in all files in a directory RECURSIVELY M-x rgrep + - Save the CURRENT buffer C-x C-s + - Save ALL open files C-x-s + - Split the window/buffer vertically C-x 2 + - Split the window/buffer horizontally C-x 3 + - Switch between the different windows C-x o + - Close all buffers besides the active one C-x 1 + - Don't kill it! + - Close only the active buffer C-x 0 + -* Don't kill it! + - Kill the active buffer C-x k + - Describe/Explain the difference between closing and killing + - closing is that emac do not display the buffer. and the contents on the buffer are kept on behined screen. + - killing is that emac delete the buffer. and if contents are not stored, it is losted + - Switch between buffers that are not shown C-x b + - Document two very similar, but slightly different ways + - C-x b is that the selected buffer is displayed on the focused window + - C-x C-b is that all buffers is dispalayed on the new window + - C-x 4 b is that the selected buffer is displayed on the new window ***** Outcome -****** DONE Document all above commands in your learning org sheet - CLOSED: [2020-05-01 금 23:28] -****** DONE Share your documentation at the end of the session (not before) - CLOSED: [2020-05-01 금 23:28] - + - Document all above commands in your learning org sheet + - Share your documentation at the end of the session (not before) * 2020-04-29 *** Organisation #4: Organising yourself **** Lecture content ***** Objective: have a todo list based on org mode ***** Steps -****** Configure the "org-directory" to be ~/ungleich-learning-circle/USERNAME/ -******* This is important as it will be used by the todo function later -****** Extend your function from the organisation #1 session -******* Instead of opening a fixed file, we include two variable parts: -******** The hostname of the machine -******** The year -******* Pressing F3 should open ~/ungleich-learning-circle/USERNAME/learning-$(hostname)-$(year).org -******** we call this "your personal agenda" -****** Configure mu4e to create a org-mode tasks from an email -******* Store these tasks in ~/ungleich-learning-circle/USERNAME/todo.org -****** Configure emacs to open the "org-agenda" with "C-c a" -****** List all TODO entries -****** List the agenda of the day -****** List the agenda of the week -****** Bind F8 to open the "org-todo-list" -****** Create some sample tasks in it + - Configure the "org-directory" to be ~/ungleich-learning-circle/USERNAME/ + - This is important as it will be used by the todo function later + - Extend your function from the organisation #1 session + - Instead of opening a fixed file, we include two variable parts: + - The hostname of the machine + - The year + - Pressing F3 should open ~/ungleich-learning-circle/USERNAME/learning-$(hostname)-$(year).org + - we call this "your personal agenda" + - Configure mu4e to create a org-mode tasks from an email + - Store these tasks in ~/ungleich-learning-circle/USERNAME/todo.org + - Configure emacs to open the "org-agenda" with "C-c a" + - List all TODO entries + - List the agenda of the day + - List the agenda of the week + - Bind F8 to open the "org-todo-list" + - Create some sample tasks in it ***** From now on, maintaining tasks should be -****** Pressing F3 to open your personal "logfile" -****** Adding a TODO item -****** Pressing F8 to see the tasks with priorities + - Pressing F3 to open your personal "logfile" + - Adding a TODO item + - Pressing F8 to see the tasks with priorities ***** Bonus tasks -****** Configure mu4e to store org-mode tasks in .../todo-$(hostname)-$(year).org + - Configure mu4e to store org-mode tasks in .../todo-$(hostname)-$(year).org * 2020-04-27 *** Organisation #3: Managing your emails **** Lecture content ***** Objective -****** Be able to manage all your mails in mu4e + - Be able to manage all your mails in mu4e ***** Description -****** All email is synchronised using isync/mbsync -****** Email is indexed with mu (xapian backend) -****** Email is viewed in mu4e -****** All new emails arrive in the inbox + - All email is synchronised using isync/mbsync + - Email is indexed with mu (xapian backend) + - Email is viewed in mu4e + - All new emails arrive in the inbox ***** Steps -****** Install mu4e -****** Start mu4e in emacs -****** Configure mbsync for your ungleich mail account -******* Synchronise all mails into ~/Maildir/ungleich -******* This structure leaves room for other mail accounts, like ~/Maildir/gmail -****** Verify that mbsync synchronises the mail -****** Index mails using `mu` on the command line (only first time) -****** Configure mu4e to get email with mbsync -a -****** Configure mu4e to "archive" emails into ~/Maildir/ungleich/YEAR/ -******* This gives you a good performance / organisation for the next decades -****** Configure mu4e/emacs for sending emails -****** Send other participants an email via mu4e -****** Verify that it arrives -****** "Archive" it afterwards + - Install mu4e + - Start mu4e in emacs + - Configure mbsync for your ungleich mail account + - Synchronise all mails into ~/Maildir/ungleich + - This structure leaves room for other mail accounts, like ~/Maildir/gmail + - Verify that mbsync synchronises the mail + - Index mails using `mu` on the command line (only first time) + - Configure mu4e to get email with mbsync -a + - Configure mu4e to "archive" emails into ~/Maildir/ungleich/YEAR/ + - This gives you a good performance / organisation for the next decades + - Configure mu4e/emacs for sending emails + - Send other participants an email via mu4e + - Verify that it arrives + - "Archive" it afterwards * 2020-04-24 *** Organisation #2: Creating, managing and sharing with "magit" **** Lecture content ***** Install "magit" for emacs ***** Bind C-x g to open magit-status in ~/.emacs ***** Create a new directory ~/ungleich-learning-circle/ (with emacs) -****** Use C-h b in dired mode to find out how to + - Use C-h b in dired mode to find out how to ***** Create a sub directory ~/ungleich-learning-circle/YOURNAME/ (with emacs) ***** Move your previously created learning.org file into ~/ungleich-learning-circle/YOURNAME/ (with emacs) ***** Initialise it with git (with magit) @@ -342,4 +287,4 @@ ***** Create a function that opens ~/learning.org in your ~/.emacs ***** Bind that function to "f3" (configure it in .emacs) ***** Create a new item named "2020-04-10" -****** Create a sub item "ungleich learning circle" + - Create a sub item "ungleich learning circle" From 511e667d4065dd356a19bbb0bddd81a8d8c992fc Mon Sep 17 00:00:00 2001 From: Youngjin Han Date: Mon, 18 May 2020 22:09:58 +0900 Subject: [PATCH 26/35] Learning Circle : python #1 - ex1 --- .gitignore | 1 + youngjin.han/python-the-hard-way/ex1.py | 8 ++++++++ 2 files changed, 9 insertions(+) create mode 100644 youngjin.han/python-the-hard-way/ex1.py diff --git a/.gitignore b/.gitignore index 64f6feb..3cfcda7 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ /youngjin.han/dot-cdist/type/__colourful_file/file/colourful~ /youngjin.han/dot-cdist/type/__colourful_file/manifest~ /youngjin.han/dot-cdist/type/__all_in_one/manifest~ +*.py~ diff --git a/youngjin.han/python-the-hard-way/ex1.py b/youngjin.han/python-the-hard-way/ex1.py new file mode 100644 index 0000000..0dc680f --- /dev/null +++ b/youngjin.han/python-the-hard-way/ex1.py @@ -0,0 +1,8 @@ +#print("Hello World!") +print("Hello Again") +print("I like typeing this.") +print("This is fun") +print('Yay! Printing.') +print("I'd much rather you 'not'.") +print('I "said" do not touch this.') +print("Ungleich Cidst\n") From 8ccbd1f8e2bd89b9353a1b91bdd0947b8f568dfa Mon Sep 17 00:00:00 2001 From: Youngjin Han Date: Mon, 18 May 2020 22:29:08 +0900 Subject: [PATCH 27/35] Learning Circle : python #1 - ex2 --- youngjin.han/python-the-hard-way/ex2.py | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 youngjin.han/python-the-hard-way/ex2.py diff --git a/youngjin.han/python-the-hard-way/ex2.py b/youngjin.han/python-the-hard-way/ex2.py new file mode 100644 index 0000000..6f3b06c --- /dev/null +++ b/youngjin.han/python-the-hard-way/ex2.py @@ -0,0 +1,9 @@ +# A comment, this is so you can read your program later. +# Anything after the # is ignored by python. + +print("I could have code like this.") # and the comment after is ignored + +# You can also use a comment to "disable" or comment out code: +# print("This won't run.") + +print("This will run.") From 526f0688a16c61e39b55e4ec0c4e32e3af2e5fe9 Mon Sep 17 00:00:00 2001 From: Youngjin Han Date: Mon, 18 May 2020 23:32:23 +0900 Subject: [PATCH 28/35] Learning Circle : python #1 - ex3, ex4 --- .gitignore | 7 ++----- youngjin.han/python-the-hard-way/ex3-1.py | 9 +++++++++ youngjin.han/python-the-hard-way/ex3-2.py | 4 ++++ youngjin.han/python-the-hard-way/ex3.py | 21 +++++++++++++++++++++ youngjin.han/python-the-hard-way/ex4.py | 17 +++++++++++++++++ youngjin.han/python.org | 11 +++++++++++ 6 files changed, 64 insertions(+), 5 deletions(-) create mode 100644 youngjin.han/python-the-hard-way/ex3-1.py create mode 100644 youngjin.han/python-the-hard-way/ex3-2.py create mode 100644 youngjin.han/python-the-hard-way/ex3.py create mode 100644 youngjin.han/python-the-hard-way/ex4.py create mode 100644 youngjin.han/python.org diff --git a/.gitignore b/.gitignore index 3cfcda7..87f4579 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,3 @@ -/youngjin.han/dot-cdist/type/__my_computer/manifest~ -/youngjin.han/cdist.org~ -/youngjin.han/dot-cdist/type/__colourful_file/file/colourful~ -/youngjin.han/dot-cdist/type/__colourful_file/manifest~ -/youngjin.han/dot-cdist/type/__all_in_one/manifest~ +manifest~ *.py~ +*.org~ diff --git a/youngjin.han/python-the-hard-way/ex3-1.py b/youngjin.han/python-the-hard-way/ex3-1.py new file mode 100644 index 0000000..b661883 --- /dev/null +++ b/youngjin.han/python-the-hard-way/ex3-1.py @@ -0,0 +1,9 @@ +f_pi = 3.14159265358979 + +print("org =", f_pi) +print("trans format 1 = %.2f" % f_pi) +print("trans format 2 =", round(f_pi, 2)) +print("trans format 3 = %.2f" % round(f_pi, 2)) +print("trans format 4 = {:.2f}".format(f_pi)) +print("trans format 5 = {:.2f}".format(round(f_pi, 2))) +print("trans format 6 = {:.15f}".format(round(f_pi, 2))) diff --git a/youngjin.han/python-the-hard-way/ex3-2.py b/youngjin.han/python-the-hard-way/ex3-2.py new file mode 100644 index 0000000..dd88dfd --- /dev/null +++ b/youngjin.han/python-the-hard-way/ex3-2.py @@ -0,0 +1,4 @@ +print((2**8) - 1) +print((2**16) - 1) +print((2**32) - 1) +print((2**64) - 1) diff --git a/youngjin.han/python-the-hard-way/ex3.py b/youngjin.han/python-the-hard-way/ex3.py new file mode 100644 index 0000000..1276637 --- /dev/null +++ b/youngjin.han/python-the-hard-way/ex3.py @@ -0,0 +1,21 @@ +print("Hens", 25 + 30 / 6) # 25 + (30 / 6) = 25 + 5 = 30 + +print("Roosters", 100 - 25 * 3 % 4) # 100 - (25 * 3 % 4) = 100 - (75 % 4) = 100 - 3 = 97 +print("Now I will count the eggs:") # print syntex + +print(3 + 2 + 1 - 5 + 4 % 2 - 1 / 4 + 6) # 3 + 2 + 1 - 5 + 0 - 0.25 + 6 = 6.75 + +print("Is it true that 3 + 2 < 5 - 7?") # print syntex + +print(3 + 2 < 5 - 7) # 5 < -2 => false + +print("What is 3 + 2?", 3 + 2) # 5 +print("What is 5 - 7?", 5 - 7) # -2 + +print("Oh, that's why it's False.") # print syntex + +print("How about some more.") # print syntex + +print("Is it greater?", 5 > -2) # true +print("Is it greater or equal?", 5 >= -2) # true +print("Is it less or equal?", 5 <= -2) # false diff --git a/youngjin.han/python-the-hard-way/ex4.py b/youngjin.han/python-the-hard-way/ex4.py new file mode 100644 index 0000000..203574b --- /dev/null +++ b/youngjin.han/python-the-hard-way/ex4.py @@ -0,0 +1,17 @@ +cars = 100 # amount of car +space_in_a_car = 4.0 # amount of seats in the car +drivers = 30 # amount of driver +passengers = 90 # amount of passenger +cars_not_driven = cars - drivers # amount of person which could not drive = 70 +cars_driven = drivers # amount of person which could drive = 30 +carpool_capacity = cars_driven * space_in_a_car # amount of seat for carpool = 120 +average_passengers_per_car = passengers / cars_driven # 3 + + +print("There are", cars, "cars available.") +print("There are only", drivers, "drivers available.") +print("There will be", cars_not_driven, "empty cars today.") +print("We can transport", carpool_capacity, "people today.") +print("We have", passengers, "to carpool today.") +print("We need to put about", average_passengers_per_car, + "in each car.") diff --git a/youngjin.han/python.org b/youngjin.han/python.org new file mode 100644 index 0000000..626f3d1 --- /dev/null +++ b/youngjin.han/python.org @@ -0,0 +1,11 @@ +* 2020-05-18 +** note + - ex1.py + - # is commnet. + - ex2.py + - I do't find mistakes. + - ex3.py + - none + - ex4.py + - car_pool_capacity is not defined. + From 2531ef78c5044ca9269dfbac83c89841f1b62dd9 Mon Sep 17 00:00:00 2001 From: Youngjin Han Date: Tue, 19 May 2020 00:00:27 +0900 Subject: [PATCH 29/35] Learning Circle : pytion #1 - ex5 --- youngjin.han/python-the-hard-way/ex3.py | 2 ++ youngjin.han/python-the-hard-way/ex5.py | 24 ++++++++++++++++++++++++ youngjin.han/python.org | 4 ++++ 3 files changed, 30 insertions(+) create mode 100644 youngjin.han/python-the-hard-way/ex5.py diff --git a/youngjin.han/python-the-hard-way/ex3.py b/youngjin.han/python-the-hard-way/ex3.py index 1276637..5f44bfe 100644 --- a/youngjin.han/python-the-hard-way/ex3.py +++ b/youngjin.han/python-the-hard-way/ex3.py @@ -1,3 +1,5 @@ +print("I will now count my chickens:") + print("Hens", 25 + 30 / 6) # 25 + (30 / 6) = 25 + 5 = 30 print("Roosters", 100 - 25 * 3 % 4) # 100 - (25 * 3 % 4) = 100 - (75 % 4) = 100 - 3 = 97 diff --git a/youngjin.han/python-the-hard-way/ex5.py b/youngjin.han/python-the-hard-way/ex5.py new file mode 100644 index 0000000..d38c795 --- /dev/null +++ b/youngjin.han/python-the-hard-way/ex5.py @@ -0,0 +1,24 @@ +name = 'Zed A. Shaw' +age = 35 # not a lie +height = 74 # inches +weight = 180 # lbs +eyes = 'Blue' +teeth = 'White' +hair = 'Brown' + +inch_to_cm = 2.54 +lbs_to_kg = 0.45359237 + +cm_height = height * inch_to_cm +kg_weight = weight * lbs_to_kg + +print(f"Let's talk about {name}.") +print(f"He's {height} inches or {cm_height} cm tall. ") +print(f"He's {weight} pounds or {kg_weight} kg heavy.") +print("Actually that's not too heavy.") +print(f"He's got {eyes} eyes and {hair} hair.") +print(f"His teeth are usually {teeth} depending on the coffee.") + +# this line is tricky, try to get it exactly right +total = age + height + weight +print(f"If I add {age}, {height}, and {weight} I get {total}.") diff --git a/youngjin.han/python.org b/youngjin.han/python.org index 626f3d1..8e5b4ce 100644 --- a/youngjin.han/python.org +++ b/youngjin.han/python.org @@ -8,4 +8,8 @@ - none - ex4.py - car_pool_capacity is not defined. + - ex5.py + - none + - ex6.py + - + is to add two string array. From 070ef33f38231c10938efe03184d8a255e1106b5 Mon Sep 17 00:00:00 2001 From: Youngjin Han Date: Tue, 19 May 2020 00:34:11 +0900 Subject: [PATCH 30/35] Learning Circle : python #1 - ex6 --- youngjin.han/learning-node02-2020.org | 17 +++++++++++++++++ youngjin.han/python-the-hard-way/ex6.py | 23 +++++++++++++++++++++++ youngjin.han/python.org | 3 ++- 3 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 youngjin.han/python-the-hard-way/ex6.py diff --git a/youngjin.han/learning-node02-2020.org b/youngjin.han/learning-node02-2020.org index 40443ae..ed2ab64 100644 --- a/youngjin.han/learning-node02-2020.org +++ b/youngjin.han/learning-node02-2020.org @@ -1,4 +1,21 @@ * 2020-05-15 +*** Python #1: +**** Lecture notes + - Ensure that you have python3 (at least 3.6) installed + - Use emacs for editing source files + - Commit all source code to ~/ungleich-learning-circle/USERNAME/python-the-hard-way +**** Lecture content + - Read thoroughly & do exercise 0 to 7 + - Commit your source code in git + - Commit every time you have a task done + - Make a new commit in git each time you finish (part of) a task + - Do all exercises + - Notify your fellow students when you solved something + - Ask help to other students when you are stuck (but try to solve + on your own before) +**** TODO Lecture material + - Available on https://cloud.ungleich.ch/s/435FyfrQyEq6oF3 +* 2020-05-15 *** cdist #6: Glueing it together **** Lecture content ***** Objective diff --git a/youngjin.han/python-the-hard-way/ex6.py b/youngjin.han/python-the-hard-way/ex6.py new file mode 100644 index 0000000..d086426 --- /dev/null +++ b/youngjin.han/python-the-hard-way/ex6.py @@ -0,0 +1,23 @@ +types_of_people = 10 # define a value +x = f"There are {types_of_people} types of people." # define a string with the value "types_of_people" + +binary = "binary" # define a string +do_not = "don't" # define a string +y = f"Those who know {binary} and those who {do_not}." # define a string with two string array + +print(x) # print "There are 10 types of people." +print(y) # print "Those who know binary and those who don't." + +print(f"I said: {x}") # print "I said: There are 10 types of people." +print(f"I also said: '{y}'") # print "I also said: 'Those who know binary and those who don't.'" + +hilarious = False # define a value + +joke_evaluation = "Isn't that joke so funny?! {}" # define a string + +print(joke_evaluation.format(hilarious)) # print some format string + +w = "This is the left side of..." # define a value +e = "a string with a right side." # define a value + +print(w + e) # print a diff --git a/youngjin.han/python.org b/youngjin.han/python.org index 8e5b4ce..8f36e35 100644 --- a/youngjin.han/python.org +++ b/youngjin.han/python.org @@ -12,4 +12,5 @@ - none - ex6.py - + is to add two string array. - + - ex7.py + - From 72ed0f808e1ba97e11d44046dfeb0f3e639085d2 Mon Sep 17 00:00:00 2001 From: Youngjin Han Date: Tue, 19 May 2020 23:45:50 +0900 Subject: [PATCH 31/35] Learning Circle : python #1 - ex7 --- .gitignore | 1 + youngjin.han/python-the-hard-way/ex7.py | 21 +++++++++++++++++++++ youngjin.han/python.org | 2 +- 3 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 youngjin.han/python-the-hard-way/ex7.py diff --git a/.gitignore b/.gitignore index 87f4579..9e3973d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ manifest~ *.py~ *.org~ +*.org# diff --git a/youngjin.han/python-the-hard-way/ex7.py b/youngjin.han/python-the-hard-way/ex7.py new file mode 100644 index 0000000..d7099f3 --- /dev/null +++ b/youngjin.han/python-the-hard-way/ex7.py @@ -0,0 +1,21 @@ +print("Mary had a little lamb.") # print scipts +print("Its fleece was white as {}.".format('snow')) # print scipts +print("And everywhere that Mary went.") # print scipts +print("." * 10) # what'd that do? # print dot 10 times + +end1 = "C" # define a character +end2 = "h" # define a character +end3 = "e" # define a character +end4 = "e" # define a character +end5 = "s" # define a character +end6 = "e" # define a character +end7 = "B" # define a character +end8 = "u" # define a character +end9 = "r" # define a character +end10 = "g" # define a character +end11 = "e" # define a character +end12 = "r" # define a character + +# watch end = ' ' at the end. try removing it to see what happens +print(end1 + end2 + end3 + end4 + end5 + end6, end=' ') # print "Cheese " +print(end7 + end8 + end9 + end10 + end11 + end12) # print "Burger" diff --git a/youngjin.han/python.org b/youngjin.han/python.org index 8f36e35..ff50f1e 100644 --- a/youngjin.han/python.org +++ b/youngjin.han/python.org @@ -13,4 +13,4 @@ - ex6.py - + is to add two string array. - ex7.py - - + - none From 48671bd22052596df0d2676702ab4309717a543f Mon Sep 17 00:00:00 2001 From: Youngjin Han Date: Wed, 20 May 2020 21:42:42 +0900 Subject: [PATCH 32/35] Learning Circle : python #2 - ex8, ex9 --- youngjin.han/learning-node02-2020.org | 18 ++++++++++++++++-- youngjin.han/python-the-hard-way/ex8.py | 12 ++++++++++++ youngjin.han/python-the-hard-way/ex9.py | 14 ++++++++++++++ youngjin.han/python.org | 9 +++++++++ 4 files changed, 51 insertions(+), 2 deletions(-) create mode 100644 youngjin.han/python-the-hard-way/ex8.py create mode 100644 youngjin.han/python-the-hard-way/ex9.py diff --git a/youngjin.han/learning-node02-2020.org b/youngjin.han/learning-node02-2020.org index ed2ab64..7a1fe17 100644 --- a/youngjin.han/learning-node02-2020.org +++ b/youngjin.han/learning-node02-2020.org @@ -1,10 +1,24 @@ +* 2020-05-20 +*** Python #2: +**** TODO Lecture content + - Read thoroughly & do exercises 8 to 14 + - Focus on understanding + - You don't have to type everything + - But you should ensure you understand everything + - Commit all source code to ~/ungleich-learning-circle/USERNAME/python-the-hard-way + - Write down notes / what you learned in the *python.org* file + - Notify your fellow students when you solved something + - "I just solved exercise 4!" +**** Lecture material + - Available on https://cloud.ungleich.ch/s/435FyfrQyEq6oF3 * 2020-05-15 *** Python #1: **** Lecture notes - Ensure that you have python3 (at least 3.6) installed - Use emacs for editing source files - Commit all source code to ~/ungleich-learning-circle/USERNAME/python-the-hard-way -**** Lecture content +**** DONE Lecture content + CLOSED: [2020-05-19 화 23:47] - Read thoroughly & do exercise 0 to 7 - Commit your source code in git - Commit every time you have a task done @@ -13,7 +27,7 @@ - Notify your fellow students when you solved something - Ask help to other students when you are stuck (but try to solve on your own before) -**** TODO Lecture material +**** Lecture material - Available on https://cloud.ungleich.ch/s/435FyfrQyEq6oF3 * 2020-05-15 *** cdist #6: Glueing it together diff --git a/youngjin.han/python-the-hard-way/ex8.py b/youngjin.han/python-the-hard-way/ex8.py new file mode 100644 index 0000000..6019f00 --- /dev/null +++ b/youngjin.han/python-the-hard-way/ex8.py @@ -0,0 +1,12 @@ +formatter = "{} {} {} {}" + +print(formatter.format(1, 2, 3, 4)) +print(formatter.format("one", "two", "three", "four")) +print(formatter.format(True, False, False, True)) +print(formatter.format(formatter, formatter, formatter, formatter)) +print(formatter.format( + "Try your", + "Own text here", + "Maybe a poem", + "Or a song about fear" +)) diff --git a/youngjin.han/python-the-hard-way/ex9.py b/youngjin.han/python-the-hard-way/ex9.py new file mode 100644 index 0000000..056db3b --- /dev/null +++ b/youngjin.han/python-the-hard-way/ex9.py @@ -0,0 +1,14 @@ +# Here's some new strange stuff, remember type it exactly. + +days = "Mon Tue Wed Thu Fri Sat Sun" # define a string +months = "Jan\nFeb\nMar\nApr\nMay\nJun\nJul\nAug" # define a string + +print("Here are the days: ", days) # print the days in a week +print("Here are the months: ", months) # print the months in a year with new lines + +print(""" +There's something going on here. +With the three double-quotes. +We'll be able to type as much as we like. +Even 4 lines if we want, or 5, or 6. +""") # print multiple lines with three double-quotes diff --git a/youngjin.han/python.org b/youngjin.han/python.org index ff50f1e..16fa719 100644 --- a/youngjin.han/python.org +++ b/youngjin.han/python.org @@ -1,3 +1,12 @@ +* 2020-05-20 +** note + - ex8.py + - none + - ex9.py + - none + - ex10.py + - + * 2020-05-18 ** note - ex1.py From 64bc3ef9f20847cc91eece5826cae554e4608dfa Mon Sep 17 00:00:00 2001 From: Youngjin Han Date: Wed, 20 May 2020 22:00:32 +0900 Subject: [PATCH 33/35] Learning Circle : python #2 - ex10 --- youngjin.han/python-the-hard-way/ex10.py | 29 ++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 youngjin.han/python-the-hard-way/ex10.py diff --git a/youngjin.han/python-the-hard-way/ex10.py b/youngjin.han/python-the-hard-way/ex10.py new file mode 100644 index 0000000..a8395e7 --- /dev/null +++ b/youngjin.han/python-the-hard-way/ex10.py @@ -0,0 +1,29 @@ +tabby_cat = "\tI'm tabbed in." +persian_cat = "I'm split\non a line." +backslash_cat = "I'm \\ a \\ cat." + +fat_cat = """ +I'll do a list: +\t* Cat food +\t* Fishies +\t* Catnip\n\t* Grass +""" + +fat_cat_single = ''' +I'll do a list: +\t* Cat food +\t* Fishies +\t* Catnip\n\t* Grass +''' + +new_test = """ +\t tap \a BELL \r CR \f FF +\\ \u0032 \U00000033 +""" + +print(tabby_cat) +print(persian_cat) +print(backslash_cat) +print(fat_cat) +print(fat_cat_single) +print(new_test) From c0b8006422296e2ff615af0a149da465cd96e476 Mon Sep 17 00:00:00 2001 From: Youngjin Han Date: Wed, 20 May 2020 22:17:57 +0900 Subject: [PATCH 34/35] Learning Circle : python #2 - ex11, ex12 --- youngjin.han/python-the-hard-way/ex11.py | 12 ++++++++++++ youngjin.han/python-the-hard-way/ex12.py | 5 +++++ youngjin.han/python.org | 7 ++++++- 3 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 youngjin.han/python-the-hard-way/ex11.py create mode 100644 youngjin.han/python-the-hard-way/ex12.py diff --git a/youngjin.han/python-the-hard-way/ex11.py b/youngjin.han/python-the-hard-way/ex11.py new file mode 100644 index 0000000..8392830 --- /dev/null +++ b/youngjin.han/python-the-hard-way/ex11.py @@ -0,0 +1,12 @@ +#print("How old are you?", end=' ') +#age = input() +#print("How tall are you?", end=' ') +#height = input() +#print("How much do you weigh?", end=' ') +#weight = input() + +age = input("How old are you?" ' ') +height = input("How tall are you?" ' ') +weight = input("How much do you weigh?" ' ') + +print(f"So, you're {age} old, {height} tall and {weight} heavy.") diff --git a/youngjin.han/python-the-hard-way/ex12.py b/youngjin.han/python-the-hard-way/ex12.py new file mode 100644 index 0000000..f1fcdd1 --- /dev/null +++ b/youngjin.han/python-the-hard-way/ex12.py @@ -0,0 +1,5 @@ +age = input("How old are you? ") +height = input("How tall are you? ") +weight = input("How much do you weigh? ") + +print(f"So, you're {age} old, {height} tall and {weight} heavy.") diff --git a/youngjin.han/python.org b/youngjin.han/python.org index 16fa719..dd879eb 100644 --- a/youngjin.han/python.org +++ b/youngjin.han/python.org @@ -5,7 +5,12 @@ - ex9.py - none - ex10.py - - + - none + - ex11.py + - none + - ex12.py + - pydoc input + - describe input on python. It looks like man commnad on linux shell. * 2020-05-18 ** note From b68eb529a1a255b5d3229aaa0a261075f6c9b66c Mon Sep 17 00:00:00 2001 From: Youngjin Han Date: Wed, 20 May 2020 22:47:36 +0900 Subject: [PATCH 35/35] Learning Circle : python #2 - ex13, ex14 --- youngjin.han/learning-node02-2020.org | 3 ++- youngjin.han/python-the-hard-way/ex13.py | 9 +++++++++ youngjin.han/python-the-hard-way/ex14.py | 22 ++++++++++++++++++++++ youngjin.han/python.org | 4 ++++ 4 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 youngjin.han/python-the-hard-way/ex13.py create mode 100644 youngjin.han/python-the-hard-way/ex14.py diff --git a/youngjin.han/learning-node02-2020.org b/youngjin.han/learning-node02-2020.org index 7a1fe17..687a0c3 100644 --- a/youngjin.han/learning-node02-2020.org +++ b/youngjin.han/learning-node02-2020.org @@ -1,6 +1,7 @@ * 2020-05-20 *** Python #2: -**** TODO Lecture content +**** DONE Lecture content + CLOSED: [2020-05-20 수 22:47] - Read thoroughly & do exercises 8 to 14 - Focus on understanding - You don't have to type everything diff --git a/youngjin.han/python-the-hard-way/ex13.py b/youngjin.han/python-the-hard-way/ex13.py new file mode 100644 index 0000000..56bc8fa --- /dev/null +++ b/youngjin.han/python-the-hard-way/ex13.py @@ -0,0 +1,9 @@ +from sys import argv +# read the WYSS section for how to run this +script, first, second, third, fourth = argv + +print("The script is called:", script) +print("Your first variable is:", first) +print("Your second variable is:", second) +print("Your third variable is:", third) +print("Your fourth variable is:", fourth) diff --git a/youngjin.han/python-the-hard-way/ex14.py b/youngjin.han/python-the-hard-way/ex14.py new file mode 100644 index 0000000..9f277ec --- /dev/null +++ b/youngjin.han/python-the-hard-way/ex14.py @@ -0,0 +1,22 @@ +from sys import argv + +script, user_name, age = argv +prompt = '$ ' + +print(f"Hi {user_name}, I'm the {script} script.") +print("I'd like to ask you a few questions.") +print(f"Do you like me {user_name}?") +likes = input(prompt) + +print(f"Where do you live {user_name}?") +lives = input(prompt) + +print("What kind of computer do you have?") +computer = input(prompt) + +print(f""" +Alright, so you said {likes} about liking me. +You live in {lives}. Not sure where that is. +And you have a {computer} computer. Nice. +Opps, You are {age} years old. +""") diff --git a/youngjin.han/python.org b/youngjin.han/python.org index dd879eb..e13dc10 100644 --- a/youngjin.han/python.org +++ b/youngjin.han/python.org @@ -11,6 +11,10 @@ - ex12.py - pydoc input - describe input on python. It looks like man commnad on linux shell. + - ex13.py + - none + - ex14.py + - none * 2020-05-18 ** note