|
@@ -1,100 +0,0 @@
|
1
|
|
-#!/bin/bash
|
2
|
|
-#
|
3
|
|
-# .---. . .
|
4
|
|
-# | | |
|
5
|
|
-# |--- .--. .-. .-. .-.| .-. .--.--. |.-. .-. .--. .-.
|
6
|
|
-# | | (.-' (.-' ( | ( )| | | | )( )| | (.-'
|
7
|
|
-# ' ' --' --' -' - -' ' ' -' -' -' ' - --'
|
8
|
|
-#
|
9
|
|
-# Freedom in the Cloud
|
10
|
|
-#
|
11
|
|
-
|
12
|
|
-# Adds an xmpp user
|
13
|
|
-
|
14
|
|
-# License
|
15
|
|
-# =======
|
16
|
|
-#
|
17
|
|
-# Copyright (C) 2015-2016 Bob Mottram <bob@freedombone.net>
|
18
|
|
-#
|
19
|
|
-# This program is free software: you can redistribute it and/or modify
|
20
|
|
-# it under the terms of the GNU Affero General Public License as published by
|
21
|
|
-# the Free Software Foundation, either version 3 of the License, or
|
22
|
|
-# (at your option) any later version.
|
23
|
|
-#
|
24
|
|
-# This program is distributed in the hope that it will be useful,
|
25
|
|
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
26
|
|
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
27
|
|
-# GNU Affero General Public License for more details.
|
28
|
|
-#
|
29
|
|
-# You should have received a copy of the GNU Affero General Public License
|
30
|
|
-# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
31
|
|
-
|
32
|
|
-PROJECT_NAME='freedombone'
|
33
|
|
-
|
34
|
|
-export TEXTDOMAIN=${PROJECT_NAME}-addxmpp
|
35
|
|
-export TEXTDOMAINDIR="/usr/share/locale"
|
36
|
|
-
|
37
|
|
-EMAIL_ADDRESS=
|
38
|
|
-NEW_USER_PASSWORD=
|
39
|
|
-
|
40
|
|
-function show_help {
|
41
|
|
- echo ''
|
42
|
|
- echo $"${PROJECT_NAME}-addxmpp -e [email address] -p [password]"
|
43
|
|
- echo ''
|
44
|
|
- exit 0
|
45
|
|
-}
|
46
|
|
-
|
47
|
|
-while [[ $# > 1 ]]
|
48
|
|
-do
|
49
|
|
- key="$1"
|
50
|
|
-
|
51
|
|
- case $key in
|
52
|
|
- -h|--help)
|
53
|
|
- show_help
|
54
|
|
- ;;
|
55
|
|
- -e|--email)
|
56
|
|
- shift
|
57
|
|
- EMAIL_ADDRESS="$1"
|
58
|
|
- ;;
|
59
|
|
- -p|--password|--passphrase)
|
60
|
|
- shift
|
61
|
|
- NEW_USER_PASSWORD="$1"
|
62
|
|
- ;;
|
63
|
|
- *)
|
64
|
|
- # unknown option
|
65
|
|
- ;;
|
66
|
|
- esac
|
67
|
|
- shift
|
68
|
|
-done
|
69
|
|
-
|
70
|
|
-if [ ! -d /etc/prosody ]; then
|
71
|
|
- echo $'xmpp server is not installed'
|
72
|
|
- exit 0
|
73
|
|
-fi
|
74
|
|
-
|
75
|
|
-if [ ! $EMAIL_ADDRESS ]; then
|
76
|
|
- show_help
|
77
|
|
- exit 1
|
78
|
|
-fi
|
79
|
|
-
|
80
|
|
-USERNAME=$(echo $EMAIL_ADDRESS | awk -F '@' '{print $1}')
|
81
|
|
-if [ ! $NEW_USER_PASSWORD ]; then
|
82
|
|
- prosodyctl adduser $EMAIL_ADDRESS
|
83
|
|
-else
|
84
|
|
- DOMAIN_NAME=$(echo $EMAIL_ADDRESS | awk -F '@' '{print $2}')
|
85
|
|
- prosodyctl register $USERNAME $DOMAIN_NAME "$NEW_USER_PASSWORD"
|
86
|
|
- if [ ! "$?" = "0" ]; then
|
87
|
|
- exit 2
|
88
|
|
- fi
|
89
|
|
-fi
|
90
|
|
-
|
91
|
|
-# add the xmpp address to email headers
|
92
|
|
-if [ -f /home/$USERNAME/.muttrc ]; then
|
93
|
|
- if ! grep -q "Jabber-ID" /home/$USERNAME/.muttrc; then
|
94
|
|
- echo "my_hdr Jabber-ID: $EMAIL_ADDRESS" >> /home/$USERNAME/.muttrc
|
95
|
|
- else
|
96
|
|
- sed -i "s|my_hdr Jabber-ID.*|my_hdr Jabber-ID: $EMAIL_ADDRESS|g" /home/$USERNAME/.muttrc
|
97
|
|
- fi
|
98
|
|
-fi
|
99
|
|
-
|
100
|
|
-exit 0
|