This repository was archived by the owner on Jun 2, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsetup.sh
More file actions
129 lines (109 loc) · 3.83 KB
/
Copy pathsetup.sh
File metadata and controls
129 lines (109 loc) · 3.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
#!/bin/bash
set -e
source ve/bin/activate
TWITTER_APP_NAME=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 8 | head -n 1)
clear
echo "-- Welcome to the t2m-docker setup! --"
echo
echo "This will guide you through the steps to set up automatic "
echo "copying of your Twitter posts to your Mastodon account."
echo
echo "First up, head to https://apps.twitter.com/app/new in your "
echo "web browser, and enter the following details without quotes:"
echo
echo "Name: 't2m ($TWITTER_APP_NAME)'"
echo "Description: 't2m (Twitter to Mastodon)'"
echo "Website: 'https://t2m-docker.local/'"
echo "Callback URL: (leave empty)"
echo "Check 'Yes, I have read and agree to the Twitter Developer Agreement.'"
echo "Click 'Create your Twitter application'"
echo
echo "Once you have completed these steps, hit Enter."
read
echo
clear
echo "-- Configure access permissions --"
echo
echo "On the next page, under the 'Details' tab under the 'Application Settings' "
echo "section, click 'modify app permissions' next to 'Access level' and "
echo "change it to read-only."
echo
echo "Once you have completed this step, hit Enter."
echo
read
echo
clear
echo "-- Create access token --"
echo
echo "Once this setting is saved, click the tab 'Keys and Access Tokens', just "
echo "underneath your application name. Then at the bottom of the screen:"
echo
echo "Click 'Create my access token'"
echo
echo "Once you have completed this step, hit Enter."
echo
read
echo
clear
echo "-- Paste in keys and secrets --"
echo
echo "We are almost done with Twitter setup. I just need the "
echo "following values from this page, which you need to paste "
echo "into your terminal:"
echo
echo "- Consumer Key (API Key)"
echo "- Consumer Secret (API Secret)"
echo "- Access Token"
echo "- Access Token Secret"
echo
read -p "Paste or enter the Consumer Key (API Key) now: " TWITTER_CONSUMER_KEY
read -p "Paste or enter the Consumer Secret (API Secret) now: " TWITTER_CONSUMER_SECRET
read -p "Paste or enter the Access Token now: " TWITTER_ACCESS_TOKEN_KEY
read -p "Paste or enter the Access Token Secret now: " TWITTER_ACCESS_TOKEN_SECRET
echo
clear
echo "-- Final steps --"
echo
echo "Finally, what's your Twitter username (without the @ symbol)?"
echo
read -p "Paste or enter your Twitter username: " TWITTER_USERNAME
echo
clear
echo "-- Mastodon setup --"
echo
echo "Alright! We're all done with Twitter. Now we need to set up the credentials "
echo "for Mastodon."
echo
read -p "What's your Mastodon username (just the username like 'hq', no domain): " MASTODON_USER
read -p "What's the domain of your Mastodon instance (just the domain, like 'mastodon.social'): " MASTODON_DOMAIN
echo
cat >/srv/conf.yaml <<EOF
consumer_key: "$TWITTER_CONSUMER_KEY"
consumer_secret: "$TWITTER_CONSUMER_SECRET"
access_token_key: "$TWITTER_ACCESS_TOKEN_KEY"
access_token_secret: "$TWITTER_ACCESS_TOKEN_SECRET"
EOF
cd /srv
/srv/t2m one $TWITTER_USERNAME -m $MASTODON_USER@$MASTODON_DOMAIN -d -n 0
MASTODON_USER_CRED=$(cat /srv/t2m_$MASTODON_USER@${MASTODON_DOMAIN}_creds.txt)
MASTODON_DOMAIN_CRED=$(cat /srv/t2m_${MASTODON_DOMAIN}_clientcred.txt)
MASTODON_DOMAIN_CRED=$(echo "$MASTODON_DOMAIN_CRED" | tr '\n' '_')
echo
clear
echo "-- Docker instructions --"
echo
echo "Run the following Docker command on a server somewhere:"
echo
echo -n "docker run -d --rm "
echo -n "-e TWITTER_USERNAME=\"$TWITTER_USERNAME\" "
echo -n "-e TWITTER_CONSUMER_KEY=\"$TWITTER_CONSUMER_KEY\" "
echo -n "-e TWITTER_CONSUMER_SECRET=\"$TWITTER_CONSUMER_SECRET\" "
echo -n "-e TWITTER_ACCESS_TOKEN_KEY=\"$TWITTER_ACCESS_TOKEN_KEY\" "
echo -n "-e TWITTER_ACCESS_TOKEN_SECRET=\"$TWITTER_ACCESS_TOKEN_SECRET\" "
echo -n "-e MASTODON_USER=\"$MASTODON_USER\" "
echo -n "-e MASTODON_DOMAIN=\"$MASTODON_DOMAIN\" "
echo -n "-e MASTODON_USER_CRED=\"$MASTODON_USER_CRED\" "
echo -n "-e MASTODON_DOMAIN_CRED=\"$MASTODON_DOMAIN_CRED\" "
echo "redpointgames/t2m-docker"
echo
echo