forked from wulukewu/noip-renewer-github
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgenerate_scripts.py
More file actions
39 lines (31 loc) · 1.66 KB
/
generate_scripts.py
File metadata and controls
39 lines (31 loc) · 1.66 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
import os
# Number of scripts to generate
num_scripts = 100
lines_per_script = 1
# Directory to save scripts
output_dir = 'scripts'
os.makedirs(output_dir, exist_ok=True)
for chunk in range(1, num_scripts + 1):
start = (chunk - 1) * lines_per_script + 1
end = start + lines_per_script - 1
# Initialize a variable to store the script content
script_content = "#!/bin/bash\n"
for i in range(start, end + 1):
username_var = f"NO_IP_USERNAME_{i}"
password_var = f"NO_IP_PASSWORD_{i}"
totp_key_var = f"NO_IP_TOTP_KEY_{i}"
script_content += 'username' + str(i) + '="${{ secrets.' + username_var + ' }}"\n'
script_content += 'password' + str(i) + '="${{ secrets.' + password_var + ' }}"\n'
script_content += 'totp_key' + str(i) + '="${{ secrets.' + totp_key_var + ' }}"\n\n'
script_content += 'if [ -n "$username' + str(i) + '" ] && [ -n "$password' + str(i) + '" ] && [ -n "$totp_key' + str(i) + '" ]; then\n'
script_content += ' echo "Processing account ' + str(i) + ': $username' + str(i) + '"\n'
script_content += ' docker run --rm \\\n'
script_content += ' --env NO_IP_USERNAME="$username' + str(i) + '" \\\n'
script_content += ' --env NO_IP_PASSWORD="$password' + str(i) + '" \\\n'
script_content += ' --env NO_IP_TOTP_KEY="$totp_key' + str(i) + '" \\\n'
script_content += ' simaofsilva/noip-renewer:latest\n'
script_content += 'fi\n\n'
# Write the accumulated content to the script file
script_file = os.path.join(output_dir, f'script_chunk_{chunk}.sh')
with open(script_file, 'w') as f:
f.write(script_content)