浏览代码

Remove rocketchat and meteor

Meteor is genuinely hard to install and I don't regard curl | bash as an adequate or safe install method
Bob Mottram 7 年前
父节点
当前提交
89be347596
共有 3 个文件被更改,包括 0 次插入687 次删除
  1. 0
    469
      src/freedombone-app-rocketchat
  2. 0
    2
      src/freedombone-image-customise
  3. 0
    216
      src/freedombone-utils-meteor

+ 0
- 469
src/freedombone-app-rocketchat 查看文件

@@ -1,469 +0,0 @@
1
-#!/bin/bash
2
-#
3
-#  _____               _           _
4
-# |   __|___ ___ ___ _| |___ _____| |_ ___ ___ ___
5
-# |   __|  _| -_| -_| . | . |     | . | . |   | -_|
6
-# |__|  |_| |___|___|___|___|_|_|_|___|___|_|_|___|
7
-#
8
-#                              Freedom in the Cloud
9
-#
10
-# License
11
-# =======
12
-#
13
-# Copyright (C) 2018 Bob Mottram <bob@freedombone.net>
14
-#
15
-# This program is free software: you can redistribute it and/or modify
16
-# it under the terms of the GNU Affero General Public License as published by
17
-# the Free Software Foundation, either version 3 of the License, or
18
-# (at your option) any later version.
19
-#
20
-# This program is distributed in the hope that it will be useful,
21
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
22
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
23
-# GNU Affero General Public License for more details.
24
-#
25
-# You should have received a copy of the GNU Affero General Public License
26
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
27
-
28
-VARIANTS='full full-vim'
29
-
30
-IN_DEFAULT_INSTALL=0
31
-SHOW_ON_ABOUT=1
32
-NOT_ON_ARM=1
33
-
34
-ROCKETCHAT_DOMAIN_NAME=
35
-ROCKETCHAT_CODE=
36
-ROCKETCHAT_ONION_PORT=9018
37
-ROCKETCHAT_REPO="https://github.com/RocketChat/Rocket.Chat"
38
-ROCKETCHAT_COMMIT='08149ebebbe265bce8f06289ad9a2f6bb4b1464b'
39
-ROCKETCHAT_PORT_INTERNAL=3004
40
-
41
-rocketchat_variables=(ONION_ONLY
42
-                      ROCKETCHAT_DOMAIN_NAME
43
-                      ROCKETCHAT_CODE
44
-                      DDNS_PROVIDER
45
-                      MY_USERNAME)
46
-
47
-function logging_on_rocketchat {
48
-    echo -n ''
49
-}
50
-
51
-function logging_off_rocketchat {
52
-    echo -n ''
53
-}
54
-
55
-function remove_user_rocketchat {
56
-    remove_username="$1"
57
-
58
-    "${PROJECT_NAME}-pass" -u "$remove_username" --rmapp rocketchat
59
-}
60
-
61
-function add_user_rocketchat {
62
-    new_username="$1"
63
-    new_user_password="$2"
64
-
65
-    "${PROJECT_NAME}-pass" -u "$new_username" -a rocketchat -p "$new_user_password"
66
-    echo '0'
67
-}
68
-
69
-function install_interactive_rocketchat {
70
-    if [ ! "$ONION_ONLY" ]; then
71
-        ONION_ONLY='no'
72
-    fi
73
-
74
-    if [[ "$ONION_ONLY" != "no" ]]; then
75
-        ROCKETCHAT_DOMAIN_NAME='rocketchat.local'
76
-        write_config_param "ROCKETCHAT_DOMAIN_NAME" "$ROCKETCHAT_DOMAIN_NAME"
77
-    else
78
-        interactive_site_details "rocketchat" "ROCKETCHAT_DOMAIN_NAME" "ROCKETCHAT_CODE"
79
-    fi
80
-    APP_INSTALLED=1
81
-}
82
-
83
-function change_password_rocketchat {
84
-    curr_username="$1"
85
-    new_user_password="$2"
86
-
87
-    read_config_param 'ROCKETCHAT_DOMAIN_NAME'
88
-
89
-    "${PROJECT_NAME}-pass" -u "$curr_username" -a rocketchat -p "$new_user_password"
90
-}
91
-
92
-function rocketchat_create_database {
93
-    if [ -f $IMAGE_PASSWORD_FILE ]; then
94
-        ROCKETCHAT_ADMIN_PASSWORD="$(printf "%d" "$(cat "")")"
95
-    else
96
-        if [ ! $ROCKETCHAT_ADMIN_PASSWORD ]; then
97
-            ROCKETCHAT_ADMIN_PASSWORD="$(create_password ${MINIMUM_PASSWORD_LENGTH})"
98
-        fi
99
-    fi
100
-    if [ ! $ROCKETCHAT_ADMIN_PASSWORD ]; then
101
-        return
102
-    fi
103
-
104
-    create_database_mongodb rocketchat "$ROCKETCHAT_ADMIN_PASSWORD" $MY_USERNAME
105
-}
106
-
107
-function reconfigure_rocketchat {
108
-    # This is used if you need to switch identity. Dump old keys and generate new ones
109
-    echo -n ''
110
-}
111
-
112
-function configure_interactive_rocketchat {
113
-    W=(1 $"Option 1"
114
-       2 $"Option 2")
115
-
116
-    while true
117
-    do
118
-        # shellcheck disable=SC2068
119
-        selection=$(dialog --backtitle $"Freedombone Administrator Control Panel" --title $"rocketchat" --menu $"Choose an operation, or ESC for main menu:" 14 70 3 "${W[@]}" 3>&2 2>&1 1>&3)
120
-
121
-        if [ ! "$selection" ]; then
122
-            break
123
-        fi
124
-        case $selection in
125
-            1) # call some function for option 1
126
-            ;;
127
-            2) # call some function for option 2
128
-            ;;
129
-        esac
130
-    done
131
-}
132
-
133
-function upgrade_rocketchat {
134
-    CURR_ROCKETCHAT_COMMIT=$(get_completion_param "rocketchat commit")
135
-    if [[ "$CURR_ROCKETCHAT_COMMIT" == "$ROCKETCHAT_COMMIT" ]]; then
136
-        return
137
-    fi
138
-
139
-    if grep -q "rocketchat domain" "$COMPLETION_FILE"; then
140
-        ROCKETCHAT_DOMAIN_NAME=$(get_completion_param "rocketchat domain")
141
-    fi
142
-
143
-    # update to the next commit
144
-    set_repo_commit "/etc/rocketchat" "rocketchat commit" "$ROCKETCHAT_COMMIT" "$ROCKETCHAT_REPO"
145
-    chown -R rocketchat:rocketchat "/etc/rocketchat"
146
-
147
-    systemctl restart rocketchat
148
-}
149
-
150
-function backup_local_rocketchat {
151
-    ROCKETCHAT_DOMAIN_NAME='rocketchat'
152
-    if grep -q "rocketchat domain" "$COMPLETION_FILE"; then
153
-        ROCKETCHAT_DOMAIN_NAME=$(get_completion_param "rocketchat domain")
154
-    fi
155
-
156
-    source_directory=/etc/rocketchat
157
-
158
-    suspend_site "${ROCKETCHAT_DOMAIN_NAME}"
159
-
160
-    systemctl stop rocketchat
161
-
162
-    dest_directory=rocketchat
163
-    backup_directory_to_usb "$source_directory" $dest_directory
164
-
165
-    USE_MONGODB=1
166
-    backup_database_to_usb rocketchat
167
-
168
-    restart_site
169
-    systemctl start rocketchat
170
-}
171
-
172
-function restore_local_rocketchat {
173
-    if ! grep -q "rocketchat domain" "$COMPLETION_FILE"; then
174
-        return
175
-    fi
176
-    ROCKETCHAT_DOMAIN_NAME=$(get_completion_param "rocketchat domain")
177
-    if [ ! "$ROCKETCHAT_DOMAIN_NAME" ]; then
178
-        return
179
-    fi
180
-    suspend_site "${ROCKETCHAT_DOMAIN_NAME}"
181
-    systemctl stop rocketchat
182
-
183
-    temp_restore_dir=/root/temprocketchat
184
-    rocketchat_dir=/etc/rocketchat
185
-
186
-    rocketchat_create_database
187
-
188
-    USE_MONGODB=1
189
-    restore_database rocketchat
190
-    if [ -d $temp_restore_dir ]; then
191
-        rm -rf $temp_restore_dir
192
-    fi
193
-
194
-    restore_directory_from_usb $temp_restore_dir rocketchat
195
-    if [ -d $temp_restore_dir ]; then
196
-        if [ -d "$temp_restore_dir$rocketchat_dir" ]; then
197
-            cp -rp "$temp_restore_dir$rocketchat_dir"/* "$rocketchat_dir"/
198
-        else
199
-            if [ ! -d "$rocketchat_dir" ]; then
200
-                mkdir "$rocketchat_dir"
201
-            fi
202
-            cp -rp "$temp_restore_dir"/* "$rocketchat_dir"/
203
-        fi
204
-        chown -R rocketchat:rocketchat "$rocketchat_dir"
205
-        rm -rf $temp_restore_dir
206
-    fi
207
-    systemctl start rocketchat
208
-
209
-    restart_site
210
-}
211
-
212
-function backup_remote_rocketchat {
213
-    ROCKETCHAT_DOMAIN_NAME='rocketchat'
214
-    if grep -q "rocketchat domain" "$COMPLETION_FILE"; then
215
-        ROCKETCHAT_DOMAIN_NAME=$(get_completion_param "rocketchat domain")
216
-    fi
217
-
218
-    source_directory=/etc/rocketchat
219
-
220
-    suspend_site "${ROCKETCHAT_DOMAIN_NAME}"
221
-    systemctl stop rocketchat
222
-
223
-    dest_directory=rocketchat
224
-    backup_directory_to_friend "$source_directory" $dest_directory
225
-    USE_MONGODB=1
226
-    backup_database_to_friend rocketchat
227
-
228
-
229
-    systemctl start rocketchat
230
-
231
-    restart_site
232
-}
233
-
234
-function restore_remote_rocketchat {
235
-    if ! grep -q "rocketchat domain" "$COMPLETION_FILE"; then
236
-        return
237
-    fi
238
-    ROCKETCHAT_DOMAIN_NAME=$(get_completion_param "rocketchat domain")
239
-    if [ ! "$ROCKETCHAT_DOMAIN_NAME" ]; then
240
-        return
241
-    fi
242
-    suspend_site "${ROCKETCHAT_DOMAIN_NAME}"
243
-    systemctl stop rocketchat
244
-
245
-    temp_restore_dir=/root/temprocketchat
246
-    rocketchat_dir=/etc/rocketchat
247
-
248
-    rocketchat_create_database
249
-
250
-    USE_MONGODB=1
251
-    restore_database_from_friend rocketchat
252
-    if [ -d "$temp_restore_dir" ]; then
253
-        rm -rf $temp_restore_dir
254
-    fi
255
-
256
-    restore_directory_from_friend $temp_restore_dir rocketchat
257
-    if [ -d $temp_restore_dir ]; then
258
-        if [ -d "$temp_restore_dir$rocketchat_dir" ]; then
259
-            cp -rp "$temp_restore_dir$rocketchat_dir"/* "$rocketchat_dir"/
260
-        else
261
-            if [ ! -d "$rocketchat_dir" ]; then
262
-                mkdir "$rocketchat_dir"
263
-            fi
264
-            cp -rp $temp_restore_dir/* "$rocketchat_dir"/
265
-        fi
266
-        chown -R rocketchat:rocketchat "$rocketchat_dir"
267
-        rm -rf $temp_restore_dir
268
-    fi
269
-    systemctl start rocketchat
270
-
271
-    restart_site
272
-}
273
-
274
-function remove_rocketchat {
275
-    nginx_dissite "$ROCKETCHAT_DOMAIN_NAME"
276
-    remove_certs "$ROCKETCHAT_DOMAIN_NAME"
277
-
278
-    if [ -f /etc/systemd/system/rocketchat.service ]; then
279
-        systemctl stop rocketchat
280
-        systemctl disable rocketchat
281
-        rm /etc/systemd/system/rocketchat.service
282
-    fi
283
-    userdel -r rocketchat
284
-    remove_nodejs rocketchat
285
-
286
-
287
-    if [ -d "/var/www/$ROCKETCHAT_DOMAIN_NAME" ]; then
288
-        rm -rf "/var/www/$ROCKETCHAT_DOMAIN_NAME"
289
-    fi
290
-    if [ -f "/etc/nginx/sites-available/$ROCKETCHAT_DOMAIN_NAME" ]; then
291
-        rm "/etc/nginx/sites-available/$ROCKETCHAT_DOMAIN_NAME"
292
-    fi
293
-    drop_database_mongodb rocketchat
294
-    remove_onion_service rocketchat "${ROCKETCHAT_ONION_PORT}"
295
-    if grep -q "rocketchat" /etc/crontab; then
296
-        sed -i "/rocketchat/d" /etc/crontab
297
-    fi
298
-    remove_app rocketchat
299
-    remove_completion_param install_rocketchat
300
-    sed -i '/rocketchat/d' "$COMPLETION_FILE"
301
-
302
-    remove_ddns_domain "$ROCKETCHAT_DOMAIN_NAME"
303
-}
304
-
305
-function install_rocketchat {
306
-    apt-get install -yq curl graphicsmagick
307
-
308
-    install_mongodb
309
-
310
-    install_nodejs rocketchat
311
-    if [ ! "$ROCKETCHAT_DOMAIN_NAME" ]; then
312
-        echo $'No domain name was given'
313
-        exit 3568356
314
-    fi
315
-
316
-    if [ -d "/var/www/$ROCKETCHAT_DOMAIN_NAME/htdocs" ]; then
317
-        rm -rf "/var/www/$ROCKETCHAT_DOMAIN_NAME/htdocs"
318
-    fi
319
-    if [ -d /repos/rocketchat ]; then
320
-        mkdir "/var/www/$ROCKETCHAT_DOMAIN_NAME/htdocs"
321
-        cp -r -p /repos/rocketchat/. "/etc/rocketchat"
322
-        cd "/etc/rocketchat" || exit 36487365
323
-        git pull
324
-    else
325
-        git_clone "$ROCKETCHAT_REPO" "/etc/rocketchat"
326
-    fi
327
-
328
-    if [ ! -d "/etc/rocketchat" ]; then
329
-        echo $'Unable to clone rocketchat repo'
330
-        exit 87525
331
-    fi
332
-
333
-    cd "/etc/rocketchat" || exit 3463754637
334
-    git checkout "$ROCKETCHAT_COMMIT" -b "$ROCKETCHAT_COMMIT"
335
-    set_completion_param "rocketchat commit" "$ROCKETCHAT_COMMIT"
336
-
337
-    chmod g+w "/var/www/$ROCKETCHAT_DOMAIN_NAME/htdocs"
338
-    chown -R www-data:www-data "/var/www/$ROCKETCHAT_DOMAIN_NAME/htdocs"
339
-
340
-    rocketchat_create_database
341
-
342
-    cd "/etc/rocketchat" || exit 46327437
343
-    if ! npm install; then
344
-        exit 36483563
345
-    fi
346
-
347
-    add_ddns_domain "$ROCKETCHAT_DOMAIN_NAME"
348
-
349
-    ROCKETCHAT_ONION_HOSTNAME=$(add_onion_service rocketchat 80 "${ROCKETCHAT_ONION_PORT}")
350
-
351
-    rocketchat_nginx_site=/etc/nginx/sites-available/$ROCKETCHAT_DOMAIN_NAME
352
-    if [[ "$ONION_ONLY" == "no" ]]; then
353
-        nginx_http_redirect "$ROCKETCHAT_DOMAIN_NAME" "index index.html"
354
-        { echo 'server {';
355
-          echo '  listen 443 ssl;';
356
-          echo '  #listen [::]:443 ssl;';
357
-          echo "  server_name $ROCKETCHAT_DOMAIN_NAME;";
358
-          echo ''; } >> "$rocketchat_nginx_site"
359
-        nginx_compress "$ROCKETCHAT_DOMAIN_NAME"
360
-        echo '' >> "$rocketchat_nginx_site"
361
-        echo '  # Security' >> "$rocketchat_nginx_site"
362
-        nginx_ssl "$ROCKETCHAT_DOMAIN_NAME"
363
-
364
-        nginx_security_options "$ROCKETCHAT_DOMAIN_NAME"
365
-
366
-        { echo '  add_header Strict-Transport-Security max-age=15768000;';
367
-          echo '';
368
-          echo '  # Logs';
369
-          echo '  access_log /dev/null;';
370
-          echo '  error_log /dev/null;';
371
-          echo '';
372
-          echo '  # Root';
373
-          echo "  root /var/www/$ROCKETCHAT_DOMAIN_NAME/htdocs;";
374
-          echo '';
375
-          echo '  index index.html;';
376
-          echo '  # Location';
377
-          echo '  location / {'; } >> "$rocketchat_nginx_site"
378
-        nginx_limits "$ROCKETCHAT_DOMAIN_NAME" '15m'
379
-        { echo "    proxy_pass http://localhost:$ROCKETCHAT_PORT_INTERNAL;";
380
-          echo '    proxy_http_version 1.1;';
381
-          echo "    proxy_set_header Upgrade \$http_upgrade;";
382
-          echo "    proxy_set_header Connection \"upgrade\";";
383
-          echo "    proxy_set_header Host \$http_host;";
384
-          echo '';
385
-          echo "    proxy_set_header X-Real-IP \$remote_addr;";
386
-          echo "    proxy_set_header X-Forward-For \$proxy_add_x_forwarded_for;";
387
-          echo '    proxy_set_header X-Forward-Proto http;';
388
-          echo '    proxy_set_header X-Nginx-Proxy true;';
389
-          echo '';
390
-          echo '    proxy_redirect off;';
391
-          echo '  }';
392
-          echo '}'; } >> "$rocketchat_nginx_site"
393
-    else
394
-        echo -n '' > "$rocketchat_nginx_site"
395
-    fi
396
-    { echo 'server {';
397
-      echo "    listen 127.0.0.1:$ROCKETCHAT_ONION_PORT default_server;";
398
-      echo "    server_name $ROCKETCHAT_ONION_HOSTNAME;";
399
-      echo ''; } >> "$rocketchat_nginx_site"
400
-    nginx_compress "$ROCKETCHAT_DOMAIN_NAME"
401
-    echo '' >> "$rocketchat_nginx_site"
402
-    nginx_security_options "$ROCKETCHAT_DOMAIN_NAME"
403
-    { echo '';
404
-      echo '  # Logs';
405
-      echo '  access_log /dev/null;';
406
-      echo '  error_log /dev/null;';
407
-      echo '';
408
-      echo '  # Root';
409
-      echo "  root /var/www/$ROCKETCHAT_DOMAIN_NAME/htdocs;";
410
-      echo '';
411
-      echo '  index index.html;';
412
-      echo '  # Location';
413
-      echo '  location / {'; } >> "$rocketchat_nginx_site"
414
-    nginx_limits "$ROCKETCHAT_DOMAIN_NAME" '15m'
415
-    { echo "    proxy_pass http://localhost:$ROCKETCHAT_PORT_INTERNAL;";
416
-      echo '    proxy_http_version 1.1;';
417
-      echo "    proxy_set_header Upgrade \$http_upgrade;";
418
-      echo "    proxy_set_header Connection \"upgrade\";";
419
-      echo "    proxy_set_header Host \$http_host;";
420
-      echo '';
421
-      echo "    proxy_set_header X-Real-IP \$remote_addr;";
422
-      echo "    proxy_set_header X-Forward-For \$proxy_add_x_forwarded_for;";
423
-      echo '    proxy_set_header X-Forward-Proto http;';
424
-      echo '    proxy_set_header X-Nginx-Proxy true;';
425
-      echo '';
426
-      echo '    proxy_redirect off;';
427
-      echo '  }';
428
-      echo '}'; } >> "$rocketchat_nginx_site"
429
-
430
-    adduser --system --home="/etc/rocketchat" --group rocketchat
431
-
432
-    { echo '[Unit]';
433
-      echo 'Description=rocketchat';
434
-      echo 'After=syslog.target';
435
-      echo 'After=network.target';
436
-      echo '';
437
-      echo '[Service]';
438
-      echo 'Type=simple';
439
-      echo 'User=rocketchat';
440
-      echo 'Group=rocketchat';
441
-      echo 'WorkingDirectory=/etc/rocketchat';
442
-      echo 'ExecStart=/usr/local/bin/node main.js';
443
-      echo 'Environment=USER=rocketchat';
444
-      echo 'Restart=always';
445
-      echo 'StandardError=syslog';
446
-      echo 'Environment=NODE_ENV=production';
447
-      echo "Environment=PORT=${ROCKETCHAT_PORT_INTERNAL}";
448
-      echo "Environment=ROOT_URL=http://localhost:${ROCKETCHAT_PORT_INTERNAL}";
449
-      echo "Environment=MONGO_URL=mongodb://mongo:${MONGODB_PORT}/rocketchat";
450
-      echo '';
451
-      echo '[Install]';
452
-      echo 'WantedBy=multi-user.target'; } >> "/etc/systemd/system/rocketchat.service"
453
-    systemctl enable rocketchat
454
-    chown -R rocketchat:rocketchat "/etc/rocketchat"
455
-    systemctl start rocketchat
456
-
457
-    create_site_certificate "$ROCKETCHAT_DOMAIN_NAME" 'yes'
458
-
459
-    nginx_ensite "$ROCKETCHAT_DOMAIN_NAME"
460
-
461
-    systemctl restart nginx
462
-
463
-    "${PROJECT_NAME}-pass" -u "$MY_USERNAME" -a rocketchat -p "$ROCKETCHAT_ADMIN_PASSWORD"
464
-    set_completion_param "rocketchat domain" "$ROCKETCHAT_DOMAIN_NAME"
465
-
466
-    APP_INSTALLED=1
467
-}
468
-
469
-# NOTE: deliberately there is no "exit 0"

+ 0
- 2
src/freedombone-image-customise 查看文件

@@ -1986,8 +1986,6 @@ image_preinstall_repos() {
1986 1986
     git clone "$BDSMAIL_REPO" "$rootdir/repos/bdsmail"
1987 1987
     #git clone "$WEKAN_REPO" "$rootdir/repos/wekan"
1988 1988
     #git clone "$FLOW_ROUTER_REPO" "$rootdir/repos/flowrouter"
1989
-    #git clone "$METEOR_USERACCOUNTS_REPO" "$rootdir/repos/meteoruseraccounts"
1990
-    #git clone "$METEOR_REPO" "$rootdir/repos/meteor"
1991 1989
     #git clone "$ZERONET_REPO" "$rootdir/repos/zeronet"
1992 1990
     #git clone "$QTOX_REPO" "$rootdir/repos/qtox"
1993 1991
 }

+ 0
- 216
src/freedombone-utils-meteor 查看文件

@@ -1,216 +0,0 @@
1
-#!/bin/bash
2
-#  _____               _           _
3
-# |   __|___ ___ ___ _| |___ _____| |_ ___ ___ ___
4
-# |   __|  _| -_| -_| . | . |     | . | . |   | -_|
5
-# |__|  |_| |___|___|___|___|_|_|_|___|___|_|_|___|
6
-#
7
-#                              Freedom in the Cloud
8
-#
9
-# Functions for installing meteor
10
-# See meteor.com
11
-#
12
-# License
13
-# =======
14
-#
15
-# Copyright (C) 2017-2018 Bob Mottram <bob@freedombone.net>
16
-#
17
-# This program is free software: you can redistribute it and/or modify
18
-# it under the terms of the GNU Affero General Public License as published by
19
-# the Free Software Foundation, either version 3 of the License, or
20
-# (at your option) any later version.
21
-#
22
-# This program is distributed in the hope that it will be useful,
23
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
24
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
25
-# GNU Affero General Public License for more details.
26
-#
27
-# You should have received a copy of the GNU Affero General Public License
28
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
29
-
30
-METEOR_RELEASE='1.4.4.1'
31
-METEOR_REPO="https://github.com/meteor/meteor"
32
-METEOR_COMMIT='b52c6587d7542c0f27481a3bee8c65be06068ac1'
33
-METEOR_USERACCOUNTS_REPO="git://github.com/meteor-useraccounts/core.git"
34
-METEOR_USERACCOUNTS_COMMIT='2e8986813b51f321f908d2f6211f6f81f76cd627'
35
-
36
-function meteor_cleanUp {
37
-    rm -rf "$TARBALL_FILE"
38
-    rm -rf "$INSTALL_TMPDIR"
39
-}
40
-
41
-function install_meteor_script {
42
-    meteor_dir="$1"
43
-
44
-    if [ ! "$meteor_dir" ]; then
45
-        echo $'No meteor install directory specified'
46
-        exit 692025
47
-    fi
48
-
49
-    if [ ! -d "$meteor_dir" ]; then
50
-        echo $'Meteor install directory not found'
51
-        exit 845382
52
-    fi
53
-
54
-    if [[ "$(arch)" == "arm"* ]]; then
55
-        echo 'meteor does not support ARM'
56
-        exit 8362952
57
-    fi
58
-    if [[ "$(arch)" == "i386" || "$(arch)" == "x86_32" ]]; then
59
-        PLATFORM="os.linux.x86_32"
60
-    else
61
-        PLATFORM="os.linux.x86_64"
62
-    fi
63
-
64
-    RELEASE="$METEOR_RELEASE"
65
-
66
-    DIR_PREFIX="/usr/local"
67
-
68
-    TARBALL_URL="https://meteorinstall-4168.kxcdn.com/packages-bootstrap/${RELEASE}/meteor-bootstrap-${PLATFORM}.tar.gz"
69
-    INSTALL_TMPDIR="$meteor_dir/.meteor-install-tmp"
70
-    TARBALL_FILE="$meteor_dir/.meteor-tarball-tmp"
71
-
72
-    # Remove temporary files now in case they exist.
73
-    meteor_cleanUp
74
-
75
-    if [ -d "$INSTALL_TMPDIR" ]; then
76
-        rm -rf "$INSTALL_TMPDIR"
77
-    fi
78
-    mkdir "$INSTALL_TMPDIR"
79
-
80
-    if [ ! -f "${TARBALL_FILE}" ]; then
81
-        echo "Downloading Meteor distribution"
82
-        # keep trying to curl the file until it works (resuming where possible)
83
-        MAX_ATTEMPTS=10
84
-        RETRY_DELAY_SECS=5
85
-        set +e
86
-        ATTEMPTS=0
87
-        while [ $ATTEMPTS -lt $MAX_ATTEMPTS ]
88
-        do
89
-            ATTEMPTS=$((ATTEMPTS + 1))
90
-
91
-            if curl --progress-bar --fail --continue-at - \
92
-                    "$TARBALL_URL" --output "$TARBALL_FILE"; then
93
-                break
94
-            fi
95
-
96
-            echo "Retrying download in $RETRY_DELAY_SECS seconds..."
97
-            sleep $RETRY_DELAY_SECS
98
-        done
99
-    fi
100
-
101
-    if [ ! -f "${TARBALL_FILE}" ]; then
102
-        echo $'meteor tarball could not be downloaded'
103
-        exit 7272452
104
-    fi
105
-
106
-    tar -xzf "$TARBALL_FILE" -C "$INSTALL_TMPDIR" -o
107
-
108
-    if [ ! -f "${INSTALL_TMPDIR}/.meteor/meteor" ]; then
109
-        echo $'tarball not extracted'
110
-        exit 693252
111
-    fi
112
-
113
-    # shellcheck disable=SC2086
114
-    mv ${INSTALL_TMPDIR}/.meteor $meteor_dir
115
-
116
-    meteor_cleanUp
117
-
118
-    echo ''
119
-    echo "Meteor ${RELEASE} has been installed in $meteor_dir/.meteor"
120
-
121
-    METEOR_SYMLINK_TARGET="$(readlink "$meteor_dir/.meteor/meteor")"
122
-    METEOR_TOOL_DIRECTORY="$(dirname "$METEOR_SYMLINK_TARGET")"
123
-    LAUNCHER="$meteor_dir/.meteor/$METEOR_TOOL_DIRECTORY/scripts/admin/launch-meteor"
124
-
125
-    if cp "$LAUNCHER" "$DIR_PREFIX/bin/meteor" >/dev/null 2>&1; then
126
-        echo "Writing a launcher script to $DIR_PREFIX/bin/meteor for your convenience."
127
-        cat <<"EOF"
128
-
129
-To get started fast:
130
-
131
-  $ meteor create ~/my_cool_app
132
-  $ cd ~/my_cool_app
133
-  $ meteor
134
-
135
-Or see the docs at:
136
-
137
-  docs.meteor.com
138
-
139
-EOF
140
-    elif type sudo >/dev/null 2>&1; then
141
-        echo "Writing a launcher script to $DIR_PREFIX/bin/meteor for your convenience."
142
-        echo "This may prompt for your password."
143
-
144
-        # New macs (10.9+) don't ship with /usr/local, however it is still in
145
-        # the default PATH. We still install there, we just need to create the
146
-        # directory first.
147
-        # XXX this means that we can run sudo too many times. we should never
148
-        #     run it more than once if it fails the first time
149
-        if [ ! -d "$DIR_PREFIX/bin" ] ; then
150
-            sudo mkdir -m 755 "$DIR_PREFIX" || true
151
-            sudo mkdir -m 755 "$DIR_PREFIX/bin" || true
152
-        fi
153
-
154
-        if sudo cp "$LAUNCHER" "$DIR_PREFIX/bin/meteor"; then
155
-            cat <<"EOF"
156
-
157
-To get started fast:
158
-
159
-  $ meteor create ~/my_cool_app
160
-  $ cd ~/my_cool_app
161
-  $ meteor
162
-
163
-Or see the docs at:
164
-
165
-  docs.meteor.com
166
-
167
-EOF
168
-        else
169
-            cat <<EOF
170
-
171
-Couldn't write the launcher script. Please either:
172
-
173
-  (1) Run the following as root:
174
-        cp "$LAUNCHER" /usr/bin/meteor
175
-  (2) Add "\$meteor_dir/.meteor" to your path, or
176
-  (3) Rerun this command to try again.
177
-
178
-Then to get started, take a look at 'meteor --help' or see the docs at
179
-docs.meteor.com.
180
-EOF
181
-        fi
182
-    else
183
-        cat <<EOF
184
-
185
-Now you need to do one of the following:
186
-
187
-  (1) Add "\$meteor_dir/.meteor" to your path, or
188
-  (2) Run this command as root:
189
-        cp "$LAUNCHER" /usr/bin/meteor
190
-
191
-Then to get started, take a look at 'meteor --help' or see the docs at
192
-docs.meteor.com.
193
-EOF
194
-    fi
195
-
196
-}
197
-
198
-function install_meteor {
199
-    apt-get -yq install curl
200
-    if [ ! -d "$INSTALL_DIR/meteor" ]; then
201
-        mkdir "$INSTALL_DIR/meteor"
202
-    fi
203
-    cd "$INSTALL_DIR/meteor" || exit 72345274
204
-    install_meteor_script
205
-}
206
-
207
-function remove_meteor {
208
-    if [ -f /usr/local/bin/meteor ]; then
209
-        rm /usr/local/bin/meteor
210
-    fi
211
-    if [ -f /usr/bin/meteor ]; then
212
-        rm /usr/bin/meteor
213
-    fi
214
-}
215
-
216
-# NOTE: deliberately no exit 0