gestion 1.9.12

Sign up to get free protection for your applications and to get access to all the features.
Files changed (233) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +48 -0
  3. data/.project +14 -0
  4. data/Binaries/adduser_to_buzz +15 -0
  5. data/Binaries/backup +7 -0
  6. data/Binaries/check_gestion +8 -0
  7. data/Binaries/gestion.gnumail +22 -0
  8. data/Binaries/gestion.logrotate +34 -0
  9. data/Binaries/gestion.service +12 -0
  10. data/Binaries/gestion_update.rb +183 -0
  11. data/Binaries/gestion_update.service +10 -0
  12. data/Binaries/get_compta +11 -0
  13. data/Binaries/kill_gestion +16 -0
  14. data/Binaries/ldap/add_indexes +51 -0
  15. data/Binaries/ldap/backup +2 -0
  16. data/Binaries/ldap/install_ldap +92 -0
  17. data/Binaries/ldap/restore +7 -0
  18. data/Binaries/lib_backup +5 -0
  19. data/Binaries/log_scan_errors +8 -0
  20. data/Binaries/loop_gestion +64 -0
  21. data/Binaries/onetimers/sync_courses_from_compta.rb +74 -0
  22. data/Binaries/onetimers/transfer_cash_from_ldap_to_csv +26 -0
  23. data/Binaries/reboot +5 -0
  24. data/Binaries/restore +3 -0
  25. data/Binaries/restore_do +22 -0
  26. data/Binaries/sort_events +31 -0
  27. data/Binaries/start_gestion +18 -0
  28. data/Binaries/swipe_gestion +18 -0
  29. data/Binaries/update_africompta +21 -0
  30. data/Binaries/update_users +3 -0
  31. data/Diplomas.src/accredited.odg +0 -0
  32. data/Diplomas.src/diploma.odg +0 -0
  33. data/Diplomas.src/label.odg +0 -0
  34. data/Diplomas.src/presence_sheet.ods +0 -0
  35. data/Diplomas.src/presence_sheet_small.ods +0 -0
  36. data/Diplomas.src/student_card.odg +0 -0
  37. data/Doc/130514-it-ideas.odt +0 -0
  38. data/Doc/Compta-cash.mm +179 -0
  39. data/Doc/General.odt +0 -0
  40. data/Entities/AccessGroups.rb +117 -0
  41. data/Entities/Activity.rb +178 -0
  42. data/Entities/ChatMsg.rb +142 -0
  43. data/Entities/Classroom.rb +11 -0
  44. data/Entities/Client.rb +19 -0
  45. data/Entities/Computer.rb +21 -0
  46. data/Entities/ConfigBase.rb +280 -0
  47. data/Entities/Course.rb +1588 -0
  48. data/Entities/CourseType.rb +171 -0
  49. data/Entities/DFiles.rb +466 -0
  50. data/Entities/FilesManage.rb +226 -0
  51. data/Entities/Grade.rb +186 -0
  52. data/Entities/Internet.rb +300 -0
  53. data/Entities/Netdev.rb +10 -0
  54. data/Entities/Person.rb +1175 -0
  55. data/Entities/Plug.rb +98 -0
  56. data/Entities/Quiz.rb +33 -0
  57. data/Entities/Recharges.rb +37 -0
  58. data/Entities/Report.rb +136 -0
  59. data/Entities/Room.rb +12 -0
  60. data/Entities/SMS.rb +30 -0
  61. data/Entities/ScheduleType.rb +33 -0
  62. data/Entities/Share.rb +120 -0
  63. data/Entities/Task.rb +51 -0
  64. data/Entities/Ticket.rb +72 -0
  65. data/Entities/Usage.rb +143 -0
  66. data/Entities/Worker.rb +29 -0
  67. data/Files/apache-profeda.conf +36 -0
  68. data/Files/label.erb +121 -0
  69. data/Files/label_notfound.erb +64 -0
  70. data/Files/label_notpassed.erb +84 -0
  71. data/Files/mobileinfo.erb +115 -0
  72. data/Files/smb.conf +333 -0
  73. data/Files/timetable.html +36 -0
  74. data/Files/timetable.js +239 -0
  75. data/Gemfile +12 -0
  76. data/Gemfile.dev +12 -0
  77. data/Gemfile.dev.lock +127 -0
  78. data/Gemfile.lock +127 -0
  79. data/Gemfile.prod +8 -0
  80. data/Gestion +35 -0
  81. data/Gestion.rb +220 -0
  82. data/INSTALL +40 -0
  83. data/Images/connection.xcf +0 -0
  84. data/Images/connection_no.png +0 -0
  85. data/Images/connection_wait.png +0 -0
  86. data/Images/connection_yes.png +0 -0
  87. data/Paths/Exas.rb +13 -0
  88. data/Paths/Files.rb +19 -0
  89. data/Paths/GetDiplomas.rb +20 -0
  90. data/Paths/Info.rb +114 -0
  91. data/Paths/Label.rb +187 -0
  92. data/Paths/MobileInfo.rb +19 -0
  93. data/Paths/internetCash.rb +34 -0
  94. data/Paths/internetWifi.rb +54 -0
  95. data/README.md +60 -0
  96. data/Rakefile +13 -0
  97. data/TODO +1391 -0
  98. data/Test/.gitignore +3 -0
  99. data/Test/Diplomas/base_gestion.odt +0 -0
  100. data/Test/Diplomas/base_report.odt +0 -0
  101. data/Test/Diplomas/carte_etudiant.odg +0 -0
  102. data/Test/Diplomas/exam_language.odt +0 -0
  103. data/Test/Diplomas/label.odg +0 -0
  104. data/Test/Diplomas/presence_sheet.ods +0 -0
  105. data/Test/Diplomas/presence_sheet_small.ods +0 -0
  106. data/Test/Diplomas/student_card.odg +0 -0
  107. data/Test/Manual/testMerge +18 -0
  108. data/Test/config_test.yaml +26 -0
  109. data/Test/db.testGestion +0 -0
  110. data/Test/dfiles/descs/avg-rescue.desc +10 -0
  111. data/Test/dfiles/descs/avg.desc +8 -0
  112. data/Test/dfiles/descs/driver.desc +8 -0
  113. data/Test/dfiles/descs/linuxmint.desc +7 -0
  114. data/Test/dfiles/files/avg-160203.exe +1 -0
  115. data/Test/dfiles/files/avg.iso +1 -0
  116. data/Test/dfiles/files/driver.exe +1 -0
  117. data/Test/dfiles/index_post.html +3 -0
  118. data/Test/dfiles/index_pre.html +8 -0
  119. data/Test/dfiles/priorities +5 -0
  120. data/Test/ge_activity.rb +124 -0
  121. data/Test/ge_chat.rb +106 -0
  122. data/Test/ge_compta.rb +67 -0
  123. data/Test/ge_configbase.rb +54 -0
  124. data/Test/ge_course.rb +1114 -0
  125. data/Test/ge_dfiles.rb +121 -0
  126. data/Test/ge_filesmanage.rb +180 -0
  127. data/Test/ge_info.rb +27 -0
  128. data/Test/ge_internet.rb +246 -0
  129. data/Test/ge_login.rb +55 -0
  130. data/Test/ge_person.rb +373 -0
  131. data/Test/ge_qvinfo.rb +28 -0
  132. data/Test/ge_report.rb +97 -0
  133. data/Test/ge_share.rb +27 -0
  134. data/Test/ge_sms.rb +34 -0
  135. data/Test/ge_tasks.rb +19 -0
  136. data/Test/ge_usage.rb +168 -0
  137. data/Test/ge_view.rb +46 -0
  138. data/Test/multiconf-captive +29 -0
  139. data/Test/test.conf +7 -0
  140. data/Test/test.rb +49 -0
  141. data/Test/test_bytes.png +0 -0
  142. data/VERSION +140 -0
  143. data/Views/Admin/Backup.rb +91 -0
  144. data/Views/Admin/Configuration.rb +44 -0
  145. data/Views/Admin/Credit.rb +32 -0
  146. data/Views/Admin/FilesManage.rb +219 -0
  147. data/Views/Admin/Function.rb +39 -0
  148. data/Views/Admin/Power.rb +49 -0
  149. data/Views/Admin/Printer.rb +37 -0
  150. data/Views/Admin/Server.rb +252 -0
  151. data/Views/Admin/Tabs.rb +5 -0
  152. data/Views/Admin/Update.rb +73 -0
  153. data/Views/Admin/UpdateSystem.rb +26 -0
  154. data/Views/Cashbox/Activity.rb +191 -0
  155. data/Views/Cashbox/Course.rb +141 -0
  156. data/Views/Cashbox/Credit.rb +79 -0
  157. data/Views/Cashbox/Report.rb +115 -0
  158. data/Views/Cashbox/Service.rb +105 -0
  159. data/Views/Cashbox/Tabs.rb +10 -0
  160. data/Views/Compta/Accounts.rb +36 -0
  161. data/Views/Compta/Course.rb +96 -0
  162. data/Views/Compta/Show.rb +6 -0
  163. data/Views/Compta/Transfer.rb +66 -0
  164. data/Views/Course/Diploma.rb +203 -0
  165. data/Views/Course/Grade.rb +401 -0
  166. data/Views/Course/Modify.rb +447 -0
  167. data/Views/Course/Print.rb +94 -0
  168. data/Views/Course/Responsible.rb +44 -0
  169. data/Views/Course/Stats.rb +76 -0
  170. data/Views/Course/Students.rb +92 -0
  171. data/Views/Course/Tabs.rb +220 -0
  172. data/Views/Internet/Access.rb +134 -0
  173. data/Views/Internet/ClassEdit.rb +24 -0
  174. data/Views/Internet/ClassUsers.rb +81 -0
  175. data/Views/Internet/Config.rb +32 -0
  176. data/Views/Internet/Mobile.rb +213 -0
  177. data/Views/Internet/Recharges.rb +49 -0
  178. data/Views/Internet/Tabs.rb +6 -0
  179. data/Views/Inventory/Computer.rb +24 -0
  180. data/Views/Inventory/Room.rb +18 -0
  181. data/Views/Inventory/Tabs.rb +9 -0
  182. data/Views/Inventory/TicketClosed.rb +7 -0
  183. data/Views/Inventory/TicketOpen.rb +23 -0
  184. data/Views/Library/Person.rb +36 -0
  185. data/Views/Library/Tabs.rb +7 -0
  186. data/Views/Network/Block.rb +87 -0
  187. data/Views/Network/Netdevs.rb +21 -0
  188. data/Views/Network/Restriction.rb +37 -0
  189. data/Views/Network/Share.rb +167 -0
  190. data/Views/Network/Tables.rb +28 -0
  191. data/Views/Network/Tabs.rb +6 -0
  192. data/Views/Person/Admin.rb +99 -0
  193. data/Views/Person/Center.rb +48 -0
  194. data/Views/Person/Course.rb +72 -0
  195. data/Views/Person/Modify.rb +153 -0
  196. data/Views/Person/Tabs.rb +162 -0
  197. data/Views/Report/ComptaExecutive.rb +221 -0
  198. data/Views/Report/ComptaFlat.rb +79 -0
  199. data/Views/Report/ReportCourse.rb +47 -0
  200. data/Views/Report/Tabs.rb +8 -0
  201. data/Views/Report/Usage.rb +52 -0
  202. data/Views/Report/UsageCases.rb +59 -0
  203. data/Views/Self/Cash.rb +67 -0
  204. data/Views/Self/Chat.rb +55 -0
  205. data/Views/Self/Concours.rb +109 -0
  206. data/Views/Self/Email.rb +34 -0
  207. data/Views/Self/Internet.rb +255 -0
  208. data/Views/Self/Results.rb +17 -0
  209. data/Views/Self/Services.rb +85 -0
  210. data/Views/Self/Show.rb +47 -0
  211. data/Views/Self/Tabs.rb +5 -0
  212. data/Views/Special/DFileEdit.rb +13 -0
  213. data/Views/Special/PlugEdit.rb +56 -0
  214. data/Views/Special/Tabs.rb +6 -0
  215. data/Views/Special/Vnc.rb +39 -0
  216. data/Views/Task/Client.rb +21 -0
  217. data/Views/Task/Edit.rb +33 -0
  218. data/Views/Task/List.rb +55 -0
  219. data/Views/Task/Tabs.rb +9 -0
  220. data/Views/Task/Worker.rb +30 -0
  221. data/Views/Template/Activity.rb +33 -0
  222. data/Views/Template/CourseType.rb +63 -0
  223. data/Views/Template/ScheduleType.rb +29 -0
  224. data/Views/Template/Tabs.rb +5 -0
  225. data/Views/Welcome.rb +121 -0
  226. data/config.yaml.default +36 -0
  227. data/po/Gestion-ar.po +2356 -0
  228. data/po/Gestion-en.mo +0 -0
  229. data/po/Gestion-en.po +4363 -0
  230. data/po/Gestion-fr.mo +0 -0
  231. data/po/Gestion-fr.po +4345 -0
  232. data/po/traduction-ar.rtf +76 -0
  233. metadata +381 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: c703ebb9634b23eca593fe1bead1f71131c21e74
4
+ data.tar.gz: 0baed7d2aa22c8db5e57f79228817306b22ddeea
5
+ SHA512:
6
+ metadata.gz: 603c7563f4291c3875f64994ba97e05546820a8d479f4cfa0dc9ac52c5400932d3911b59f52df443ac2feb4e7339b1f0828bf4da4437568dd2a3002b7415c1c9
7
+ data.tar.gz: 7731a40cc07cb311da39e987a5092024205f191af4395c106d549df8011c338a0439ce1907128ee8985d13c98027926f62862afa3c506c9aaab2a1a81f671822
data/.gitignore ADDED
@@ -0,0 +1,48 @@
1
+ *\.tgz
2
+ *\.csv
3
+ *\.log
4
+ \.external.*
5
+
6
+ .DS_Store
7
+ .~lock*
8
+ .hg*
9
+ .settings*
10
+ .idea*
11
+
12
+ config.yaml
13
+
14
+ *data*/*
15
+ ldap*conf
16
+ Test/data/*
17
+ Test/data2/*
18
+ Test/Diplomas/*
19
+ Test/Exas/*
20
+ Test/Exams/*
21
+ Test/log
22
+ Test/run
23
+ Diplomas/*/*
24
+ Diplomas.Profeda*
25
+ Diplomas.Man
26
+ old/*
27
+ Exas/
28
+ Exams/
29
+ po/*mo
30
+ po/*pot
31
+ tmp/
32
+ po/*/*
33
+ Binaries/onetimers/data
34
+ Binaries/onetimers/Diplomas
35
+ Binaries/onetimers/Exas
36
+ Binaries/onetimers/config.yaml
37
+
38
+ Test/share_test
39
+ Doc/.backup
40
+ ac_work
41
+ Test/reports
42
+ Diplomas
43
+ Diplomas.src/*/*
44
+ .bundle
45
+ vendor
46
+
47
+ gestion.conf
48
+ Gestion.pkgrel
data/.project ADDED
@@ -0,0 +1,14 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <projectDescription>
3
+ <name>Gestion</name>
4
+ <comment></comment>
5
+ <projects>
6
+ <project>QooxView</project>
7
+ </projects>
8
+ <buildSpec>
9
+ </buildSpec>
10
+ <natures>
11
+ <nature>com.aptana.ruby.core.rubynature</nature>
12
+ <nature>com.aptana.projects.webnature</nature>
13
+ </natures>
14
+ </projectDescription>
@@ -0,0 +1,15 @@
1
+ #!/bin/bash
2
+
3
+ if [ ! "$1" ]; then
4
+ echo Syntax is: $0 username
5
+ exit 1
6
+ fi
7
+
8
+ USER=$1
9
+ ldapaddusertogroup $USER cyber_club
10
+
11
+ #if rsync -Paiv /home/$USER root@buzz.wifi:/home; then
12
+ # exit
13
+ #else
14
+ # exit 2
15
+ #fi
data/Binaries/backup ADDED
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ . $( dirname $0 )/lib_backup
3
+ cd $WDIR
4
+ DATE=$( date +%Y-%m-%d_%H.%M.%S )
5
+
6
+ DIRS="data config.yaml Exas Diplomas*"
7
+ tar --exclude LibreOffice -chzf $BACKUP_DIR/${1}backup_$DATE.tgz $DIRS
@@ -0,0 +1,8 @@
1
+ #!/bin/bash
2
+
3
+ if [ ! "$( pgrep -f 'ruby.*Gestion' )" ]; then
4
+ logger Not found Gestion - restarting
5
+ # /var/www/Gestion/Binaries/start_gestion
6
+ else
7
+ logger Gestion here
8
+ fi
@@ -0,0 +1,22 @@
1
+ /var/log/gestion/gestion.log {
2
+ daily
3
+ copytruncate
4
+ rotate 30
5
+ mail root@localhost
6
+ postrotate
7
+ /var/profeda/Gestion/Binaries/log_scan_errors
8
+ endscript
9
+ nocompress
10
+ }
11
+
12
+ /var/log/gestion/events.log {
13
+ daily
14
+ copytruncate
15
+ rotate 30
16
+ mail root@localhost
17
+ prerotate
18
+ cat /var/log/gestion/events.log | mail -s "Events from $( hostname )" root@localhost
19
+ endscript
20
+ nocompress
21
+ }
22
+
@@ -0,0 +1,34 @@
1
+ /var/log/gestion/gestion.log {
2
+ daily
3
+ copytruncate
4
+ rotate 30
5
+ mail root@localhost
6
+ #nomail
7
+ postrotate
8
+ /opt/gestion/Binaries/log_scan_errors
9
+ endscript
10
+ nocompress
11
+ }
12
+
13
+ /var/log/gestion/events.log {
14
+ daily
15
+ copytruncate
16
+ rotate 30
17
+ mail root@localhost
18
+ prerotate
19
+ /opt/gestion/Binaries/sort_events /var/log/gestion/events.log /tmp/gestion_events.log
20
+ SUBJ="Events from $( hostname )"
21
+ #if [ -x /usr/bin/mutt ]; then
22
+ # echo "Gestion log-file" | mutt -s "$SUBJ" -a /tmp/gestion_events.log -- root@localhost
23
+ #else
24
+ MAIL=/usr/bin/bsd-mailx
25
+ if [ ! -x $MAIL ]; then
26
+ MAIL=/usr/bin/mail
27
+ fi
28
+ cat /tmp/gestion_events.log | $MAIL -s "$SUBJ" root@localhost
29
+ #fi
30
+ rm /tmp/gestion_events.log
31
+ endscript
32
+ nocompress
33
+ }
34
+
@@ -0,0 +1,12 @@
1
+ [Unit]
2
+ Description=Gestion of cultural centers
3
+ Requires=network.target
4
+ After=network.target
5
+
6
+ [Service]
7
+ ExecStart=/usr/bin/sudo -i /opt/gestion/Gestion
8
+ ExecStop=/usr/bin/pkill -15 -f "ruby ./Gestion.rb"
9
+ ExecStop=/usr/bin/sleep 10
10
+
11
+ [Install]
12
+ WantedBy=multi-user.target
@@ -0,0 +1,183 @@
1
+ #!/usr/bin/env ruby
2
+ require 'bundler/setup'
3
+ require 'helper_classes'
4
+ require 'net/http'
5
+ require 'fileutils'
6
+
7
+ include HelperClasses
8
+ include HelperClasses::DPuts
9
+
10
+ @file_update = '/tmp/gestion.update'
11
+ @file_switch_versions = '/tmp/gestion.switch_versions'
12
+ @html_txt = []
13
+ @html_dir = '/srv/http/local'
14
+ @pacman_lock = '/var/lib/pacman/db.lck'
15
+ @html_file = "#{@html_dir}/update_progress.html"
16
+ DEBUG_LVL = 2
17
+
18
+ def reverse_update
19
+ return unless File.exists?(@file_update)
20
+ "#{Time.now.to_s }<br><textarea rows='20' cols='100'>" +
21
+ IO.read(@file_update).split("\n").reverse.join("\n") +
22
+ '</textarea>'
23
+ end
24
+
25
+ def main
26
+ begin
27
+ update_content = ''
28
+ if !File.exists? @file_switch_versions
29
+ if !File.exists? @file_update
30
+ update_html("Didn't find #{@file_update}", '0')
31
+ exit
32
+ end
33
+ file = IO.read(@file_update)
34
+ update_html('Stopping Gestion')
35
+ Platform.stop('gestion')
36
+ update_html("Updating using file #{file}")
37
+ update_html "Calling pacman to update #{file}"
38
+ update = Thread.new {
39
+ System.run_str '/usr/bin/killall -9 pacman'
40
+ puts @pacman_lock
41
+ File.exists?(@pacman_lock) and
42
+ FileUtils.rm(@pacman_lock)
43
+ puts System.run_str("/usr/bin/pacman --noconfirm --force -U #{file} > "+
44
+ @file_update)
45
+ }
46
+ while update.alive?
47
+ dputs(3) { 'Update is alive' }
48
+ update_html(reverse_update, true)
49
+ sleep 4
50
+ end
51
+ dputs(3) { 'Update should be done' }
52
+ update_content = reverse_update
53
+ FileUtils.rm @file_update
54
+ else
55
+ update_content = reverse_update
56
+ FileUtils.rm @file_switch_versions
57
+ while File.exists? @file_update
58
+ sleep 1
59
+ end
60
+ Platform.stop('gestion')
61
+ end
62
+ update_html update_content
63
+ update_html 'Starting Gestion'
64
+ Platform.reload
65
+ Platform.start('gestion')
66
+ i = 0
67
+ uri = URI('http://localhost:3302')
68
+ loop do
69
+ sleep 4
70
+ i += 1
71
+ begin
72
+ Net::HTTP.get(uri)
73
+ update_html("OK, we're good")
74
+ break
75
+ rescue Errno::ECONNREFUSED => e
76
+ update_html("Count: #{i} - gestion not yet up and running", true)
77
+ end
78
+ end
79
+ update_html('Hope the update went well -
80
+ <a href="http://admin.profeda.org" target="other">Login</a>',
81
+ refresh: '86400',
82
+ script: "setTimeout(function(){
83
+ window.open('http://admin.profeda.org', '_blank');
84
+ }, 5000 );")
85
+ rescue StandardError => e
86
+ update_html("Error: #{e.to_s} - #{e.inspect}")
87
+ update_html("Error: #{caller.inspect}")
88
+ end
89
+ System.run_str "cat #{@html_file} | mail -s 'update gestion on $(hostname)' root@localhost"
90
+ end
91
+
92
+ def update_html(msg, noadd = false, refresh: '5', script: '')
93
+ return unless Dir.exists? @html_dir
94
+ p msg unless noadd
95
+ @html_txt.push msg
96
+ IO.write("#{@html_file}.tmp", "
97
+ <html>
98
+ <head>
99
+ <META http-equiv='refresh' content='#{refresh}'>
100
+ <meta http-equiv='Content-Type' content='text/html; charset=utf-8'/>
101
+ <title>Update of Gestion</title>
102
+ <style>
103
+ body {
104
+ background-color: #607860;
105
+ }
106
+
107
+ .center {
108
+ text-align: center;
109
+ }
110
+
111
+ .right {
112
+ text-align: right;
113
+ }
114
+
115
+ .main {
116
+ margin-left: auto;
117
+ margin-right: auto;
118
+ padding: 10px;
119
+ width: 70%;
120
+ background-color: #b0deb0;
121
+ }
122
+
123
+ textarea {
124
+ background-color: #d0ded0;
125
+ }
126
+
127
+ a:link {
128
+ text-decoration: underline;
129
+ color: #6666AA;
130
+ }
131
+
132
+ a:visited {
133
+ text-decoration: underline;
134
+ color: #6666AA;
135
+ }
136
+
137
+ a:hover {
138
+ text-decoration: underline;
139
+ color: #66AA66;
140
+ }
141
+
142
+ a:active {
143
+ text-decoration: underline;
144
+ }
145
+
146
+ .big {
147
+ font-size: 30px;
148
+ }
149
+
150
+ .medium {
151
+ font-size: 20px;
152
+ }
153
+
154
+ .small {
155
+ font-size: 10px;
156
+ }
157
+ </style>
158
+ </head>
159
+ <body>
160
+ <div class='main'>
161
+ <div class='center'>
162
+ <h1>Updating Gestion - please be patient</h1>
163
+ </div>
164
+ <ul>
165
+ #{@html_txt.collect { |t| "<li>#{t}</li>" }.join("\n")}
166
+ </ul>
167
+ </div>
168
+ <script type='text/javascript'>
169
+ #{script}
170
+ </script>
171
+ </body>
172
+ </html>
173
+ ")
174
+ FileUtils.mv "#{@html_file}.tmp", @html_file
175
+ noadd and @html_txt.pop
176
+ end
177
+
178
+ if ARGV.length > 0
179
+ IO.write(@file_update, ARGV.first)
180
+ update_html('Waiting to begin update')
181
+ else
182
+ main
183
+ end
@@ -0,0 +1,10 @@
1
+ [Unit]
2
+ Description=Updating gestion
3
+ Requires=network.target
4
+ After=network.target
5
+
6
+ [Service]
7
+ ExecStart=/usr/bin/sudo -i /opt/gestion/Gestion update
8
+
9
+ [Install]
10
+ WantedBy=multi-user.target
@@ -0,0 +1,11 @@
1
+ #!/bin/bash
2
+
3
+ COMPTA_DB=/Users/foo/.camping.db
4
+
5
+ sqlite3 sql.db 'DROP TABLE "stsql_accounts";'
6
+ sqlite3 $COMPTA_DB ".dump compta_accounts" | sed -e 's/"compta_accounts"/"stsql_accounts"/' |
7
+ sed -e 's/^\(CREATE TABLE.*\)"id"\(.*\)"account_id"/\1"account_id"\2"parent_id"/' | sqlite3 sql.db
8
+
9
+ sqlite3 sql.db 'DROP TABLE "stsql_movements";'
10
+ sqlite3 $COMPTA_DB ".dump compta_movements" | sed -e 's/"compta_movements"/"stsql_movements"/' |
11
+ sed -e 's/^\(CREATE TABLE.*\)"id"/\1"movement_id"/' | sqlite3 sql.db
@@ -0,0 +1,16 @@
1
+ #!/bin/bash
2
+ STOP=/tmp/stop_gestion
3
+
4
+ logger -s "Stopping Gestion"
5
+ touch $STOP
6
+ cd $( dirname $0 )/..
7
+ logger -s "Killing old Gestion"
8
+ pkill -f ruby.*Gestion
9
+ pkill -f tee.*gestion
10
+ logger -s "Waiting for 10 seconds"
11
+ sleep 10
12
+ logger -s "Killing old Gestion with -9"
13
+ pkill -9 -f loop_gestion
14
+ pkill -9 -f ruby.*Gestion
15
+ pkill -9 -f tee.*gestion
16
+ screen -wipe
@@ -0,0 +1,51 @@
1
+ #!/bin/bash
2
+
3
+ cat > index.ldif <<EOF
4
+ dn: olcDatabase={1}hdb,cn=config
5
+ changetype: modify
6
+ add: olcDbIndex
7
+ olcDbIndex: cn pres,sub,eq
8
+ -
9
+ add: olcDbIndex
10
+ olcDbIndex: sn pres,sub,eq
11
+ -
12
+ add: olcDbIndex
13
+ olcDbIndex: uid pres,sub,eq
14
+ -
15
+ add: olcDbIndex
16
+ olcDbIndex: displayName pres,sub,eq
17
+ -
18
+ add: olcDbIndex
19
+ olcDbIndex: default sub
20
+ -
21
+ add: olcDbIndex
22
+ olcDbIndex: uidNumber eq
23
+ -
24
+ add: olcDbIndex
25
+ olcDbIndex: gidNumber eq
26
+ -
27
+ add: olcDbIndex
28
+ olcDbIndex: mail,givenName eq,subinitial
29
+ -
30
+ add: olcDbIndex
31
+ olcDbIndex: dc eq
32
+ -
33
+ add: olcDbIndex
34
+ olcDbIndex: uniqueMember eq
35
+ -
36
+ EOF
37
+ cat > index.ldif <<EOF
38
+ dn: olcDatabase={1}hdb,cn=config
39
+ changetype: modify
40
+ add: olcDbIndex
41
+ olcDbIndex: memberUid eq
42
+ EOF
43
+
44
+ sudo ldapadd -Y EXTERNAL -H ldapi:/// -f index.ldif
45
+ rm index.ldif
46
+ /etc/init.d/slapd stop
47
+ slapindex
48
+ chown -R openldap:openldap /var/lib/ldap
49
+ /etc/init.d/slapd start
50
+
51
+
@@ -0,0 +1,2 @@
1
+ #!/bin/bash
2
+ slapcat > ldap.backup
@@ -0,0 +1,92 @@
1
+ #!/bin/bash
2
+ #aptitude install slapd ldap-utils pwgen samba-doc
3
+
4
+ if [ "$1" ]; then
5
+ HOST=$1
6
+ else
7
+ read -p "Name of host [profeda]: " HOST
8
+ HOST=${HOST:-profeda}
9
+ fi
10
+ if [ "$2" ]; then
11
+ PASSWD=$2
12
+ else
13
+ pass=$( pwgen -1 )
14
+ read -p "Password [$pass]: " PASSWD
15
+ PASSWD=${PASSWD:-$pass}
16
+ fi
17
+
18
+ TLD=wifi
19
+
20
+ echo
21
+ echo "Creating the ldap for host $HOST.$TLD with password '$PASSWD'"
22
+ echo "Press <ENTER> to confirm"
23
+ read
24
+
25
+ echo Preparing samba.ldif
26
+ zcat /usr/share/doc/samba-doc/examples/LDAP/samba.schema.gz > /etc/ldap/schema/samba.schema
27
+ cat > /tmp/samba.conf <<EOF
28
+ include /etc/ldap/schema/core.schema
29
+ include /etc/ldap/schema/cosine.schema
30
+ include /etc/ldap/schema/nis.schema
31
+ include /etc/ldap/schema/inetorgperson.schema
32
+ include /etc/ldap/schema/samba.schema
33
+ EOF
34
+ mkdir -p /tmp/slapd.d
35
+ slaptest -f /tmp/samba.conf -F /tmp/slapd.d/
36
+ cp /tmp/slapd.d/cn=config/cn=schema/cn=\{4\}samba.ldif /etc/ldap/schema/samba.ldif
37
+ rm -rf /tmp/samba.conf /tmp/slapd.d
38
+
39
+ for a in cosine nis inetorgperson samba; do
40
+ if ls /etc/ldap/slapd.d/cn\=config/cn\=schema/*$a.ldif > /dev/null 2>&1; then
41
+ echo $a does already exist
42
+ else
43
+ echo Installing schema $a
44
+ sudo ldapadd -Y EXTERNAL -H ldapi:/// -f /etc/ldap/schema/$a.ldif
45
+ fi
46
+ done
47
+
48
+ exit
49
+ echo Adding rights for admin $HOST $TLD
50
+ cat > backend.ldif <<EOF
51
+ dn: olcDatabase={2}hdb,cn=config
52
+ objectClass: olcDatabaseConfig
53
+ objectClass: olcHdbConfig
54
+ olcDatabase: {2}hdb
55
+ olcSuffix: dc=$HOST,dc=$TLD
56
+ olcDbDirectory: /var/lib/ldap
57
+ olcRootDN: cn=admin,dc=$HOST,dc=$TLD
58
+ olcRootPW: $PASSWD
59
+ olcDbIndex: cn,sn,uid pres,eq,approx,sub
60
+ olcDbIndex: objectClass eq
61
+ olcAccess: to attrs=userPassword
62
+ by self write
63
+ by anonymous auth
64
+ by dn.base="cn=admin,dc=$HOST,dc=$TLD" write
65
+ by * none
66
+ olcAccess: to *
67
+ by self write
68
+ by dn.base="cn=admin,dc=$HOST,dc=$TLD" write
69
+ by * read
70
+ EOF
71
+
72
+ #sudo ldapadd -Y EXTERNAL -H ldapi:/// -f backend.ldif
73
+ rm backend.ldif
74
+
75
+ echo And populating database
76
+
77
+ cat > init.ldif <<EOF
78
+ dn: ou=Users,dc=$HOST,dc=$TLD
79
+ objectClass: organizationalUnit
80
+ ou: Users
81
+
82
+ dn: ou=Groups,dc=$HOST,dc=$TLD
83
+ objectClass: organizationalUnit
84
+ ou: Groups
85
+ EOF
86
+
87
+ sudo ldapadd -x -D cn=admin,dc=$HOST,dc=$TLD -w $PASSWD -f init.ldif
88
+ rm init.ldif
89
+
90
+ echo Finally making the indexes a bit faster
91
+
92
+ add_indexes
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+
3
+ /etc/init.d/slapd stop
4
+ rm /var/lib/ldap/*
5
+ egrep -v "(samba|displayName|MaN|structuralObjectClass|^ )" ldap.backup | slapadd -c
6
+ chown -R openldap.openldap /var/lib/ldap
7
+ /etc/init.d/slapd start
@@ -0,0 +1,5 @@
1
+ #!/bin/bash
2
+
3
+ WDIR=$( dirname ${BASH_SOURCE[0]} )/..
4
+ BACKUP_DIR=$WDIR/Backups
5
+ test -d $BACKUP_DIR || mkdir -p $BACKUP_DIR
@@ -0,0 +1,8 @@
1
+ #!/bin/bash
2
+
3
+ LOG=/var/log/gestion/gestion.log.1
4
+
5
+ if grep -q "^:0:" $LOG; then
6
+ grep "^:0:" -A 20 -B 20 $LOG | mail -s "$( hostname ): Error-logs for $( date )" root@localhost
7
+ fi
8
+
@@ -0,0 +1,64 @@
1
+ #!/bin/bash
2
+ LOGR=""
3
+
4
+ cd $( dirname $0 )/..
5
+
6
+ log(){
7
+ echo $( date ) $@ >> $LOG
8
+ }
9
+
10
+ biglog(){
11
+ echo "
12
+
13
+ **** **** **** ****
14
+ $( date )
15
+ **** **** **** ****
16
+
17
+ " >> $LOG
18
+ }
19
+
20
+ mkdir -p /var/log/gestion
21
+ LOG=/var/log/gestion/gestion.log
22
+ if ! touch $LOG; then
23
+ LOG=gestion.log
24
+ fi
25
+ if [ "$LOGR" ]; then
26
+ if [ -f $LOG ]; then
27
+ mv $LOG $LOG.1
28
+ gzip -f $LOG.1
29
+ fi
30
+ fi
31
+
32
+ #log "$( set )"
33
+ #set
34
+ #while sleep 1; do date; done
35
+ #exit
36
+
37
+ STOP=/tmp/stop_gestion
38
+ rm $STOP
39
+ touch $LOG
40
+ pkill -9 -f "tail -f $LOG"
41
+ tail -f $LOG &
42
+ while [ ! -f $STOP ]; do
43
+ now=$( date +%s )
44
+ if which unbuffer > /dev/null; then
45
+ PRE="unbuffer"
46
+ elif which stdbuf > /dev/null; then
47
+ PRE="stdbuf -oL -eL"
48
+ else
49
+ PRE=""
50
+ fi
51
+ #$PRE ./Gestion 2>&1 >> $LOG
52
+ #./Gestion
53
+ ./Gestion 2>&1 >> $LOG
54
+ #./Gestion 2>&1
55
+ biglog Oups - quit Gestion after $(( quit - now )) seconds
56
+ quit=$( date +%s )
57
+ if [ $(( quit - now )) -lt 60 ]; then
58
+ log This seems to be quite bad... not restarting >> $LOG
59
+ #tail -n 30 $LOG | mail -s "Gestion crashed on short notice" root@localhost
60
+ exit
61
+ fi
62
+ done
63
+ pkill -9 -f "tail -f $LOG"
64
+ biglog Stopped because of $STOP >> $LOG