diff options
Diffstat (limited to 'nquakesv-init.py')
-rwxr-xr-x | nquakesv-init.py | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/nquakesv-init.py b/nquakesv-init.py index c042f8b93d07..0b6dbcb12414 100755 --- a/nquakesv-init.py +++ b/nquakesv-init.py @@ -10,6 +10,7 @@ import pwd import datetime import json import subprocess +from urllib.request import urlopen timestamp = datetime.datetime.now().strftime('%Y.%m.%d_%H%M.%S') user = pwd.getpwuid(os.geteuid()).pw_name @@ -71,8 +72,29 @@ def buildRootTree(ver = False): if os.path.isdir(nquakedir): os.rename(nquakedir, '{0}.bak_{1}'.format(nquakedir, timestamp)) os.makedirs(nquakedir, exist_ok = True) + # Some meta information with open(nquakedir + '/VERSION', 'w') as f: f.write('Generated on nquakesv package version {0}\n'.format(ver)) + with open(nquakedir + '/admin', 'w') as f: + f.write(user + '\n') + with urlopen('https://ipinfo.io/ip') as ipfetch: + ipaddr = ipfetch.read().decode('utf-8') + with open(nquakedir + '/hostdns', 'w') as f: + f.write(ipaddr) + with open(nquakedir + '/ip', 'w') as f: + f.write(ipaddr) + with open(nquakedir + '/hostname', 'w') as f: + f.write('nQuake running on Arch Linux\n') + with open(nquakedir + '/install_dir', 'w') as f: + f.write(nquakedir + '\n') + with open(nquakedir + '/README', 'w') as f: + f.write("""Please review the following files in this directory to ensure that they contain the correct information. + admin - your name and contact info. Typically, this is in the form of: Handle (email@address.tld) + hostdns - the DNS entry of your server. If you don't have one, just map this to your external IP address. + hostname - the name used for server browsers. + install_dir - leave this unchanged. + ip - your external/WAN-accessible IP address.""") + f.write('\n\nNote that these files are not used by default, but are compatible with the upstream nquakesv scripts- so if you opt to use them, you can.\n') # Generated from a vanilla from-"source" nquakesv install # and generated by running the following inside the directory: # find ./ -type d -printf "%P\n" | sed -e '/^$/d' | sort @@ -112,6 +134,7 @@ def buildRootTree(ver = False): def main(): buildRootTree() populateTree() + print('Setup has completed successfully. Please review ~/.nquakesv/README') if __name__ == '__main__': main() |