Repository navigation
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·138 lines (121 loc) · 3.74 KB
/
Copy pathinstall.sh
File metadata and controls
executable file
·138 lines (121 loc) · 3.74 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
130
131
132
133
134
135
136
137
138
#!/bin/bash
# Installation script for RedditModLog systemd services
set -e
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
# shellcheck disable=SC2034 # Reserved for future use
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
echo -e "${GREEN}RedditModLog Systemd Installation Script${NC}"
echo "========================================="
# Check if running as root
if [[ $EUID -ne 0 ]]; then
echo -e "${RED}This script must be run as root${NC}"
exit 1
fi
# Create user if it doesn't exist
if ! id "modlogbot" &>/dev/null; then
echo "Creating modlogbot user..."
useradd -r -s /bin/false -d /opt/RedditModLog -m modlogbot
else
echo "User modlogbot already exists"
fi
# Create necessary directories
echo "Creating directories..."
mkdir -p /var/log/redditmodlog
mkdir -p /etc/redditmodlog
mkdir -p /opt/RedditModLog/data
# Set permissions
echo "Setting permissions..."
chown -R modlogbot:modlogbot /var/log/redditmodlog
chown -R modlogbot:modlogbot /opt/RedditModLog/data
chown modlogbot:modlogbot /etc/redditmodlog
chmod 755 /var/log/redditmodlog
chmod 755 /etc/redditmodlog
# Install systemd service template
echo "Installing systemd service template..."
cp modlog@.service /etc/systemd/system/
# Install logrotate configuration
echo "Installing logrotate configuration..."
cp redditmodlog.logrotate /etc/logrotate.d/redditmodlog
# Create example configurations
echo "Creating example configurations..."
# OpenSignups config
cat >/etc/redditmodlog/opensignups.json.example <<EOF
{
"reddit": {
"client_id": "your_client_id",
"client_secret": "your_client_secret",
"username": "your_bot_username",
"password": "your_bot_password"
},
"source_subreddit": "OpenSignups",
"wiki_page": "modlog",
"retention_days": 180,
"batch_size": 500,
"update_interval": 600,
"anonymize_moderators": true,
"max_wiki_entries_per_page": 1000
}
EOF
# Usenet config
cat >/etc/redditmodlog/usenet.json.example <<EOF
{
"reddit": {
"client_id": "your_client_id",
"client_secret": "your_client_secret",
"username": "your_bot_username",
"password": "your_bot_password"
},
"source_subreddit": "usenet",
"wiki_page": "modlog",
"retention_days": 30,
"batch_size": 100,
"update_interval": 300,
"anonymize_moderators": true,
"max_wiki_entries_per_page": 1000
}
EOF
# Example environment file
cat >/etc/redditmodlog/example.env <<EOF
# Optional environment variables to override config file
# Uncomment and set as needed
# REDDIT_CLIENT_ID=your_client_id
# REDDIT_CLIENT_SECRET=your_client_secret
# REDDIT_USERNAME=your_bot_username
# REDDIT_PASSWORD=your_bot_password
# BATCH_SIZE=100
# UPDATE_INTERVAL=300
EOF
chmod 640 /etc/redditmodlog/*.example
chmod 640 /etc/redditmodlog/*.env
chown -R modlogbot:modlogbot /etc/redditmodlog/
# Reload systemd
echo "Reloading systemd daemon..."
systemctl daemon-reload
echo ""
echo -e "${GREEN}Installation complete!${NC}"
echo ""
echo "Next steps:"
echo "1. Copy and edit the config files:"
echo " cp /etc/redditmodlog/opensignups.json.example /etc/redditmodlog/opensignups.json"
echo " cp /etc/redditmodlog/usenet.json.example /etc/redditmodlog/usenet.json"
echo " nano /etc/redditmodlog/opensignups.json"
echo " nano /etc/redditmodlog/usenet.json"
echo ""
echo "2. Start the services:"
echo " systemctl start modlog@opensignups.service"
echo " systemctl start modlog@usenet.service"
echo ""
echo "3. Enable auto-start on boot:"
echo " systemctl enable modlog@opensignups.service"
echo " systemctl enable modlog@usenet.service"
echo ""
echo "4. Check logs:"
echo " tail -f /var/log/redditmodlog/opensignups.log"
echo " tail -f /var/log/redditmodlog/usenet.log"
echo ""
echo "5. Check service status:"
echo " systemctl status modlog@opensignups.service"
echo " systemctl status modlog@usenet.service"