Skip to content

Instantly share code, notes, and snippets.

@Nonickn
Forked from primarydataloop/CHANGELOG
Created September 22, 2013 21:00
Show Gist options
  • Save Nonickn/6663752 to your computer and use it in GitHub Desktop.
Save Nonickn/6663752 to your computer and use it in GitHub Desktop.
pdl-idler (0.77) README
DESCRIPTION
-----------
pdl-idler will install, update, and run multiple instances of steam and tf2
game clients in individual wine prefixes for the purpose of textmode idling.
As many considerations as possible are made to reduce cpu load and memory
consumption, while still permitting the use of a gui client. All downloaded
data is shared between account prefixes, and a special dedicated idle server
for item farming is started that parks clients in the connection state,
(thereby not loading the map) so they can run at one frame per second and be
allowed a low-memory mode. Up to 32 of these farm clients will be sent to a
separate X/Xvfb server, so that an input helper script can accept item drop
notifications unobstructed. Finally, status and backpack actions, utilities,
and wrappers around community functions are provided.
REQUIREMENTS
------------
bash, bc, netcat, screen, sudo, wget, wine >= 1.5, and xdotool are required.
Xvfb is required if the machine is not running the proprietary nvidia/flgrx
graphics drivers. x11vnc is optionally used when the script has to start the
main X server or the farming Xvfb server.
INSTALLATION
------------
Download the tarball from 'https://gist.github.com/primarydataloop/1432762',
extract its contents to a location such as '~/pdl-idler'. The script will
update itself from the gist site in the future. On the first invocation of
pdl-idler, you will be asked for your sudo password so that the script can
alter '/etc/sudoers.conf' and allow the user to run select commands as root
without a password. On Debian systems, the file '/etc/X11/Xwrapper.config'
will also be corrected so that the user can start X servers.
USAGE
-----
bash pdl-idler.sh ACTION1{,/%}ACTION2=arg^x... {acct1 acct2 ...}
pdl-idler accepts a list of actions to perform (separated by ',' or '%' ) and
the specified account usernames (separated by spaces). If no accounts are
specified, then all known accounts will be specified. Actions grouped with the
'%' character will all execute before proceeding to the next account, instead
of having each action execute on all accounts. To supply optional parameters,
append an action with the '=' character followed by an argument string in
which all spaces are referenced by the '^' character, and semicolons are
escaped with a '\'.
The following are the available actions with optional parameters in brackets.
[ install ]
If not already running, the X server will be started (followed by x11vnc if
it is installed), then a separate wineprefix for the account will be created
or updated. If necessary, the steam launcher will be installed, data links
and directories will be created, and some configuration will be prepped.
[ login{=mode} ]
If the wineprefix does not exist and there is no credential backup, the user
will be prompted before the install action is performed. Upon initial login
of an account, the user may have to input the password and/or a guard code
into the steam login dialog. If there was no credential backup at time of
install, steam will be restarted so the configuration can be applied. The
user may supply the 'low' mode flag to launch steam in low-resource mode
without html/trade support, or the 'high' to include support for the in-game
overlay. The 'hide' flag can also be added to neglect the explorer process,
thereby hiding the steam system tray icon. (def: "")
[ create ]
After the user is prompted for a password and an e-mail address, the install
action will be performed, then a login will start. When the greeting window
arrives the account form fields will be automatically filled and submitted,
the account will be created, then the login will proceed.
[ online ]
If logged in, sign on to steam friends.
[ offline ]
If online, sign off steam friends.
[ enter{=id} ]
Mark the current friends status, then go online and join a public chatroom
via its community id. (def: "103582791432273268")
[ exit ]
Leave the chatroom and restore prior friends status.
[ friend{=accounts} ]
Perform or queue friend invite request/acceptances for each account defined
in the action parameter (where multiple accounts are separated by a '-') or
for all accounts that were targeted on invocation. (def: target accounts)
[ play{=mode} ]
Login if necessary, then start the client in gui mode. Once there is a
client of any type running, power management will be disabled. (def: "")
[ start{=mode} ]
Login if necessary, then start the client in textmode. (def: "")
[ command{=cmd} ]
If the client is running, execute console commands as supplied from the
action parameter or prompt. (def: prompts)
[ connect{=place} ]
If the client isn't running, start it in textmode, then connect to a server
via the ip address or host a listen server via the specified map name. If
there is no parameter specified (or if the server cannot be pinged), the
dedicated idle server will be started and will connect to an IRC server, the
client will lower its fps, then will connect to it. If connecting to a
normal server, low-resource clients will restart in normal mode.
(def: use idle server)
[ farm ]
Logout of a normal session, start the dedicated server and a separate X
server on the next display (if they weren't running), then login with the
'low-hide' login flags on the separate display. When using the nvidia/flgrx
driver, there will be a short period where the screen will blank. If not
running, start the client in low-resource, soundless noshaderapi mode, then
connect. If this is the initial farm client load, an input helper script
will be started that is used to automatically accept drop notifications.
[ join{=team-class} ]
If in-game, join a random or specified team/class. If the client is running
in textmode, it will reissue this command periodically so as to maintain
this selection in case of map or gameplay changes. (def: "auto-auto")
[ spectate ]
If in-game, join spectators.
[ disconnect ]
If connected, disconnect from the server. If the server was the dedicated
idle server, print the contents of the account backpack to the server log,
then reset the client fps. If the idle server player count is 0 when the
script completes, then it will be stopped.
[ reconnect{=place} ]
Disconnect and reconnect. (def: use idle server)
[ stop{=kill} ]
Stop the client with a console command or process kill (if it is hung or the
kill parameter is 'yes'). If the script is finished and there are no clients
running, desktop power management will be restored. (def: "")
[ restart{=kill} ]
Stop then start. (def: "")
[ logout{=kill} ]
Stop then logout out of steam, or kill the process if it is hung or the kill
parameter is 'yes'. If there are no steam processes remaining when the
script ends, the appropriate X server will be stopped if the script had
originally started it. (def: "")
[ relogin{=mode} ]
Logout then login. (def: "")
[ website{=web} ]
Open tf2-related websites for an initiated account in the default browser.
The choices include 'tf2b',' tf2items', 'backpack.tf', 'stm_com', 'stm_inv',
and 'willitcraft'. (def: "tf2b")
[ list{=ref} ]
Print account information consisting of an item/crate count, the steam user
id, the last 6 characters of the connection hash, version information and
status flags. The item data will be read from a cache if it isn't older than
5 minutes and the refresh parameter isn't 'yes', or if it is present and the
refresh parameter is 'no'. (def: "")
[ backpack{=ref} ]
List then detail backpack contents. (def: "")
[ status{=ref} ]
Show system and server information then list specified accounts (if they are
logged in) followed by their process statistics. (def: "")
[ log{=files} ]
Page log files, including the running server, client console, and other
steam files. The choices include 'cl', 'sv', 'app', 'boot', 'cloud', 'conn',
'content', 'ccfg', 'lcfg', 'scfg', and 'all'. Press Q to cycle through each
log or CTRL-C to abort. (def: "all")
[ utility{=utils} ]
Execute shell commands and steam urls (if it is started) under the script
environment for the selected account prefix. (def: "regedit")
[ sleep{=time} ]
Wait for a specified period of time or until enter is pressed three times.
If this action is not grouped with any others (via the '%' character) it
will only execute once, instead of being executed for each logged in
account. (def: "1m")
[ uninstall ]
Logout, backup credentials, then remove the client files and wineprefix.
[ reinstall ]
Uninstall then install.
[ delete ]
Uninstall then remove the credential backup.
ADVANCED ACCOUNT SPECIFICATION
------------------------------
The optional file 'pdl-idler.conf' can be filled with a large multi-line
ACCOUNTS variable that details the order of accounts on invocation (when none
are specified) or for selecting an account by its position prefaced with a
'+'. An ACCOUNT_BLOCKS array can be used for referencing account groups via
the array index prefaced with a ':'. Finally, one may negate an account from
being specified (if it was part an account group or the assumption of all
accounts) by prefacing its name or index with the '-' character.
# Guys
ACCOUNTS1="ben"
ACCOUNTS1="${ACCOUNTS1} mann1 mann2"
ACCOUNTS1="${ACCOUNTS1} mann3 mann4"
ACCOUNTS="${ACCOUNTS1}"
ACCOUNT_BLOCKS[1]=${ACCOUNTS1}
# Gals
ACCOUNTS1="jerry"
ACCOUNTS2="${ACCOUNTS1} herr1 herr2"
ACCOUNTS2="${ACCOUNTS2} herr3 herr4"
ACCOUNTS="${ACCOUNTS} ${ACCOUNTS2}"
ACCOUNT_BLOCKS[2]=${ACCOUNTS2}
ENVIRONMENTAL VARIABLES
-----------------------
While most configuration is supplied as action parameters, some other
miscellaneous settings and personalization options can be specified as
environmental variables. You may set them in 'pdl-idler.conf', export them in
the shell, or include them as a preface to a script invocation.
[ X_DISPLAY ]
If starting the main X server, use this display. (def: ":0.0")
[ X_X11VNC ]
If no, don't start x11vnc with main X or farming Xvfb server. (def: "yes")
[ IRC_SERVER ]
Use this IRC server address, or skip if "none". (def: "irc.freenode.net")
[ IRC_SERVER_PASS ]
Use this IRC server password. (def: "")
[ IRC_SERVER_PORT ]
Use this IRC server port. (def: "6667")
[ IRC_CHANNEL ]
Use this IRC channel name. (def: "primarydataloop")
[ IRC_CHANNEL_PASS ]
Use this IRC channel password. (def: "")
CLIENT COMMAND ALIASES
----------------------
Useful command aliases are provided for pdl-idler clients to take advantage
of, with either the gui console or 'command' action.
[ mmute ]
Stop voice transmission and mute all players.
[ mhear ]
Stop voice transmission and unmute all players.
[ mtalk ]
Unmute all players and start voice transmission.
ACCOUNT CREDENTIAL SHARING
--------------------------
When employing multiple VMs or physical machines to idle a large pool of
accounts, it is recommended that the 'cred' directory be shared among these
hosts via a symlink to a samba share or a VM shared folder on the host. This
makes is such that the user will only have to input the account password and
guard code once on whichever is the the first host that is used to create and
login a prefix.
PERFORMANCE ASSUMPTIONS
-----------------------
A resource-constrained farm steam/tf2 pair will consume around 175MB and 150MB
of memory respectively, and can swap down to tens of MB of RAM, while still
maintaining a connection to the game/steam servers and being responsive to
item notification arrivals and command requests. As an anecdotal reference,
the author's weakest machine has 2GB of slow DDR2 and a Pentium 4 HT that
farms 16 accounts well enough, and uses a Phenom 1 dual-core with 4GB to
handle 32 clients. However, both of these machines feature modest linux
distributions and boast large swap partitions. A generous rule of thumb would
allow 8 clients for every GB of RAM, 3-4GB of swap space, and available CPU
core.
EXAMPLES
--------
[ login,start,online mann1 mann2 ]
Login mann1 and mann2, start their clients, then sign them onto friends.
[ list,login%start,enter :2 ]
List accounts in block 2, login and start each, then have them enter chat.
[ login=high,play,connect=cp_well ben ]
Login ben with the overlay, start the gui client, then host a listen server.
[ farm,sleep=10h,logout :1 -+1 jerry ]
Farm block 1 with jerry (without ben) for 10 hours then logout.
[ connect=1.2.3.4,join=red-pyro,command=say^hello\;volume^1\;mtalk mann4 ]
Connect mann4 to a friendly server then rock the mic as a pyro in red spawn.
[ log=app-cloud,utility=steam://settings\;regedit +2 ]
View app and cloud logs, steam settings, and registry of the second account.
[ friend=hurr1-hurr2-hurr3,website=stm_com ben ]
Get ben some lady friends then check out his profile.
SUPPORT/LINKS
-------------
[ irc://irc.freenode.net/primarydataloop ]
Default server IRC relay and discussion hub for advanced idler science.
[ steam://url/GroupSteamIdPage/103582791432273268 ]
Official group consisting entirely of human accounts.
[ https://gist.github.com/1432762#comment-833847 ]
Start of the github gist comment section for pdl-idler.
ACKNOWLEDGMENTS
---------------
Thanks tf2b, ##slackware, sourceirc, xdotool, hllib, etc. Powered by cream.
pdl-idler CHANGELOG
[version 0.77]
+ remove unused bitmap flag from get_window_id()
+ don't run various calls to echo that needlessly encapsulate other output
+ explicitly return true in pause()
+ show steam/hl2 pid in various output messages
+ pass the kill parameter from uninstall/delete to their calls to logout
+ fix delete removing files from similarly named accounts
+ hide error output in window raise/focus and successful login window unmap
+ have client echo starting log marker after running alias.cfg, not before
+ remove nice and ionice priority reductions from low/farm wine processes
+ show steam pid on authentication
+ mark ui version file upon extraction, not authentication
+ improve/fix password prompt, and check for a connection warning dialog
+ only check error window if steam is up and avoid extra pid check in login
+ timeout and retry client launch after 10 seconds if nothing happens
+ ensure 5 seconds had elapsed since login before preparing the client
+ show client version in schema output message, not loading
+ exit if steamcmd fails to receive license on server content check
+ create/link server console log immediately after steamcmd update
+ upgrade sourcemod to 1.5.1
+ start client notification trigger in alias.cfg instead of as a call to cmd()
+ remove 'low' command line parameter from farm client startup
+ wait 1.5 seconds instead of 0.5 when calculating total cpu usage in status
+ fix indentations in status
+ combine X server and x11vnc stop output messages
+ move check to resume power management to after any potential X server stops
+ adjust memory assumptions in readme
[version 0.76]
+ check shell before declaring functions and restart with bash if needed
+ change parentheses to brackets in output message markers
+ fail if the present working directory is not writable
+ move dependency check to before the gist update check
+ simplify steam/hl2 pid checks
+ add viewable flag to get_window_id()
+ handle private bp and fix output error with uninitiated accounts in list
+ use a dash instead of an underscore in cred host marker files
+ delete webcache and fix output error in delete
+ use Xvfb server instead of X for farming if the driver isn't nvidia or flgrx
+ start an x11vnc instance along with the Xvfb server for farming
+ rename registry file to registry.reg and don't hide or delete it
+ raise windows before focus when they can't be activated
+ focus window before new mouse click, and the escape press in close_window()
+ combine appropriate xdotool calls in raise+focus, close window and helper
+ move cred host check and insertion to before client file creation
+ sleep for 5 seconds if the cred file appears to be claimed by another host
+ rename 'pdl-idler.cfg' to 'autoexec.cfg'
+ provide a supplementary prompt on the shell for the user password if needed
+ delete 5 digit anonymous id userdata directories as well as those with 6
+ go offline but don't check the result when ensuring initial offline state
+ alter sourceirc download to allow upgrade/reinstall without a sourcemod bump
+ truncate irc name to prevent them from being too long for gameinfo/status
+ don't add chvt sudoers entry or use it in farm for hosts that use Xvfb
+ change sleep period before chvt switch from 5 seconds to 8
+ improve status output and device id deduction for vmware/virtualbox adapters
+ move uninstall/reinstall/delete to the end of usage/readme
+ clear the sudo password cache before alterting any permissions
+ ensure Xvfb is an entry in sudoers for hosts that use it
+ show version in pci id download message and assume nvidia driver over i915
+ downgrade fatal missing input errors to warnings
+ revert to a switch instead of if/else for the main action loop
+ add support section to readme and note potential Xvfb dependency
[version 0.75]
+ improve file downloading and failure
+ show incompatible shell in fatal output message
+ have the script restart itself automatically after update
+ save copy of steam uid in cred file for use with uninstalled prefixes
+ fail in version checks if there is no installed component
+ compare ui version to steam cdn manifest in list and extraction
+ really fix list 'no/yes' parameter
+ store cached web data as hidden files in 'cred' instead of in each prefix
+ elaborate crate count, use full uid, and remove bootstrapper version in list
+ detail uninstalled prefixes in list
+ use builtin silent read calls with a timeout instead of the external sleep
+ explicitly return true if the client console command succeeded
+ fix fps change/detection when setting it ingame
+ slow client command file read alias to 4 times the fps instead of 2
+ remove idler_kill and instead check for 'yes' parameters to logout/stop
+ show prefix version and size in delete output message
+ fix X server process check
+ improve steam account community id deduction
+ show both memory usages in online/offline/enter/exit output messages
+ change 'clientport' cvar to 28001
+ set 'cl_hud_playerclass_use_playermodel' cvar to 0
+ integrate 'pdl-idler.cfg' file into the script
+ disable filesystem access to the 'userdata/760' directory for steam cloud
+ change client listen server port start to 28101
+ remove old ui version v1370553818 download retry workaround
+ maybe fix steam hang retry and warn then retry if steam crashes post auth
+ show chat room id in enter output message
+ don't sync the xdotool windowmove call in enter
+ implement friend action that sends or queues invites between accounts
+ show memory usage in join/spectate output messages
+ change dedicated server port from 27014 to 28201
+ upgrade to metamod-1.10.0 and sourcemod 1.5.0
+ remove dashes from irc names to fix gameinfo/status
+ assume the specified server on 28201 is a pdl dedicated in connect
+ if there is a visible login window, have farm helper pause and raise it
+ remove useless one second sleep in farm helper
+ replace 'view' with a 'log' action to page client/server and other files
+ print usage text and skip other actions if 'help/usage' is specified
+ only attempt to run enter once if the specified chatroom id is invalid
+ check and respond to friend queue for active accounts after running actions
+ add friend text, perf summary, shared cred tip, and adjust readme/usage
[version 0.74]
+ allow 'no' parameter in list to skip tf2b pull
+ hide error if there was no cred host marker file to delete in logout
+ improve X server startup/shutdown with support for separate farm display
+ fix connect location/prefix location variable name conflict
+ don't set steam ui mode to mini in install to fix the temporary scrambled ui
+ change client resolution from 800x600 to 640x480
+ mark farm client/steam processes
+ restart wineserver without debugging after prep with farm marker if needed
+ sync the xdotool windowunmap and windowmove calls
+ increase ui extraction hang timeout from 60 to 150
+ have create function fail if it couldn't log in
+ download and use hllib to extract files from vpk files
+ add load() parameter to extract and alter client ui assisting farm helper
+ return 'noschema' if client might not have recieved item schema
+ check client pid for user cancel interpret in load
+ show pid in power management startup/shutdown output messages
+ stop then fail on client load if the item schema download explicitly failed
+ remove textmode startup parameter from farm client startup
+ upgrade to metamod-1.9.3-hg821 and sourcemod 1.5.0-hg3855
+ reintegrate server plugin code into the script once again
+ remove insecure from the server and farm client startup parameters
+ unset location/test variable before each try in connect
+ fix player count connection output message in connect
+ wait until the server has registered the initial client connection
+ remove login mode parameter to farm action and use 'low-hide'
+ start separate X server for farming and relogin regular sessions to use it
+ run chvt with sudo to restore the original VT on farm X server start
+ allow gui/textmode clients in farm to be used if explicitly started prior
+ use client command alias for triggering item notifications
+ start farm helper after the initial farm client connects to the server
+ perform dead process, screen session, and cred checks before the others
+ set wine check to allow versions 1.5-1.9
+ right-align the pid in defunct process output message
+ check for sudo dep and alter /etc/sudoers enable the user to run chvt
+ if present, alter /etc/X11/Xwrapper.config with sudo to allow user X start
+ reset display environmental variable with each client action
+ restore ui modifications if there are no steam farm processes on shutdown
+ remove cloud marker client pause bind
+ add sudo notes, remove script name from examples, and adjust readme/usage
[version 0.73]
+ disallow root from running the script
+ really fix gist/pci.ids update checks
+ add bitmap flag to get_window_id(), rename 'visible' flag to 'opacity'
+ show connection time in client disconnect output message
+ fix get_prefix_size() for prefixes one GB or larger
+ hide error if chmod doesn't find a userdata directory to alter in uninstall
+ show prefix version in uninstall output message
+ improve wine version parsing
+ use variables to configure IRC and other settings with explanation in readme
+ bump prefix version to 5
+ set the survey completion date to the present on login to prevent the prompt
+ make config.cfg empty and unwriteable
+ ensure that the trade hint in friends chat doesn't show via sharedconfig
+ disable filesystem access to the 'userdata/ugc' directory for steam cloud
+ add '-clearbeta' paraemter to steam startup
+ timeout then warn and restart steam if it stalls during init
+ kill and restart steam ui download if it attempts to download v1370553818
+ fix get_server_ircname() truncating hostnames with a dash
+ log steamcmd output to the server log and improve completion check
+ upgrade to metamod-1.9.3-hg820 and sourcemod 1.5.0-hg3843
+ fix get_process_usage() with multiple instances of the pid in proc output
+ only get the first listed gpu device name for the target pci id in status
+ fix status when the machine has no dnsdomainname
+ set WINEARCH to 'win32' to prevent the creation of 64-bit wine prefixes
+ account for nvidia+nouveau and ati/fglrx drivers in hardware detection
+ fix player count in server plugin restart
+ don't park clients with server plugin if their tv_nochat cvar isn't 0
+ fix usage typo, adjust wine dep, space bracketed titles, and fluff readme
[version 0.72]
+ fix gist and pci.ids update checks
+ timeout then warn and proceed on upgrade prompt
+ workaround client config exec error for old account names with periods
+ read dosfiles in unix format
+ fix backpack item type and memory usage output
+ synchronize cred files across machines and ensure collection after logout
+ disable filesystem access for steam cloud and use a local sharedconfig
+ add 'stm_com' and 'stm_inv' parameters to the website action
+ interpret user load cancel with the content log instead of sharedconfig
+ timeout then warn and proceed if there is no schema message on client start
+ revert to having server plugin in separate file
+ show timestamps on server plugin output
+ show server player count on farm connection output message
+ improve hardware detection and show wine version in status
+ don't execute utility for steam urls if the account is not logged in
+ fix pci.ids update check
+ negate hammer_dll.dll
+ fix server plugin compile when bash is not the default shell
[version 0.71]
+ handle gist being down and prompt before upgrade
+ check for recent enough wine
+ set steam network rate to 30000kb
+ use timestamped client console output
+ get client connection duration
+ add marker flags to waiting, warning, and error output messages
+ show prefix in status
+ bump prefix version to 4
+ disable game overlay with localconfig and not just dll overrides
+ reinstall the prefix if it was moved
+ set clients to use dxlevel 80 instead of 81
+ fix steam launcher installation output message
+ timeout and retry on hung steam ui extraction
+ fix cloud conflict window check
+ get tf2 license origin
+ improve steam ui version checking
+ upgrade to sourcemod 1.5.0-hg3841
+ shuffle hlds/steamcmd cache directory instead of failing if it was occupied
+ include sourceirc with the server
+ improve fps changes and start/keep farm clients at 1fps without auto aliases
+ improve client disconnect and timing
+ fix cpu usage pid check
+ show server and client version in status
+ improve/fix account targeting
[version 0.70]
+ fail unless bash is the running shell
+ check gist and exit after applying a script update
+ get client connection state as well as map or ip address
+ improve output message printing
+ cache tf2b for 5 minutes and also obtain the steam profile page in list
+ fix parameter and delete bad cache with better tf2b error handling in list
+ adjust backpack action output
+ improve the showing of both memory usages in various output messages
+ append backpack contents to server log if disconnecting client was idling
+ show fps in output messages when changing it
+ restore/set cred backup once in install/uninstall instead of on each login
+ check item schema for either client or server and print hash
+ improve cloud conflict check and show version and item schema in load
+ erase 'steamcmd/userdata' directory when done checking/updating the server
+ print player count to server log as it changes in idle plugin
+ change dedicated idle server map from itemtest to cp_cloak
+ wait until the server has recieved the item schema
+ show memory usage on low-client restart, ip on server query
+ show the location map or 'spawning' when using the idle server on connect
+ allow farm to run even if there is a noshaderapi client already running
+ show server player count, process usage, network info, and backend in status
+ show profile names and improve output and hardware descriptions in status
+ log output and only execute urls if steam is running in utility
+ show dependancy in error output message and add bash and bc to the check
+ change action concatenation char '+' to '@' avoiding account index conflict
+ use the pciids project instead of pcidatabase.com for hardware detection
+ change account block char '@' to ':' avoiding conflict with old usernames
+ allow account target negations with the'-' suffix to usernames or indexes
+ fail if an invalid action is specified and improve main loop
+ stop server if no clients are connected instead of checking for hl2 procs
+ slow mic ping alias from 6000 to 16000 frames
+ incorporate full readme and adjust usage output
[version 0.69]
+ fix grep errors when an adjacent file exists containing all numbers
+ wait until steam registers the application as halted before finishing stop
+ allow optional parameters in steam pid checks and startup
+ improve wine program launch
+ hide registry settings file
+ prep manifest, guard code, and client files on each login instead of install
+ only use '-condebug' startup parameter on the server
+ exit if pdl-idler.cfg is not found when prepping client files on login
+ hide login window after successful entry
+ don't supply mat_texture_limit on the command line for farm clients
+ show server memory usage in relevant output messages
+ have list cache tf2b for 4 minutes and only show 1 'v' in version info
+ fail in list if the prefix was not installed
+ implement backpack action that details backpack contents
+ implement status action that reports system, process, and account info
+ implement utility action that runs shell commands/steam urls for an account
+ implement sleep action that waits for a time or until enter is thrice pushed
+ only set client directory variable once
+ use array for targeting accounts by indexes as defined in pdl-idler.conf
+ check for uninstalled prefixes when no accounts are specified on invocation
+ don't uncapitalize action paremeters
+ fix gnome/xfce-session process checks
+ set 'sv_pure' cvar to -1
[version 0.68]
+ use /bin/bash instead of /bin/sh as the shell bang
+ improve client disconnect
+ show prefix disk size on uninstall
+ align windows for the chatroom and talks with the private inbreastigator
+ improve version parsing
+ track installed versions per client for ui upgrades
+ rename 'backpack' action to 'website' and add 'willitcraft' parameter
+ (re)move chat window on arrival
+ add item+crate count and steam connection hash to account list
+ fix ui version in account listing due to new package system
+ remove cloud and launch flags and shorten main status flag in account list
+ print error on client command failure
+ allow account group specification
[version 0.67]
+ suffix account read wait/pid marker config files with a '+'
+ allow chat if there is any app license (instead of just tf2)
+ only validate srcds content after initial install
################################################################################
[??????? 0.66]
+
C REVERT BAD ASS WRITEIP AND yeah....
+ remove paragraph on gcf files in readme
[VERSION 0.65] right-hand-opputs, steampipe server
[VERSION 0.64] create
################################################################################
[version 0.63]
+ use addip/writeip and the 'banned_ip.cfg' file for client command execution
+ run mmute client command alias before disconnecting
+ simplify client command read alias fps changing
+ bump prefix version to 2 and use hidden marker file
+ explicilty create/update prefix with regedit instead of launcher in install
+ remove 'user token' and 'currentversion/run' registry settings
+ set default dimensions of trade window to 648x445 and place it top-right
+ add low priority/resource steam mode that negates chrome and explorer.exe
+ set default client resolution to 640x480
+ fix syntax error when no parameter is supplied to enter
+ check for the steam id instead of just the wineprefix in backpack
+ fix sourcemod.cfg typo when blanking its contents
+ login steam in low-resource mode if it wasn't already active in farm
+ negate commedit, datamodel, pet, and vmt dlls from being loaded
+ remove 'props_break_max_pieces' and 'sensitivity' client cvars
[VERSION 0.62] singularregedit, farm, join/spec
+ slow the 30 fps client command read alias to to 60 fps
+ check gcf files once on invocation instead of each login
+ bump prefix to version 1
+ PREPPAGE
[version 0.61]
+ reorder function definitions
[version 0.60]
+ correct shell bang typo
+ fix atom window id check
+ don't reference the script location directory when unnccessary
+ rely on the display variable or default ":0.0" for the X server display id
+ start x11vnc if installed when the script has to start the X server
+ improve video driver module check and use account-named registry files
+ initiate jumplist ui settings to 0 and adjust it from 1545 to 521 on login
+ implement exit action to leave the chat instead of using enter as a toggle
+ upgrade to sourcemod 1.4.7
+ delete data extracts and gcf links after each account instead of after all
################################################################################
[??????? 0.59] Leave thisOne still the middle of second run through
+ don't require pdl-idler.conf
+ reinclude micspam client alias
! ECHO DISCONNECT drawviewmodel, VOLUME 0
? include close window function
+ CREDS/GUARD
+ PREFIX
+ CONFIG PREPS
+ CAUSE NO MANUAL OVERLAY DISABLE NEEDED
+ NEWLY DOING THE SSA STUFF?
+ WINESERVER WAIT ON LOGIN?????
+ CLOUD/UPDATE REGS
+ HANDLE THEM NEW UI INSTALLS AND BOOTSTRAPS
+ MONTIOR LOGIN MORE THROUGHLY
+ WAIT ON SSA, DO AVOID DEFAULT ONLINE, RESTART FOR OCNFIG^
+ F2P1
+ CHAT LOGS THEM IN NOW/LAME TOGGLE
+ LOAD MEGA MONITORING + DISABLEING PM RIGHT AT THE MOMEMNT?
+ SERPERATE CONNECTION FROM START ++ DISONECT + ISCONNECTED
+ IDLER_COMMAND
+ NO MORE PING?
+ IDLEER_BACKPACK (WEBSITE TYPE)
+ IDLER_LIST
+ IDLER_KILL
+ MORE DLLS AND THEM WINE PROCS
+ GET SOME ACCTS IF NONE SPECIFIED FROM EXISINTG
+ ACTION PARAMETERS
+ RELOGIN/RESTARTS?
+ add uninstall action
+ share steam ui download packages
################################################################################
[version 0.58]
+ store server console logs
+ include view action to cycle through screen sessions
[version 0.57]
+ set and use client startup options in steam config instead of on invocation
+ use exec file to set client command read alias polling frequency on startup
+ remove client binds and trade spam and micspam aliases
[version 0.56]
+ include window check functions and revert xdotool dependency
+ prompt for new install and prep data/config links before steam pid check
+ silence all file downloads and stop if the pci/hldsupdatetool downloads fail
+ revert chat auto login hibernate and multiple windows
+ slow offline/online/enter/command wait sleeps from 0.1 to 0.25
+ start gui clients at 30 fps and textmode clients at 1 fps
+ capture server bootstrap updating in screen
+ integrate server plugin code into the script
+ use sv_cheats and run server at 10 fps
+ deduce correct network device and ip address of server for client connection
+ have connecting client send message, and say 'stop' not 'quit' on disconnect
[version 0.55]
+ start clients at 10 fps with sv_cheats 1
+ call regedit before each steam launch instead of just once per login attempt
[version 0.54]
+ adjust jumplist steam ui setting flag from 1705 to 1545
+ require xdotool and use it to check for windows
+ add variable for having accounts join and and hibernate in chat on login
+ ensure if the account has premium tf2 before joining chat
+ make chat action hide/show the window with xdotool
+ have account friend chats open in a seperate window
+ wait for the main window with xdotool to finish login instead of appinfo_log
+ remove superfluous tf/maps mkdir call
+ wait for window to ask for password instead of assuming via SteamAppData.vdf
+ wait until the account has finished changing friends state
+ quicken client command-read poll from 120 to 60 frames
+ hide x pid file
+ download steam launcher and pci id file on install instead of on invocation
+ don't print output message if not joining a game and are only connecting
+ upgrade to sourcemod 1.4.2
+ use screen for the server content updating
+ ensure the hlds/steam cache directory link isn't the idler's before failing
+ include general client command function 'cmd'
+ add timestamp to disconnect announcement performed now as a call to cmd
+ remove client quit alias and just write 'quit' to readcmd.cfg
+ don't use any extra fonts
[version 0.53]
+ use the launcher install to create the prefix instead of regedit
+ delete registry key for startup applications
+ include chat action for joining a public chatroom
+ remove prediction of high cpu consumption/crash in readme for first login
[version 0.52]
+ download, install, start, connect to, and stop a dedicated idle server
+ include sourcemod plugin for server that parks clients in the spawning phase
+ don't download or use achievement_idle map and rely on itemtest
+ remove client movement alias file/binds
+ rename 'pdl-idler_autoexec.cfg' to 'pdl-idler.cfg'
+ use port 27016 as the start of the client listen port range
[version 0.51]
+ don't use cpulimit
[version 0.50]
+ monitor client console via the screen instead of polling the log file
+ always suppress winedebug output
+ fix X process check
[version 0.49]
+ print output messages with a timestamp
+ mark when the X server starts instead of relying on user variable
+ don't login when going online
+ check server even if it was down for each client connecting in an invocation
+ suppress power manager restart output
+ improve client trade-spam aliases
+ hide servers from master list
+ disable mp_timeout
[version 0.48]
+ add ping action that instructs clients to message the server
+ quicken client command-read poll from 240 to 120 frames
+ use one main loop for each specified account
[version 0.47]
+ change client resolution from 640x480 to 800x600
+ set client timeout cvar to 0
[version 0.46]
+ have clients print console output to logfile
+ create separate screen session that polls the client console log
+ wait until client joins the game after connecting
[version 0.45]
+ don't set windows mode to win98 and rely on default
+ hide client achievement hud element
+ mute voice chat on client startup
[version 0.44]
+ include binds and cfg file containing client movement aliases
+ append marker command line parameter to client startup
+ fix cpulimit removals
+ add trade spam client aliases
+ bind mouse5 to 'inspect' in the client
+ hide maxplayer/blacklist/favorites warnings in client
+ show item quality outlines in client
+ increase volume amounts in relevant client binds
+ use mat_disable_d3d9ex cvar and fix mat_envmaptgasize typo
+ change mat_picmip from 4 to 2
+ remove avglight, drawdecals, and drawviewmodel render cvar changes
+ move net_graph cvar to autoexec instead of the command line
[VERSION 0.43]
+ initial drop to git hub
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The GNU General Public License is a free, copyleft license for
software and other kinds of works.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
the GNU General Public License is intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users. We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors. You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
To protect your rights, we need to prevent others from denying you
these rights or asking you to surrender the rights. Therefore, you have
certain responsibilities if you distribute copies of the software, or if
you modify it: responsibilities to respect the freedom of others.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received. You must make sure that they, too, receive
or can get the source code. And you must show them these terms so they
know their rights.
Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.
For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software. For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.
Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so. This is fundamentally incompatible with the aim of
protecting users' freedom to change the software. The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable. Therefore, we
have designed this version of the GPL to prohibit the practice for those
products. If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.
Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
avoid the special danger that patents applied to a free program could
make it effectively proprietary. To prevent this, the GPL assures that
patents cannot be used to render the program non-free.
The precise terms and conditions for copying, distribution and
modification follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based
on the Program.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source
form of a work.
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
The Corresponding Source for a work in source code form is that
same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or
e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
13. Use with the GNU Affero General Public License.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:
<program> Copyright (C) <year> <name of author>
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, your program's commands
might be different; for a GUI interface, you would use an "about box".
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
<http://www.gnu.org/licenses/>.
The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
<http://www.gnu.org/philosophy/why-not-lgpl.html>.
#!/bin/bash
# pdl-idler.sh (0.77)
# Copyright (c) 2011-2013 byteframe@primarydataloop
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>
DIR="$( cd "$( dirname "$0" )" && pwd )"
if [ -L "${DIR}" ]; then
DIR=$(readlink "${DIR}")
fi
cd "${DIR}"
# force bash shell to run this script
if [ $(readlink "/proc/$$/exe" | sed "s/.*\///") != bash ]; then
echo "[$(date +%H:%M:%S)] warning, only bash is supported as the shell {*}"
exec bash pdl-idler.sh $*
fi
function print()
{
# output with an optional right-aligned argument and padding
unset PAD RIGHT
if [ ! -z "${2}" ]; then
RIGHT="${2}"
if [ ! -z ${3} ]; then
WIDTH=${3}
else
WIDTH=$(expr length "${2}")
fi
let $((PAD=$(tput cols)-$(expr length "${1}")-${WIDTH}-1))
fi
printf "${1}%${PAD}s${RIGHT:0:$((WIDTH))}\n"
}
function tprint()
{
# print with a timestamp
if [ ! -z "${2}" ]; then
RIGHT="|${2}"
else
unset RIGHT
fi
print "[$(date +%H:%M:%S)] ${1}" "${RIGHT}" ${3}
}
# make sure the present working directory is writeable
if [ ! -w . ]; then
tprint "fatal, pwd is unwriteable {"'!}' $(pwd)
exit 1
fi
# do not allow root to run this script
if [ $(whoami) = root ]; then
tprint "fatal: cannot be run as root {"'!}'
exit 1
fi
# check dependencies
if ! lsmod | grep -q "^nvidia \|^fglrx "; then
XVFB=Xvfb
fi
for DEP in bash bc nc screen sudo wget xdotool ${XVFB}; do
if ! which ${DEP} > /dev/null 2>&1; then
tprint "fatal, missing dependency '${DEP}' {"'!}'
exit 1
fi
done
if [[ $(wine --version 2> /dev/null) != wine-1.[5-9]* ]]; then
tprint "fatal, wine is not installed or is too old {"'!}'
exit 1
fi
function download()
{
# download a file
unset TARGET
if [ ! -z "${2}" ]; then
if [ -d "${2}" ]; then
TARGET="${2}/${1##*/}"
else
TARGET="${2}"
fi
else
TARGET="${1##*/}"
fi
if ! wget -q ${1} -O "${TARGET}"; then
rm -f "${TARGET}"
exit 1
fi
}
# check for script updates
mkdir -p .gist
if [ -z $(find .gist -maxdepth 1 -name pdl-idler.sh -mmin -240) ]; then
if download gist.github.com/primarydataloop/1432762/download \
.gist.tar.gz; then
tar -xzf .gist.tar.gz -C .gist --strip=1
touch .gist/pdl-idler.sh
rm .gist.tar.gz
OLD=$(cat pdl-idler.sh | grep -m 1 -o \(.* | grep -o "[0-9]*\.[0-9]*")
NEW=$(cat .gist/pdl-idler.sh | grep -m 1 -o \(.* | grep -o "[0-9]*\.[0-9]*")
if [ ${OLD} != ${NEW} ]; then
printf "[$(date +%H:%M:%S)] enter y to upgrade to version ${NEW}: "
read -t 20 INPUT || echo
if [ "${INPUT}" = y ]; then
cp .gist/* .
chmod +x pdl-idler.sh
tprint "upgraded pdl-idler" "${OLD}>${NEW}"
exec bash pdl-idler.sh $*
else
tprint "warning, update skipped {*}" "${OLD}>${NEW}"
fi
fi
else
tprint "warning, can't check version on github (*)"
fi
fi
function steam_uid()
{
# get steam user id from config.vdf or cred backup
GET=${ACCT}
if [ ! -z ${1} ]; then
GET=${1}
fi
CONFIGVDF="${DIR}"/wine-${GET}/drive_c/Program\ Files/Steam/config/config.vdf
CREDFILE="${DIR}"/cred/cred-${GET}_
if ! grep SteamID "${CONFIGVDF}" 2> /dev/null | grep -o \[0-9]* \
&& ! grep SteamID "${CREDFILE}"* 2> /dev/null | grep -o \[0-9]* ; then
echo 765611-----------
return 1
fi
}
function steam_connect_hash()
{
# get last 6 characters of the current or backup connection cache
local FILE="${STEAM}"/config/config.vdf
if [ ! -z ${1} ]; then
FILE=cred/cred-${ACCT}_$(basename "${STEAM}"/userdata/*)
fi
local HASH=$(cat "${FILE}" 2> /dev/null | tr -d '[:blank:]' \
| tr -d '\n'| grep -o \"ConnectCache\"{\"[a-f0-9]*\"\"[a-f0-9]* | tail -c7)
if [ -z ${HASH} ]; then
HASH=------
fi
echo \#${HASH}
}
function version()
{
# parse version string
if [ ! -z ${1} ]; then
echo v${1}
else
echo none
return 1
fi
}
function steam_ui_version()
{
# get steam ui version of the installed prefix
version $(cat "${WINEPREFIX}"/.ui.pdl 2> /dev/null | sed -e "s/^v//")
}
function steam_ui_web_version()
{
# get steam ui version from manifest file on valve cdn
version $(wget -qO- http://media.steampowered.com/client/steam_client_win32 \
| grep version | grep -o \[0-9]*)
}
function steam_pid()
{
# get pid of steam process with an optional command line string
pgrep -fn "wine-${ACCT}/.*steam\.exe.*${1}"
}
function hl2_pid()
{
# get pid of hl2 process with an optional command line string
pgrep -f "hl2\.exe.*${1}.*${ACCT//./}\+"
}
function dcat()
{
# read a file forwards or backwards negating dos newlines
if [ ! -z ${2} ]; then
tac "${1}" | sed 's/\r$//'
else
cat "${1}" | sed 's/\r$//'
fi
}
function client_map()
{
# get map load status of client
if hl2_pid > /dev/null && dcat "${CON}" y \
| grep -m 1 ": Disconnect\|: Compact freed" | grep -q Compact; then
echo $(dcat "${CON}" y | grep -m 1 ^Map: | grep -o \ .*)
return 0
fi
return 1
}
function client_connection()
{
# get connection time and status of client
if hl2_pid > /dev/null; then
TIME=$(($(date +%s)-$(date -d "$(dcat "${CON}" y \
| grep -m 1 ': Disconnect\|: Connected to\|: Compact freed' \
| sed -e 's/: .*//' -e 's/ - / /')" +%s)))
TIME=$(echo - | awk \
'{printf "%02d:%02d",'${TIME}'/(60*60),'${TIME}'%(60*60)/60}')\|
if dcat "${CON}" y | grep -m 1 ": Disconnect\|: Connected to\| connected" \
| grep -q Disconnect; then
echo ${TIME} Disconnect
return 1
fi
IP=$(dcat "${CON}" y | grep -m 1 ": Disconnect\|: Connected to" \
| grep -o Connected\ to.* | grep -o \[0-9.:]*)
if [ -z ${IP} ]; then
IP=Listen
fi
echo ${TIME} ${IP}
fi
}
function window_id()
{
# get id of a named window
SPID=$(steam_pid)
if [ ! -z ${SPID} ]; then
for ID in $(xwininfo -all -root -children 2> /dev/null \
| grep "${1}.*: (\"steam\.exe" | awk '{print $1}'); do
PID=$(xprop -id ${ID} 2> /dev/null | grep PID | awk '{print $3}')
if [ "${PID}" = ${SPID} ]; then
if [ "${2}" = atom ] \
&& ! xprop -id ${ID} 2> /dev/null | grep -q "_WM_STATE(ATOM)"; then
continue
elif [ "${2}" = opacity ] \
&& xprop -id ${ID} 2> /dev/null | grep -q "_OPACITY"; then
continue
elif [ "${2}" = viewable ] \
&& ! xwininfo -id ${ID} 2> /dev/null | grep -q "IsViewable"; then
continue
fi
echo ${ID}
return 0
fi
done
fi
return 1
}
function idler_list()
{
# print listing with item counts, steamid, connect hash, versions, and status
unset LINE ITEM
if steam_uid > /dev/null; then
if [ ! -e cred/.tf2b-${ACCT} ] || [ "${1}" != no ]; then
WGET=$(find -L cred -maxdepth 1 -name .tf2b-${ACCT} -mmin -5)
if [ "${1}" = yes ] || [ -z ${WGET} ]; then
cd /
download tf2b.com/tf2/txt/$(steam_uid) "${DIR}"/cred/.tf2b-${ACCT}
download steamcommunity.com/profiles/$(steam_uid) \
"${DIR}"/cred/.profile-${ACCT}
cd "${DIR}"
fi
fi
WGET=$(cat cred/.tf2b-${ACCT} | grep -o \<body\>.*)
if echo ${WGET} | grep -q Something\ broke; then
LINE='!'\|?
unset WGET
rm -f cred/.tf2b-${ACCT}
elif echo ${WGET} | grep -q backpack\ is\ private; then
LINE=?\|?
else
ITEM=$(echo ${WGET} | grep -o [0-9][0-9]*/[0-9][0-9]* | sed "s/\/.*//")
if [ ! -z ${ITEM} ]; then
if echo ${WGET} | grep -q Tux; then
let ITEM=ITEM-1
fi
MANN=$(echo ${WGET} | grep -o ">Mann Co. Supply Crate</td><td>[0-9]*" \
| grep -o \[0-9]*)
ROBO=$(echo ${WGET} | grep -o ">RoboCrate</td><td>[0-9]*" \
| grep -o \[0-9]*)
CLAIM=$(echo ${WGET} | grep -o ">Summer Claim Check</td><td>[0-9]*" \
| grep -o \[0-9]*)
SAC=$(echo ${WGET} | grep -o ">Summer Appetizer Crate</td><td>[0-9]*" \
| grep -o \[0-9]*)
let ITEM=ITEM-MANN-ROBO-CLAIM-SAC
CRATES=_
if [ ! -z ${MANN} ]; then
CRATES=${MANN}
fi
if [ ! -z ${ROBO} ]; then
CRATES=${CRATES}+${ROBO}
fi
if [ ! -z ${CLAIM} ]; then
if [ -z ${ROBO} ]; then
CRATES=${CRATES}+0
fi
CRATES=${CRATES}+${CLAIM}
fi
if [ ! -z ${SAC} ]; then
if [ -z ${CLAIM} ]; then
if [ -z ${ROBO} ]; then
CRATES=${CRATES}+0
fi
CRATES=${CRATES}+0
fi
CRATES=${CRATES}+${SAC}
fi
if [ ${ITEM} = 0 ]; then
ITEM=_
fi
LINE="${ITEM}|${CRATES}"
else
LINE=_\|_
fi
fi
fi
LINE="${LINE} @$(steam_uid)"
LINE="${LINE} [$(steam_connect_hash)]"
if ! steam_uid > /dev/null; then
LINE="${LINE} not_initiated |"
elif ! steam_ui_version > /dev/null; then
LINE="${LINE} not_installed |"
else
if [ -z ${UI_WEB} ]; then
UI_WEB=$(steam_ui_web_version)
fi
if [ $(steam_ui_version) != ${UI_WEB} ]; then
LINE="${LINE} <$(steam_ui_version | sed s/v//g)"
else
LINE="${LINE} ^$(steam_ui_version | sed s/v//g)"
fi
LINE="${LINE}p$(cat "${WINEPREFIX}"/.prefix.pdl) |"
fi
if ! steam_pid > /dev/null; then
LINE="${LINE}--"
else
if client_map > /dev/null; then
LINE="${LINE}G"
elif client_connection > /dev/null; then
LINE="${LINE}C"
elif hl2_pid > /dev/null; then
LINE="${LINE}S"
else
LINE="${LINE}A"
fi
if window_id Group\ Chat opacity > /dev/null; then
LINE="${LINE}C"
elif ! grep -q "\"PersonaStateDesired\".*\"0\"" \
"${STEAM}"/userdata/*/config/localconfig.vdf; then
LINE="${LINE}O"
else
LINE="${LINE}-"
fi
fi
print ${ACCT} "${LINE}"
}
function steam_mem()
{
# get memory usage of steam process
echo $(($(grep RSS /proc/$(steam_pid)/status | grep -o \[0-9]*) / 1024))mb
}
function hl2_mem()
{
# get memory usage of hl2 process
echo $(($(grep RSS /proc/$(hl2_pid)/status | grep -o \[0-9]*) / 1024))mb
}
function both_mem()
{
# get memory usage of steam and hl2
STM=$(steam_mem)
if hl2_pid > /dev/null; then
STM=$(steam_mem | sed "s/mb//")
HL2=/$(hl2_mem)
else
unset HL2
fi
echo ${STM}${HL2}
}
function pause()
{
# wait for a specified period with a blocking read call
PAUSE=1
if [ ! -z ${1} ]; then
PAUSE=${1}
fi
read -d \\ -s -t ${PAUSE}
return 0
}
function cmd()
{
# run a client console command
TIME=$(date +%s)${RANDOM}
echo -e "alias cmnd \"alias cmnd;${1};echo b${TIME}\"\necho a${TIME}" \
> "${TF}"/cfg/cmd-${ACCT//./}.cfg
TIMEOUT=0
while ! dcat "${CON}" y | grep -q a${TIME}; do
pause 0.1
let TIMEOUT+=1
if [ ${TIMEOUT} = 300 ]; then
tprint "${ACCT}: error, command failed {"'!}' $(both_mem)
return 1
fi
done
echo cmnd > "${TF}"/cfg/cmd-${ACCT//./}.cfg
while ! dcat "${CON}" y | grep -q b${TIME}; do
pause 0.1
done
return 0
}
function idler_backpack()
{
# list then detail backpack contents
idler_list ${1} || return 1
if [ ! -z ${ITEM} ]; then
for WORD in $(echo ${WGET} | sed -e "s/ /_/g" -e 's/<[^>]*>/ /g'); do
if [ ${WORD} != \# ] && [ ${WORD} != " " ]; then
if echo ${WORD} | grep -qi items; then
if [[ ${WORD} = Genuine_* ]]; then
TYPE=H.
elif [[ ${WORD} = Strange_* ]]; then
TYPE=S.
elif [[ ${WORD} = Vintage_* ]]; then
TYPE=V.
elif [[ ${WORD} = Unusual_* ]]; then
TYPE=U.
else
unset TYPE
fi
elif [[ ${WORD} = [0-9]* ]]; then
print "" "${TYPE}${NAME} (x${WORD})" 46
elif [[ ${WORD} = *[a-zA-Z]* ]]; then
NAME=$(echo ${WORD} | sed "s/_/ /g")
fi
fi
done
print "" {$(echo ${WGET} | grep -o [0-9][0-9]*/[0-9][0-9]*)} 46
elif [ -z "${WGET}" ]; then
print "" "{website error}" 46
else
print "" "{backpack empty}" 46
fi
}
function change_client_fps()
{
# change client fps
tprint "${ACCT}: changing fps..." ${1}fps,$(both_mem)
{
echo "alias _acmd"$(dcat "${CON}" y | grep -om 1 :\ fps.* | grep -o \[0-9]*)
echo "alias _acmd${1} \"exec cmd-${ACCT//./};wait $((${1}*4));_acmd${1}\""
echo "fps_max ${1}"
echo "_acmd${1}"
echo "echo fps${1}"
} > "${TF}"/cfg/fps-${ACCT//./}.cfg
cmd "exec fps-${ACCT//./}"
}
function idler_disconnect()
{
if hl2_pid > /dev/null; then
# disconnect client from server
if client_connection > /dev/null; then
tprint "${ACCT}: disconnecting..." \
$(client_connection | cut -c1-5),$(both_mem)
cmd "mmute;disconnect" || return 1
cmd "echo Disconnect"
# if client was on the idle server, write backpack contents to server log
if ! client_map > /dev/null; then
idler_backpack yes >> ${SCON}
fi
fi
# raise fps if needed and if not reconnecting
if dcat "${CON}" y | grep -m 1 :\ fps | grep -q fps1 \
&& ! hl2_pid noshaderapi > /dev/null && [ -z ${1} ]; then
change_client_fps 30
fi
fi
}
function idler_stop()
{
if hl2_pid > /dev/null; then
# disconnect and/or quit or kill client process
if [ "${1}" = yes ]; then
TIMEOUT=121
tprint "${ACCT}: killing client..." @$(hl2_pid),$(both_mem)
else
TIMEOUT=120
if idler_disconnect; then
tprint "${ACCT}: quitting client..." @$(hl2_pid),$(both_mem)
if cmd quit; then
TIMEOUT=0
fi
fi
fi
while hl2_pid > /dev/null; do
pause
if [ ${TIMEOUT} = 120 ]; then
tprint "${ACCT}: warning, killing client... {*}" $(both_mem)
elif [ ${TIMEOUT} = 121 ]; then
kill -9 $(hl2_pid)
fi
let TIMEOUT+=1
done
# wait until steam registers application as stopped
while dcat "${STEAM}"/logs/content_log.txt y | grep -m 1 Installed, \
| grep -q Running; do
pause
done
fi
}
function wine_run()
{
# execute a program with wine and surpress the call output
wine "$@" > /dev/null 2>&1
}
function backup_credentials()
{
# update credential backup
if [ -e "${STEAM}"/config/config.vdf ] \
&& [ $(steam_connect_hash) != $(steam_connect_hash y) ]; then
{
cat "${STEAM}"/config/config.vdf | tr -d '[:blank:]' | tr -d '\n' \
| grep -o \"MTBF\"\"[0-9]*\"
cat "${STEAM}"/config/config.vdf | tr -d '[:blank:]' | tr -d '\n' \
| grep -o \"ConnectCache\"{\"[a-f0-9]*\"\"[a-f0-9]*\"}
cat "${STEAM}"/config/config.vdf | grep SteamID
} > cred/cred-${ACCT}_$(basename "${STEAM}"/userdata/*)
fi
}
function idler_logout()
{
# stop, logout account or kill steam process, then backup credentials
if steam_pid > /dev/null; then
idler_stop ${1}
if [ "${1}" = yes ]; then
TIMEOUT=121
tprint "${ACCT}: killing steam..." @$(steam_pid),$(steam_mem)
else
TIMEOUT=0
tprint "${ACCT}: logging out..." @$(steam_pid),$(steam_mem)
wine_run "${STEAM}"/steam.exe -shutdown
fi
while steam_pid > /dev/null; do
pause
if [ ${TIMEOUT} = 120 ]; then
tprint "${ACCT}: warning, killing steam... {*}" $(steam_mem)
elif [ ${TIMEOUT} = 121 ]; then
kill -9 $(steam_pid)
fi
let TIMEOUT+=1
done
backup_credentials
rm -f cred/.host-${ACCT}
fi
}
function prefix_size()
{
# get size on disk of the wineprefix
echo $(du -ch "${WINEPREFIX}" | grep total | awk '{print $1}')
}
function idler_uninstall()
{
# logout, backup credentials, then remove client config files and wineprefix
if [ -d "${WINEPREFIX}" ]; then
idler_logout ${1}
chmod -R 755 "${STEAM}"/userdata/ 2> /dev/null
tprint "${ACCT}: uninstalling..." \
p$(cat "${WINEPREFIX}"/.prefix.pdl),$(prefix_size)
wineserver -w
rm -fr "${WINEPREFIX}"
fi
rm -rf "${TF}"/con-${ACCT}.log "${TF}"/cfg/*-${ACCT//./}.cfg \
"${TF}"/cfg/${ACCT//./}+.cfg
}
function idler_delete()
{
# logout, uninstall, then remove credential backup
idler_logout ${1}
if [ -d "${WINEPREFIX}" ]; then
tprint "${ACCT}: deleting..." \
p$(cat "${WINEPREFIX}"/.prefix.pdl),$(prefix_size)
elif [ -e cred/ssfn-${ACCT} ]; then
tprint "${ACCT}: deleting..."
fi
idler_uninstall > /dev/null
rm -f cred/cred-${ACCT}_* cred/ssfn-${ACCT} cred/.profile-${ACCT} \
cred/.tf2b-${ACCT}
}
function xserver_pid()
{
# get pid of an X server process by its display id
pgrep -fn X\ .*${1/.*}\|Xvfb\ .*${1/.*}
}
function start_xserver()
{
# start regular X server or seperate farm X/Xvfb server with optional x11vnc
if ! xserver_pid ${DISPLAY/.*} > /dev/null; then
TYPE=${DISPLAY}
if [ ${DISPLAY} != ${X_DISPLAY} ]; then
TYPE=farm,${TYPE}
fi
local VER=v$(Xorg -version 2>&1 >/dev/null | grep Server | awk '{print $4}')
if [[ ${TYPE} = farm* ]] && [ ! -z ${XVFB} ]; then
tprint "starting Xvfb..." ${TYPE},${VER}
SERVER=Xvfb
screen -dmS idler-X${DISPLAY:1:1}$ \
Xvfb ${DISPLAY/.*} -screen 0 800x600x24
else
tprint "starting X..." ${TYPE},${VER}
SERVER=X
screen -dmS idler-X${DISPLAY:1:1}$ \
xinit -geometry =40x40+9999+0 -- ${DISPLAY/.*}
fi
while ! xserver_pid ${DISPLAY/.*} > /dev/null; do
pause
done
xserver_pid ${DISPLAY/.*} > x${DISPLAY:1:1}.pid
if [[ ${TYPE} != farm* ]] || [ ${SERVER} = Xvfb ]; then
if [ "${X_X11VNC}" != no ]; then
if which x11vnc > /dev/null 2>&1; then
tprint "starting x11vnc..." v$(x11vnc -V | awk '{print $2}')
screen -dmS idler-x11vnc${DISPLAY:1:1}$ \
x11vnc -display ${DISPLAY/.*} -forever -noxdamage
else
tprint "warning, x11vnc is not installed (*)"
fi
fi
fi
fi
}
function wine_version()
{
# get wine version
VER=$(wine --version | sed s/wine-//)
version ${VER%-*}
}
function steam_cid()
{
# get steam community id from the userdata directory or cred backup
GET=${ACCT}
if [ ! -z ${1} ]; then
GET=${1}
fi
USERDATA="${DIR}"/wine-${GET}/drive_c/Program\ Files/Steam/userdata
CREDFILE="${DIR}"/cred/cred-${GET}_
if [ -d "${USERDATA}" ]; then
ls "${USERDATA}" | sed "s/\///"
elif [ -e "${CREDFILE}"* ]; then
basename "${CREDFILE}"* | grep -o \[0-9]*$
else
echo --------
return 1
fi
}
function idler_install()
{
if ! steam_pid > /dev/null; then
# uninstall when the prefix needs rebuilding or was moved
PREFIX=5
if [ -d "${WINEPREFIX}" ]; then
OLD=$(cat "${WINEPREFIX}"/.prefix.pdl 2> /dev/null)
if [ ${OLD} != ${PREFIX} ]; then
tprint "${ACCT}: uninstalling for prefix rebuild..." p${OLD}\>p${PREFIX}
idler_uninstall > /dev/null
else
local LOCATION=$(cat "${WINEPREFIX}"/.location.pdl)
if [ "${WINEPREFIX}" != "${LOCATION}" ]; then
tprint "${ACCT}: warning, uninstalling for prefix move... {*}" \
${PREFIX}
idler_uninstall > /dev/null
fi
fi
fi
# start x server then prep wineprefix with registry settings application
start_xserver
TIME=$(cat "${WINEPREFIX}"/.timestamp.pdl 2> /dev/null || echo 0)
if [ ${TIME} = 0 ]; then
tprint "${ACCT}: creating wineprefix..." p${PREFIX},$(wine_version)
elif (( $(date +%s)-3 > ${TIME} )); then
tprint "${ACCT}: prepping wineprefix..." p${PREFIX},$(wine_version)
fi
{
echo -e "REGEDIT4\n"
echo "[HKEY_CURRENT_USER\Software\Valve\Source\tf\Settings]"
echo "\"AutoConfigVersion\"=dword:00000001"
echo "\"DeviceID\"=dword:0000${DEV}"
echo "\"DXLevel_V1\"=dword:00000050"
echo "\"mat_aaquality\"=dword:00000000"
echo "\"mat_antialias\"=dword:00000000"
echo "\"mat_bumpmap\"=dword:00000000"
echo "\"mat_colorcorrection\"=dword:00000000"
echo "\"mat_forceaniso\"=dword:00000000"
echo "\"mat_forcehardwaresync\"=dword:00000000"
echo "\"mat_hdr_level\"=dword:00000000"
echo "\"mat_parallaxmap\"=dword:00000000"
echo "\"mat_picmip\"=dword:00000002"
echo "\"mat_reducefillrate\"=dword:00000001"
echo "\"mat_specular\"=dword:00000000"
echo "\"mat_trilinear\"=dword:00000000"
echo "\"mat_vsync\"=dword:00000000"
echo "\"MotionBlur\"=dword:00000000"
echo "\"r_rootlod\"=dword:00000002"
echo "\"r_shadowrendertotexture\"=dword:00000000"
echo "\"r_waterforceexpensive\"=dword:00000000"
echo "\"r_waterforcereflectentities\"=dword:00000000"
echo "\"ScreenHeight\"=dword:00000258"
echo "\"ScreenMonitorGamma\"=\"2.2\""
echo "\"ScreenMSAA\"=dword:00000000"
echo "\"ScreenMSAAQuality\"=dword:00000000"
echo "\"ScreenWidth\"=dword:00000320"
echo "\"ScreenWindowed\"=dword:00000001"
echo "\"ShadowDepthTexture\"=dword:00000000"
echo "\"VendorID\"=dword:0000${VENDOR}"
echo "[HKEY_CURRENT_USER\Software\Valve\Steam]"
echo "\"AlreadyRetriedOfflineMode\"=dword:00000001"
echo "\"Offline\"=dword:00000000"
echo "[HKEY_CURRENT_USER\Software\Valve\Steam\Apps\440]"
echo "\"EnableCacheLoading\"=dword:00000000"
echo "\"Cloud\"=dword:00000000"
echo "[HKEY_CURRENT_USER\Software\Wine\AppDefaults\hl2.exe\DllOverrides]"
echo "\"libcef\"=\"\""
echo "\"icudt\"=\"\""
echo "\"chromehtml\"=\"\""
echo "[HKEY_CURRENT_USER\Software\Wine\Direct3D]"
echo "\"UseGLSL\"=\"disabled\""
echo "\"OffscreenRenderingMode\"=\"backbuffer\""
echo "\"Multisampling\"=\"disabled\""
echo "[HKEY_CURRENT_USER\Software\Wine\WineDbg]"
echo "\"ShowCrashDialog\"=dword:0000000"
} > regedit.reg
regedit regedit.reg > /dev/null 2>&1
# (re)make data directories
mkdir -p package "${TF}"/cfg
# install steam launcher
if [ ! -d "${STEAM}"/Public ]; then
echo ${PREFIX} > "${WINEPREFIX}"/.prefix.pdl
CRED=no
if [ -e cred/cred-${ACCT}_[0-9]* ]; then
CRED=ok
fi
tprint "${ACCT}: installing steam launcher..." ${CRED}_cred
if [ ! -e SteamInstall.msi ]; then
download http://cdn.steampowered.com/download/SteamInstall.msi
fi
WINEDLLOVERRIDES=${DLLS/,msi.dll}=d \
wine_run msiexec /qb /i SteamInstall.msi
date +%s > "${WINEPREFIX}"/.timestamp.pdl
echo "${WINEPREFIX}" > "${WINEPREFIX}"/.location.pdl
# make steam directories and data links
mkdir -p "${STEAM}"/config "${STEAM}"/logs "${STEAM}"/steamapps/common
ln -s "${DIR}"/package "${STEAM}"
ln -s "${DIR}"/Team\ Fortress\ 2 "${STEAM}"/steamapps/common
# prep configuration
{
echo -e "\"SteamAppData\"{\"RememberPassword\"\"1\""
echo -e "\"AutoLoginUser\"\"${ACCT}\"}"
} > "${STEAM}"/config/SteamAppData.vdf
{
echo "\"InstallConfigStore\"{\"Software\"{\"Valve\"{\"Steam\"{"
echo "\"SentryFile\"\"c:\\\\program files\\\\steam\\\\ssfn-${ACCT}\""
echo "\"Rate\"\"30000\"\"MTBF\"\"0\"\"ConnectCache\"{\"x\"\"y\"}"
echo "\"SurveyDate\"\"1-2-3\"}}}}"
} > "${STEAM}"/config/config.vdf
if [ -e cred/cred-${ACCT}_[0-9]* ]; then
mkdir -p "${STEAM}"/userdata/$(steam_cid)/config
echo "\"UserLocalConfigStore\"{\"friends\"{}}" \
> "${STEAM}"/userdata/$(steam_cid)/config/localconfig.vdf
fi
# set default dimensions of dialog windows
WIDTH=$(xdpyinfo | grep -o "dimensions:\ *[0-9]*x" | grep -o \[0-9]*)
{
echo "\"UserConfigData\"{\"Steam\"{\"cached\"{\"tradedialog.layout\"{"
echo "\"xpos\"\"9999\"\"ypos\"\"9999\"\"wide\"\"648\"\"tall\"\"445\"}}}"
echo "\"FriendsMainDialog\"{\"xpos\"\"$((WIDTH-1153))\"\"ypos\"\"0\""
echo "\"wide\"\"220\"\"tall\"\"259\"}\"SteamRootDialog\"{\"xpos\""
echo "\"$((WIDTH-1153))\"\"ypos\"\"0\"\"wide\"\"1153\"\"tall\"\"679\"}"
echo "\"resource\"{\"layout\"{\"gamespage_mini.layout\"{\"xpos\""
echo "\"$((WIDTH-933))\"\"ypos\"\"0\"\"wide\"\"285\"\"tall\"\"259\"}}}"
echo "\"friends\"{\"ChatRoomDlg.res_110338190873329012\"{\"xpos\""
echo "\"636\"\"ypos\"\"284\"\"wide\"\"636\"\"tall\"\"351\"}"
echo "\"ChatRoomDlgFriend.res_16471780\"{\"xpos\"\"876\"\"ypos\"\"284\""
echo "\"wide\"\"396\"\"tall\"\"351\"}}}"
} > "${STEAM}"/config/DialogConfig.vdf
fi
fi
}
function steam_ui_cache_version()
{
# get steam ui version from extracted cache or current download
MANIFEST=.manifest
if [ -e package/steam_client_win32 ]; then
unset MANIFEST
fi
version $(grep version package/steam_client_win32${MANIFEST} 2> /dev/null \
| grep -o \[0-9]*)
}
# set command line options common to client and server
COMMON_OPTS="-nobreakpad -nodev -nodns -nogamestats -nohltv -noipx -nomaster"
COMMON_OPTS="${COMMON_OPTS} -nominidumps"
function focus_window()
{
# activate or focus a window by its id
xdotool windowactivate --sync ${1} 2> /dev/null \
|| xdotool windowraise ${1} windowfocus --sync ${1} 2> /dev/null
}
function close_window()
{
# close a window by its name
WID=$(window_id "${1}")
while window_id "${1}" > /dev/null \
&& ! xprop -id ${WID} | grep -q Withdrawn; do
focus_window ${WID}
Y=$(($(xwininfo -id ${WID} | grep Height | grep -o [0-9]*)-8))
xdotool mousemove --window ${WID} 8 ${Y} click --repeat 2 --delay 250 1 \
key --window ${WID} Escape Alt+F4
for I in 1 2 3; do
pause 1.1
if ! window_id "${1}" > /dev/null \
|| xprop -id ${WID} | grep -q Withdrawn; then
break
fi
done
done
}
function is_authenticated()
{
# check if the current account has been authenticated with steam
dcat "${STEAM}"/logs/connection_log.txt | grep -q OnResponse.*U:.*OK
}
function steam_auth_server()
{
# get steam authentication server
dcat "${STEAM}"/logs/connection_log.txt y | grep Complete \
| grep -m1 -o "[0-9\.:]*, [A-Z]*"
}
function steam_version()
{
# get steam version
version $(basename "${STEAM}"/steam_*.mst | grep -o \[0-9]*)
}
function idler_offline()
{
# set friend presense to offline
if steam_pid > /dev/null && ! grep -q "\"PersonaStateDesired\".*\"0\"" \
"${STEAM}"/userdata/*/config/localconfig.vdf; then
tprint "${ACCT}: signing off of friends..." $(both_mem)
wine_run "${STEAM}"/steam.exe steam://friends/status/offline
while ! grep -q "\"PersonaStateDesired\".*\"0\"" \
"${STEAM}"/userdata/*/config/localconfig.vdf; do
pause
done
fi
}
function idler_login()
{
if ! steam_pid > /dev/null; then
# prompt on initial install
if [ ! -d "${WINEPREFIX}" ] && [ ! -e cred/cred-${ACCT}_[0-9]* ]; then
printf "[$(date +%H:%M:%S)] ${ACCT}: enter y to install: "
read INPUT
if [ -z ${INPUT} ] || [ ${INPUT} != y ]; then
return 1
fi
fi
idler_install
# set credential keys
mkdir -p cred
if [ -e cred/.host-${ACCT} ]; then
HOST=$(cat cred/.host-${ACCT})
if [ ${HOST} != $(hostname) ]; then
tprint "${ACCT}: warning, '${HOST}' has last cred {*}" \
$(steam_connect_hash y | sed s/#/?/)
idler_sleep 5s
fi
fi
OPTS=$(cat cred/cred-${ACCT}_[0-9]* 2> /dev/null | grep MTBF)
sed -i -e "s/\"MTBF\"\t*\"[0-9]*\"/${OPTS}/" "${STEAM}"/config/config.vdf
OPTS=$(cat cred/cred-${ACCT}_[0-9]* 2> /dev/null | grep ConnectCache)
OPTS="Cache\"\n*\t*{\n*\t*\"[a-z0-9]*\"\t*\"[a-z0-9]*\"\n*\t*}/${OPTS}"
sed -i -e ':a;N;$!ba;'"s/\"Connect${OPTS}/" "${STEAM}"/config/config.vdf
# (re)make client files
{
echo "+movedown"
echo "sv_cheats \"1\""
echo "alias _amove \"+left;wait 1;-left;wait 1200;_amove\""
echo "alias _atrig \"cl_trigger_first_notification;wait 30;_atrig\""
echo "alias cmnd"
printf "alias mmute \"voice_loopback 0;cl_voice_filter _pdl_"
echo ";-voicerecord;alias mping\""
echo "alias mhear \"mmute;exec mic\""
printf "alias mtalk \"mhear;wait 120;voice_loopback 1;+voicerecord"
echo ";alias mping mtalk\""
echo "alias mping \"\""
echo "alias _mping \"mping;wait 16000;_mping\""
echo "cl_ask_blacklist_opt_out \"1\""
echo "cl_ask_favorite_opt_out \"1\""
echo "cl_class \"default\""
echo "cl_detaildist \"0\""
echo "cl_detailfade \"0\""
echo "cl_disablehtmlmotd \"1\""
echo "cl_drawmonitors \"0\""
echo "cl_dynamiccrosshair \"0\""
echo "cl_ejectbrass \"0\""
echo "cl_forcepreload \"0\""
echo "cl_hud_minmode \"1\""
echo "cl_hud_playerclass_use_playermodel \"0\""
echo "cl_lagcompensation \"0\""
echo "cl_observercrosshair \"0\""
echo "cl_phys_props_enable \"0\""
echo "cl_phys_props_max \"0\""
echo "cl_playerspraydisable \"1\""
echo "cl_ragdoll_collide \"0\""
echo "cl_ragdoll_fade_time \"0\""
echo "cl_ragdoll_forcefade \"1\""
echo "cl_ragdoll_physics_enable \"0\""
echo "cl_scalecrosshair \"0\""
echo "cl_show_splashes \"0\""
echo "cl_showhelp \"0\""
echo "cl_smooth \"0\""
echo "cl_spec_carrieditems \"0\""
echo "cl_steamscreenshots \"0\""
echo "cl_team \"default\""
echo "cl_timeout \"0\""
echo "clientport \"28001\""
echo "con_enable \"1\""
echo "con_timestamp \"1\""
echo "decalfrequency \"0\""
echo "dsp_slow_cpu \"1\""
echo "fps_max \"30\""
echo "func_break_max_pieces \"0\""
echo "g_ragdoll_fadespeed \"0\""
echo "g_ragdoll_lvfadespeed \"0\""
echo "glow_outline_effect_enable \"0\""
echo "hud_achievement_tracker \"0\""
echo "hud_classautokill \"1\""
echo "joystick \"0\""
echo "lod_transitiondist \"0\""
echo "mat_aaquality \"0\""
echo "mat_antialias \"0\""
echo "mat_bloom_scalefactor_scalar \"0\""
echo "mat_bumpmap \"0\""
echo "mat_colorcorrection \"0\""
echo "mat_colcorrection_disableentities \"1\""
echo "mat_disable_bloom \"1\""
echo "mat_disable_d3d9ex \"1\""
echo "mat_disable_fancy_blending \"1\""
echo "mat_disable_lightwarp \"1\""
echo "mat_disable_ps_patch \"1\""
echo "mat_envmapsize \"0\""
echo "mat_envmaptgasize \"0\""
echo "mat_filterlightmaps \"0\""
echo "mat_filtertextures \"0\""
echo "mat_forceaniso \"0\""
echo "mat_hdr_level \"0\""
echo "mat_motion_blur_enabled \"0\""
echo "mat_motion_blur_strength \"0\""
echo "mat_parallaxmap \"0\""
echo "mat_picmip \"2\""
echo "mat_queue_mode \"0\""
echo "mat_reducefillrate \"1\""
echo "mat_reduceparticles \"1\""
echo "mat_shadowstate \"0\""
echo "mat_software_aa_edge_threshold \"4\""
echo "mat_software_aa_quality \"0\""
echo "mat_software_aa_strength \"0.0\""
echo "mat_software_aa_strength_vgui \"0.0\""
echo "mat_specular \"0\""
echo "mat_supportflashlight \"0\""
echo "mat_trilinear \"0\""
echo "mat_vsync \"0\""
echo "mp_decals \"0\""
echo "mp_timelimit \"0\""
echo "r_3dsky \"0\""
echo "r_ambientboost \"0\""
echo "r_ambientfactor \"0\""
echo "r_ambientmin \"0\""
echo "r_cheapwaterend \"1\""
echo "r_cheapwaterstart \"1\""
echo "r_decals \"0\""
echo "r_decalstaticprops \"0\""
echo "r_drawbatchdecals \"0\""
echo "r_drawdetailprops \"0\""
echo "r_drawflecks \"0\""
echo "r_drawmodeldecals \"0\""
echo "r_drawopaquestaticpropslast \"0\""
echo "r_drawviewmodel \"0\""
echo "r_dynamic \"0\""
echo "r_eyegloss \"0\""
echo "r_eyemove \"0\""
echo "r_eyes \"0\""
echo "r_flashlightdepthtexture \"0\""
echo "r_flashlightnodraw \"1\""
echo "r_flex \"0\""
echo "r_hunkalloclightmaps \"0\""
echo "r_lightaverage \"0\""
echo "r_lod \"2\""
echo "r_maxdlights \"0\""
echo "r_propsmaxdist \"0\""
echo "r_renderoverlayfragment \"0\""
echo "r_rootlod \"2\""
echo "r_shadowmaxrendered \"0\""
echo "r_shadowrendertotexture \"0\""
echo "r_shadows \"0\""
echo "r_spray_lifetime \"0\""
echo "r_staticprop_lod \"4\""
echo "r_teeth \"0\""
echo "r_waterdrawreflection \"0\""
echo "r_waterdrawrefraction \"0\""
echo "r_waterforceexpensive \"0\""
echo "r_waterforcereflectentities \"0\""
echo "r_worldlights \"0\""
echo "ragdoll_sleepaftertime \"0\""
echo "replay_enablerenderpreview \"0\""
echo "rope_averagelight \"0\""
echo "rope_collide \"0\""
echo "rope_rendersolid \"0\""
echo "rope_smooth \"0\""
echo "rope_subdiv \"0\""
echo "rope_wind_dist \"0\""
echo "sb_dontshow_maxplayer_warning \"1\""
echo "snd_async_fullyasync \"1\""
echo "snd_musicvolume \"0\""
echo "snd_pitchquality \"0\""
echo "setinfo name \"\""
echo "sixense_enabled \"0\""
echo "spec_autodirector \"0\""
echo "sv_logfile \"0\""
echo "sv_pure \"-1\""
echo "tf_coach_request_nevershowagain \"1\""
echo "tf_explanations_backpackpanel \"1\""
echo "tf_explanations_charinfo_armory_panel \"1\""
echo "tf_explanations_charinfopanel \"1\""
echo "tf_explanations_craftingpanel \"1\""
echo "tf_explanations_discardpanel \"1\""
echo "tf_explanations_store \"1\""
echo "tf_explanations_tradingpanel \"1\""
echo "tf_particles_disable_weather \"1\""
echo "tf_training_has_prompted_for_forums \"1\""
echo "tf_training_has_prompted_for_loadout \"1\""
echo "tf_training_has_prompted_for_offline_practice \"1\""
echo "tf_training_has_prompted_for_options \"1\""
echo "tf_training_has_prompted_for_training \"1\""
echo "voice_enable \"1\""
echo "voice_fadeouttime \"0.0\""
echo "voice_overdrive \"64\""
echo "volume \"0\""
echo "violence_ablood \"0\""
echo "violence_agibs \"0\""
echo "violence_hblood \"0\""
echo "violence_hgibs \"0\""
} > autoexec.cfg
ln -sf "${DIR}"/autoexec.cfg "${TF}"/cfg/autoexec.cfg
if [ ! -e "${TF}"/cfg/config.cfg ] || [ -w "${TF}"/cfg/config.cfg ]; then
echo // > "${TF}"/cfg/config.cfg
chmod 444 "${TF}"/cfg/config.cfg
fi
echo -e "cl_voice_filter \"\"\nsetinfo name \"\"" > "${TF}"/cfg/mic.cfg
for CLASS in demoman engineer heavyweapons medic pyro scout sniper \
soldier spy; do
echo "echo CLASS_${CLASS}" > "${TF}"/cfg/${CLASS}.cfg
done
{
echo "alias _acmd30 \"exec cmd-${ACCT//./};wait 120;_acmd30\""
echo "con_logfile con-${ACCT}.log"
echo "echo fps30"
echo "exec alias-${ACCT//./}"
echo "echo Disconnect"
} > "${TF}"/cfg/${ACCT//./}+.cfg
echo _acmd30\;_amove\;_mping > "${TF}"/cfg/alias-${ACCT//./}.cfg
echo // > "${TF}"/cfg/cmd-${ACCT//./}.cfg
echo spectate > "${TF}"/cfg/join-${ACCT//./}.cfg
# (re)make and/or link guard key
touch cred/ssfn-${ACCT}
ln -sf "${DIR}"/cred/ssfn-${ACCT} "${STEAM}"
# (re)make and/or link application manifest
if [ ! -e appmanifest_440.acf ]; then
echo '"AppState"{"appID""440""Universe""1""StateFlags""514"}' \
> appmanifest_440.acf
fi
ln -sf "${DIR}"/appmanifest_440.acf "${STEAM}"/steamapps
# erase game download cache
rm -fr "${STEAM}"/steamapps/downloading
# set survey date to the present
sed -i -e "s/urveyDate\"\t*\"[0-9\-]*\"/urveyDate\"\"$(date +%Y-%m-%d)\"/" \
"${STEAM}"/config/config.vdf
# allow for new ui update
if [ $(steam_ui_version) = $(steam_ui_cache_version) ]; then
mv package/old.installed package/steam_client_win32.installed 2> /dev/null
else
mv package/steam_client_win32.installed package/old.installed 2> /dev/null
fi
# configure login modes then initiate
unset AUTH DOWNLOAD EXTRACT HIDE MODE
if [[ ${1} = *hide* ]]; then
MODE=hidden,
else
HIDE=,explorer.exe
fi
OVER=0
if [[ "${1}" = *low* ]]; then
MODE=${MODE}low
elif [[ "${1}" = *high* ]]; then
MODE=${MODE}high
HIDE=${HIDE},icudt.dll,libcef.dll,chromehtml.dll
HIDE=${HIDE},appoverlay.dll,gameoverlayrenderer.dll,gameoverlayui.dll
OVER=1
else
HIDE=${HIDE},icudt.dll,libcef.dll,chromehtml.dll
fi
if [ ! -z ${MODE} ]; then
MODE="(${MODE}) "
fi
tprint "${ACCT}: starting ${MODE}steam..." $(steam_connect_hash)
while ! steam_pid > /dev/null; do
# apply steam configuration
if [ -d "${STEAM}"/userdata ]; then
FID=$(steam_cid)
{
echo "\"UserRoamingConfigStore\"{\"Software\"{\"Valve\"{\"Steam\"{"
echo "\"SteamDefaultDialog\"\"#app_friends\"\"cloudenabled\"\"0\""
echo "\"apps\"{\"440\"{\"cloudenabled\"\"0\"}}}}}"
echo "\"TradeInfoHint\"\"1\"}"
} > "${STEAM}"/userdata/${FID}/config/sharedconfig.vdf
rm -fr "${STEAM}"/userdata/${FID}/7 "${STEAM}"/userdata/${FID}/440 \
"${STEAM}"/userdata/${FID}/760 "${STEAM}"/userdata/${FID}/ugc
mkdir -p "${STEAM}"/userdata/${FID}/7 "${STEAM}"/userdata/${FID}/440 \
"${STEAM}"/userdata/${FID}/760 "${STEAM}"/userdata/${FID}/ugc
chmod 444 "${STEAM}"/userdata/${FID}/7 "${STEAM}"/userdata/${FID}/440 \
"${STEAM}"/userdata/${FID}/760 "${STEAM}"/userdata/${FID}/ugc
if ! grep -q Launch "${STEAM}"/userdata/*/config/localconfig.vdf; then
OPTS="\"system\"{\"EnableGameOverlay\"\"0\"\"JumplistSettings\"\"0\""
OPTS="${OPTS} \"JumplistSettingsKnown\"\"32767\"\"NavUrlBar\"\"1\"}"
OPTS="${OPTS} \"News\"{\"NotifyAvailableGames\"\"0\"}"
OPTS="${OPTS} \"Software\"{\"Valve\"{\"Steam\"{\"SSAVersion\"\"2\""
OPTS="${OPTS} \"PrivacyPolicyVersion\"\"2\"\"apps\"{\"440\"{"
sed -i -e "s/\"friends\"/${OPTS}\nLaunchOptions\n}}}}}&/" \
"${STEAM}"/userdata/*/config/localconfig.vdf
OPTS="\"Notifications_ShowIngame\"\"0\""
OPTS="${OPTS} \"Notifications_ShowOnline\"\"0\""
OPTS="${OPTS} \"Sounds_PlayMessage\"\"0\""
OPTS="${OPTS} \"AutoSignIntoFriends\"\"0\""
OPTS="${OPTS} \"ShowTimeInChatLogCheck\"\"1\""
OPTS="${OPTS} \"ShowAvatars\"\"0\""
sed -i -e ':a;N;$!ba;'"s/\"friends\"\n*\s*{/&${OPTS}/" \
"${STEAM}"/userdata/*/config/localconfig.vdf
fi
unset FARM
if [ ${X_DISPLAY} != ${DISPLAY} ]; then
FARM=-farm
fi
OPTS="${COMMON_OPTS} -dxlevel 80 -h 480 -nocrashdialog -nod3d9ex -nojoy"
OPTS="${OPTS} -nomessagebox -nopreload -nopreloadmodels -norebuildaudio"
OPTS="${OPTS} -novid -port 28101 -sw -w 640 ${FARM} +exec ${ACCT//./}+"
sed -i -e "/LaunchOptions/ s/^.*$/\"LaunchOptions\" \"${OPTS}\"/" \
-e "s/PersonaStateDesired\".*\"[0-9]/PersonaStateDesired\"\"0/" \
-e "s/listSettings\"\t*\"[0-9]*\"/listSettings\"\"1609\"/" \
-e "s/nableGameOverlay\"\t*\"[0-9]\"/nableGameOverlay\"\"${OVER}\"/" \
"${STEAM}"/userdata/*/config/localconfig.vdf
fi
# wait for wineserver and start steam
wineserver -w
if [ ${X_DISPLAY} != ${DISPLAY} ]; then
TYPE=farm-
wineserver -d0farm
else
TYPE=main-
wineserver -d0
fi
unset BOOTSTRAP CONNECTION CRED ERROR GUARD SSA TIMEOUT
echo "" > "${STEAM}"/logs/connection_log.txt
if [[ "${1}" = *low* ]]; then
WINEDLLOVERRIDES=${DLLS/${HIDE}}=d screen -dmS idler-${ACCT}$ \
wine "${STEAM}"/steam.exe ${TYPE}${1} -clearbeta -silent
else
WINEDLLOVERRIDES=${DLLS/${HIDE}}=d screen -dmS idler-${ACCT}$ \
wine "${STEAM}"/steam.exe ${TYPE}${1} -clearbeta -console -silent
fi
while ! window_id Servers > /dev/null; do
pause
let TIMEOUT+=1
# if there is no connection, close error window, then proceed offline
if [ -z ${CONNECTION} ]; then
if window_id \"Connection\ Error > /dev/null; then
CONNECTION=yes
tprint "${ACCT}: fatal, ending offline login... {"'!}'
close_window \"Connection\ Error
# inform when authenticated, mark host file, then hide login window
elif [ -z ${AUTH} ]; then
if is_authenticated && ! window_id Guard > /dev/null; then
AUTH=$(steam_auth_server | grep -o "[A-Z]*")
tprint "${ACCT}: authenticated, loading..." \
${AUTH},@$(steam_pid),$(steam_mem)
hostname > cred/.host-${ACCT}
WID=$(window_id Login)
if [ ! -z ${WID} ]; then
xdotool windowunmap --sync ${WID} 2> /dev/null
fi
# if guard window arrives, prompt for guard code entry
elif [ -z ${GUARD} ]; then
if window_id Guard > /dev/null; then
GUARD=yes
tprint "${ACCT}: waiting for guard code... {?}" $(steam_mem)
# if login window arrives, prompt for password entry
elif [ -z ${CRED} ]; then
if window_id Login > /dev/null; then
CRED=yes
function end_read()
{
while window_id Login viewable > /dev/null; do
pause
done
if pgrep -f bash.*passwd-${ACCT}.sh > /dev/null; then
kill -1 $(pgrep -f bash.*passwd-${ACCT}.sh)
echo
fi
}
end_read &
{
echo "while IFS= read -r -n1 -s CH; do"
echo " case \"\$( echo -n \"\${CH}\" | od -An -tx1 )\" in"
echo " '')"
echo " break"
echo " ;;"
echo " ' 08'|' 7f')"
echo " if [ -n \"\${INPUT}\" ]; then"
echo " INPUT=\"\$( echo \"\${INPUT}\" \\"
echo " | sed 's/.\$//' )\""
echo " echo -n \$'\b \b' 1>&2"
echo " fi"
echo " ;;"
echo " ' 15')"
echo " echo -n \"\${INPUT}\" | sed 's/./\cH \cH/g' >&2"
echo " INPUT=''"
echo " ;;"
echo " *)"
echo " INPUT=\"\${INPUT}\${CH}\""
echo " echo -n '*' 1>&2"
echo " ;;"
echo " esac"
echo "done"
echo "echo \${INPUT}"
} > "${WINEPREFIX}"/passwd-${ACCT}.sh
printf "[$(date +%H:%M:%S)] ${ACCT}: input password: "
while ! is_authenticated \
&& window_id Login viewable > /dev/null; do
INPUT=$(bash "${WINEPREFIX}"/passwd-${ACCT}.sh)
if [ -z ${INPUT} ]; then
continue
fi
if window_id Login viewable > /dev/null; then
focus_window $(window_id Login)
xdotool type --delay 150ms ${INPUT}
unset INPUT WARNING
xdotool key Return
while ! is_authenticated; do
if window_id Error > /dev/null; then
xdotool key Return
echo
printf "[$(date +%H:%M:%S)] ${ACCT}: retry password: "
continue 2
elif [ -z ${WARNING} ] \
&& window_id Warning > /dev/null; then
WARNING=yes
xdotool key Return
fi
done
echo
fi
done
stty echo
# inform when bootstrapper is downloading
elif [ -z ${BOOTSTRAP} ]; then
if window_id Updating > /dev/null; then
BOOTSTRAP=yes
tprint "${ACCT}: downloading steam bootstrapper..." \
$(steam_mem)
# if the greeting window arrives, create new account
else
WID=$(window_id \"Steam\" atom)
if [ ! -z ${WID} ]; then
if [ -z ${F2P} ] \
&& xprop -id ${WID} 2> /dev/null | grep -q 432\ by; then
F2P=yes
tprint "${ACCT}: filling fields..." $(steam_mem)
function key()
{
focus_window ${WID}
xdotool key ${1}
pause
}
function input()
{
xdotool type --delay 150ms ${1}
pause
}
function wait_on()
{
xdotool key --window ${WID} Return
while ! window_id ${1} > /dev/null; do
pause 0.1
done
while window_id ${1} > /dev/null; do
pause
done
}
key Return ; key Return ; key Return
input ${ACCT} ; key Tab ; input ${PASSWORD} ; key Tab \
; input ${PASSWORD}
wait_on working
input ${EMAIL} ; key Tab ; input ${EMAIL}
wait_on working
key Tab ; input ${RANDOM}
tprint "${ACCT}: creating account..." $(steam_mem)
wait_on Working
while window_id Create opacity > /dev/null; do
pause
key Return
done
rm -fr "${STEAM}"/userdata/????? \
"${STEAM}"/userdata/??????
# inform if there is ui package activity
elif [ -z ${DOWNLOAD} ]; then
TIMEOUT=91
DOWNLOAD=yes
UI=$(steam_ui_version)
if [ ${UI} = none ]; then
UI=$(steam_ui_cache_version)
fi
tprint "${ACCT}: checking/updating steam ui..." \
${UI},$(steam_mem)
fi
fi
if [ -z ${EXTRACT} ]; then
if [ ${TIMEOUT} = 90 ]; then
tprint "${ACCT}: warning, hung launch... {*}" \
$(steam_mem)
idler_logout yes > /dev/null
elif [ -e "${STEAM}"/package/*win32 ]; then
EXTRACT=yes
if [ $(steam_ui_cache_version) \
= $(steam_ui_web_version) ]; then
tprint "${ACCT}: extracting steam ui..." \
$(steam_ui_cache_version),$(steam_mem)
else
tprint "${ACCT}: warning, old ui version... {*}" \
$(steam_ui_cache_version),$(steam_mem)
fi
steam_ui_cache_version > "${WINEPREFIX}"/.ui.pdl
fi
elif [ ${TIMEOUT} = 150 ]; then
tprint "${ACCT}: warning, hung extraction... {*}" \
$(steam_mem)
idler_logout yes > /dev/null
fi
fi
fi
fi
fi
fi
fi
# restart for bootstrapper update, ui extraction, or fail/cancel
if ! steam_pid > /dev/null; then
if [ -e "${STEAM}"/SteamNew.exe ]; then
tprint "${ACCT}: updating steam bootstrapper..." \
$(steam_version)
screen -dmS idler-${ACCT}$ wine "${STEAM}"/steamTmp.exe SelfUpdate \
"C:\Program Files\Steam\Steam.exe" \
$(basename "${STEAM}"/steam_*.mst | grep -o \[0-9]*) -silent
while pgrep -f wine-${ACCT}/.*steamTmp.exe > /dev/null; do
pause 1.2
done
elif [ ! -z ${AUTH} ]; then
tprint "${ACCT}: warning, retry for auth error... {*}" \
$(steam_connect_hash)
elif [ -z ${EXTRACT} ] || [ ! -z ${CRED} ]; then
if [ ! -z ${ERROR} ]; then
tprint "${ACCT}: error, steam server problem {"'!}'
else
tprint "${ACCT}: error, user cancel {"'!}'
fi
return 1
fi
continue 2
# close miscellaneous error windows
elif [ -z ${ERROR} ] && [ -z ${CRED} ] \
&& window_id Steam\ -\ Error > /dev/null; then
ERROR=yes
close_window Error
fi
done
# wait if the user needs to accept license agreement(s)
if window_id Subscriber > /dev/null; then
tprint "${ACCT}: waiting for eula agreement... {?}" $(steam_mem)
while window_id Subscriber > /dev/null; do
pause
done
fi
# restart for initial configuration
if ! grep -q LaunchOp "${STEAM}"/userdata/*/config/localconfig.vdf; then
tprint "${ACCT}: restarting for configuration..." $(steam_mem)
idler_logout > /dev/null
sed -i -e ':a;N;$!ba;s/"friends"\n*\s*{/&"PersonaStateDesired""0"/' \
"${STEAM}"/userdata/*/config/localconfig.vdf
# end an offline login
elif [ ! -z ${CONNECTION} ]; then
idler_logout > /dev/null
exit 1
# backup credentials, ensure initial offline state, then finish
else
backup_credentials
wine_run "${STEAM}"/steam.exe steam://friends/status/offline
date +%s > "${WINEPREFIX}"/.timestamp.pdl
tprint "${ACCT}: logged in" $(steam_connect_hash),$(steam_mem)
fi
done
fi
}
function idler_create()
{
# parse input, prep wineprefix for account creation, then login
if [ ! -d "${WINEPREFIX}" ]; then
printf "[$(date +%H:%M:%S)] ${ACCT}: input password: "
read -s PASSWORD
echo
if (( $(expr length "${PASSWORD}") >= 8 )) \
&& echo ${PASSWORD} | grep -q [0-9]; then
printf "[$(date +%H:%M:%S)] ${ACCT}: confirm password: "
read -s CONFIRM
echo
if [ ${PASSWORD} = "${CONFIRM}" ]; then
printf "[$(date +%H:%M:%S)] ${ACCT}: input email: "
read EMAIL
if echo ${EMAIL} | grep -q .*@.*\..*; then
idler_install
rm "${STEAM}"/config/SteamAppData.vdf
idler_login || return 1
return 0
else
tprint "${ACCT}: error, invalid email {"'!}'
fi
else
tprint "${ACCT}: error, passwords don't match {"'!}'
fi
else
tprint "${ACCT}: error, invalid password {"'!}'
fi
else
tprint "${ACCT}: error, account exists {"'!}'
fi
return 1
}
function idler_website()
{
# open relevant website in the default browser
if steam_uid > /dev/null; then
if [ "${1/.tf}" = backpack ]; then
SITE=backpack.tf/id/$(steam_uid)
elif [ "${1/.com}" = tf2items ]; then
SITE=tf2items.com/profiles/$(steam_uid)
elif [ "${1/.com}" = willitcraft ]; then
SITE=willitcraft.com/'#!'$(steam_uid)/
elif [ "${1/.com}" = stm_com ]; then
SITE=steamcommunity.com/profiles/$(steam_uid)/
elif [ "${1/.com}" = stm_inv ]; then
SITE=steamcommunity.com/profiles/$(steam_uid)/inventory/\#753
else
SITE=tf2b.com/tf2/$(steam_uid)
fi
tprint "${ACCT}: opening website..." $(echo ${SITE} | sed "s/\/.*//")
xdg-open http://${SITE}
pause 0.1
else
tprint "${ACCT}: error, not installed {"'!}'
fi
}
function idler_online()
{
# set friend presense to online
if steam_pid > /dev/null && grep -q "\"PersonaStateDesired\".*\"0\"" \
"${STEAM}"/userdata/*/config/localconfig.vdf; then
tprint "${ACCT}: signing on to friends..." $(both_mem)
wine_run "${STEAM}"/steam.exe steam://friends/status/online
while ! grep -q "\"PersonaStateDesired\".*\"1\"" \
"${STEAM}"/userdata/*/config/localconfig.vdf; do
pause
done
fi
}
function idler_enter()
{
# join public chatroom and mark prior friends status
if steam_pid > /dev/null && ! window_id Group\ Chat > /dev/null; then
if cat "${STEAM}"/userdata/*/config/localconfig.vdf | tr -d '\n' \
| grep -oP "\"Licenses\"\t{.*?}" | grep -q "\"[1-9][0-9]*\""; then
if [ ! -z ${1} ]; then
if [[ ${1} =~ ^[0-9]*$ ]] && (( $(expr length ${1}) >= 18 )); then
CHAT=${1}
else
tprint "${ACCT}: error, invalid chat id {"'!}'
return 1
fi
else
CHAT=103582791432273268
fi
tprint "${ACCT}: entering chatroom..." \#${CHAT},$(both_mem)
if grep -q "\"PersonaStateDesired\".*\"0\"" \
"${STEAM}"/userdata/*/config/localconfig.vdf; then
rm -f "${STEAM}"/friends.pdl
else
touch "${STEAM}"/friends.pdl
fi
wine_run "${STEAM}"/steam.exe steam://friends/joinchat/${CHAT}
while ! window_id Group\ Chat > /dev/null; do
pause
done
xdotool windowmove $(window_id Group\ Chat) 636 284
else
tprint "${ACCT}: error, chat unavailable on f2p account {"'!}'
fi
fi
}
function idler_exit()
{
# leave public chatroom and restore prior friends status
if window_id Group\ Chat > /dev/null; then
tprint "${ACCT}: exiting chatroom..." $(both_mem)
close_window Group\ Chat
if [ ! -e "${STEAM}"/friends.pdl ]; then
idler_offline
fi
fi
}
function is_friend()
{
# check if the current account is friends via the community id
if [ "${FRIEND_WGET}" != ${ACCT} ]; then
download http://steamcommunity.com/profiles/$(steam_uid)/friends \
.friends.cache
FRIEND_WGET=${ACCT}
fi
if ! cat .friends.cache | grep -q miniprofile=\"$(steam_cid ${1})\"; then
return 1
fi
}
function set_account()
{
# set the account directory locations
ACCT=${1}
export WINEPREFIX="${DIR}"/wine-${1}
STEAM="${WINEPREFIX}"/drive_c/Program\ Files/Steam
CON="${TF}"/con-${ACCT}.log
}
function pause_ensure()
{
# use the timestamp file to ensure a certain time has elapsed
if (($(date +%s)-$(cat "${WINEPREFIX}"/.timestamp.pdl) <= ${1}-1)); then
pause $((${1}-($(date +%s)-$(cat "${WINEPREFIX}"/.timestamp.pdl))))
fi
date +%s > "${WINEPREFIX}"/.timestamp.pdl
}
function invite_friend()
{
# send friend invite
OLD_ACCT=${ACCT}
if [ ! -z ${2} ] && [ -d "${DIR}"/wine-${2} ]; then
set_account ${2}
fi
pause_ensure 8
wine_run "${STEAM}"/steam.exe steam://friends/add/$(steam_uid ${1})
local TIMEOUT=0
while ! window_id Friends\ -\ > /dev/null; do
pause 0.25
let TIMEOUT+=1
if [ ${TIMEOUT} = 12 ]; then
break
fi
done
close_window Friends\ -\
set_account ${OLD_ACCT}
}
function idler_friend()
{
# send and/or queue friend invites between initiated accounts
FRIEND="${ACCOUNTS}"
if [ ! -z ${1} ]; then
FRIEND=$(echo ${1} | tr [:upper:] [:lower:] | sed s/-/\ /g)
fi
unset QUEUED
for ADD in ${FRIEND}; do
if [ ${ADD} != ${ACCT} ] && [ -e cred/cred-${ADD}_* ] \
&& ! grep -q ^${ADD}\#[0-9]*$ cred/.friend-${ACCT} 2> /dev/null \
&& ! is_friend ${ADD}; then
DATE=$(date +%s)
echo ${ACCT}\#${DATE} >> cred/.friend-${ADD}
echo ${ADD}\#${DATE} >> cred/.friend-${ACCT}
unset ADD_UP
if [ "$(cat cred/.host-${ADD} 2> /dev/null)" = $(hostname) ]; then
ADD_UP=yes
fi
if ! steam_pid > /dev/null && [ -z ${ADD_UP} ]; then
let QUEUED+=1
elif steam_pid > /dev/null && [ ! -z ${ADD_UP} ]; then
tprint "sending invites..." ${ACCT}\>\<${ADD}
invite_friend ${ADD}
invite_friend ${ACCT} ${ADD}
elif [ -z ${ADD_UP} ]; then
tprint "${ACCT}: inviting with set queue..." ${ADD}
invite_friend ${ADD}
sed -i -e "s/${ADD}#[0-9]*/${ADD}#$(($(date +%s)+1))/" \
cred/.friend-${ACCT}
else
tprint "${ACCT}: set queue and inviting..." ${ADD}
invite_friend ${ACCT} ${ADD}
sed -i -e "s/${ACCT}#[0-9]*/${ACCT}#$(($(date +%s)+1))/" \
cred/.friend-${ADD}
fi
fi
done
if [ ! -z ${QUEUED} ]; then
tprint "${ACCT}: queued invites" x${QUEUED}
fi
}
function tf2_license()
{
# get tf2 license origin
LICENSES="$(cat "${STEAM}"/userdata/*/config/localconfig.vdf \
| tr -d '\n' | grep -oP Licenses.*?{.*?})"
if echo ${LICENSES} \
| grep -q '"469"\|"474"\|"48[2-3]"\|"498"\|"642"\|"801"\|"1289[7-8]"'; then
echo orange
elif echo ${LICENSES} | grep -q '"293"\|"499"\|"558"\|"829"\|"479"'; then
echo bundle
elif echo ${LICENSES} \
| grep -q '"478"\|"113[4-5]"\|"254[6-7]"\|"793[0-1]"\|"1623[6-7]"'; then
echo vpack
elif echo ${LICENSES} \
| grep -q '"502"\|"51[8-9]"\|"643"\|"687"\|"938"\|"489[5-6]"\|"6202"'; then
echo retail
elif echo ${LICENSES} | grep -q \"8538\"; then
echo premium
else
echo f2p
return 1
fi
}
function modify_client_ui()
{
# download hllib
if [ ! -e HLExtract.exe ]; then
tprint "${ACCT}: downloading hllib..." v2.4.4
download http://nemesis.thewavelength.net/files/files/hllib244.zip
unzip -j hllib244.zip bin/x86/* > /dev/null
rm hllib244.zip
fi
# alter select vgui dialog dimensions to assist helper
OPTS="${TF}"/custom/pdl/resource/ui
mkdir -p "${OPTS}"/econ/store/v1
if [ ! -e "${OPTS}"/selectmosthelpfulfrienddialog.res ]; then
wine_run HLExtract.exe -s -p "${TF}"/tf2_misc_dir.vpk -d "${OPTS}" \
-e "root\\resource\\ui\\selectmosthelpfulfrienddialog.res"
sed -i -e 's/\t\t"SelectPlayerDialog"/&\n"wide""640"/' \
-e 's/\t\t"CancelButton"/&\n"ypos""0""wide""640""tall""640"/' \
"${OPTS}"/selectmosthelpfulfrienddialog.res
fi
if [ ! -e "${OPTS}"/econ/itempickuppanel.res ]; then
wine_run HLExtract.exe -s -p "${TF}"/tf2_misc_dir.vpk -d "${OPTS}"/econ \
-e "root\\resource\\ui\\econ\\itempickuppanel.res"
sed -i -e 's/\t\t"CloseButton"/&\n"ypos""0""tall""600""wide""800"/' \
"${OPTS}"/econ/itempickuppanel.res
fi
if [ ! -e "${OPTS}"/econ/store/v1/storestatusdialog.res ]; then
wine_run HLExtract.exe -s -p "${TF}"/tf2_misc_dir.vpk \
-e "root\\resource\\ui\\econ\\store\\v1\\storestatusdialog.res" \
-d "${OPTS}"/econ/store/v1
sed -i -e s/\"250\"/\"800\"/ -e s/\"150\"/\"600\"/ -e s/\"100\"/\"800\"/ \
-e s/\"25\"/\"600\"/ "${OPTS}"/econ/store/v1/storestatusdialog.res
fi
}
function client_version()
{
# get client version
version $(cat "${TF}"/steam.inf 2> /dev/null | grep Client | grep -o \[0-9]*)
}
function item_schema()
{
# get item schema from specified log
SCHEMA=$(dcat "${1}" y | grep -m 1 -o version\ \[A-F0-9][A-F0-9]* \
| grep -o \[A-F0-9]*)
if [ -z ${SCHEMA} ]; then
echo noschema
return 1
fi
echo ${SCHEMA}
}
function load()
{
# prep client, modify ui if farming, then start
unset ERRORS
while ! hl2_pid > /dev/null; do
unset BEGAN CLOUD ERROR READY TIMEOUT UPDATE VALIDATE
echo "" > "${STEAM}"/GameValidation.log
echo // > "${TF}"/cfg/cmd-${ACCT//./}.cfg
echo spectate > "${TF}"/cfg/join-${ACCT//./}.cfg
if [ "${2}" = farm ] && [ -e "${TF}"/tf2_misc_dir.vpk ]; then
modify_client_ui
fi
pause_ensure 5
wine_run "${STEAM}"/steam.exe -applaunch 440 ${1}
while ! hl2_pid > /dev/null; do
pause
# if cloud conflicts, warn then await user action
if [ -z ${CLOUD} ] && window_id "Conflict\|Warning" > /dev/null; then
CLOUD=yes
tprint "${ACCT}: warning, cloud conflict... {*}" $(steam_mem)
fi
# if game is unavailable, warn then retry 3 times
if [ -z ${ERROR} ]; then
if window_id Error > /dev/null; then
ERROR=yes
let ERRORS+=1
if [ ${ERRORS} = 1 ]; then
tprint "${ACCT}: warning, game unavailable... {*}" $(steam_mem)
fi
close_window Error
if [ ${ERRORS} = 3 ]; then
tprint "${ACCT}: fatal, steam servers down {"'!}' $(steam_mem)
exit 1
fi
fi
elif ! window_id Error > /dev/null; then
break
fi
# if updating, warn then (re)modify ui if farming and retry after complete
if [ -z ${UPDATE} ] && window_id Updating > /dev/null; then
UPDATE=yes
tprint "${ACCT}: warning, updating tf2... {*}" \
$(client_version),$(steam_mem)
elif [ -z ${READY} ]; then
if window_id Ready > /dev/null; then
READY=yes
if [ -z ${UPDATE} ]; then
tprint "${ACCT}: warning, game readied... {*}" $(steam_mem)
fi
close_window Ready
elif [ ! -z ${UPDATE} ] && ! window_id Updating > /dev/null; then
tprint "${ACCT}: error, user cancelled update {"'!}' $(steam_mem)
return 1
fi
elif ! window_id Ready > /dev/null; then
if [ "${2}" = farm ]; then
modify_client_ui
fi
break
fi
# if validating, warn then retry after completion/bypass
if [ -z ${VALIDATE} ]; then
if window_id Validating > /dev/null; then
VALIDATE=yes
tprint "${ACCT}: warning, validating content... {*}" $(steam_mem)
fi
elif ! window_id Validating > /dev/null; then
break
elif window_id "Validating Steam files - [1-9][0-9]%" > /dev/null \
&& [ ! -z ${START} ] || grep -q plete: "${STEAM}"/GameValidation.log; then
tprint "${ACCT}: completing validation..." $(steam_mem)
close_window Validating
fi
# interpret user cancel
if [ -z ${BEGAN} ]; then
if window_id Fortress > /dev/null; then
BEGAN=yes
elif [ ${TIMEOUT} != 10 ]; then
let TIMEOUT+=1
else
TIMEOUT=0
tprint "${ACCT}: warning, retrying launch... {*}" $(steam_mem)
break
fi
elif ! window_id Fortress > /dev/null && ! hl2_pid > /dev/null \
&& [ -z ${UPDATE}${ERROR}${VALIDATE} ] \
&& dcat "${STEAM}"/logs/content_log.txt y \
| grep -m 1 "Installed,$\|Running,$" | grep -q Installed,; then
tprint "${ACCT}: error, user cancelled start {"'!}' $(steam_mem)
return 1
fi
done
done
START=yes
# disable power management
if pgrep -f gnome-power-manager > /dev/null; then
tprint "stopped gnome-power-manager" @$(pgrep -f gnome-power-manager)
killall -w gnome-power-manager
elif pgrep -f xfce4-power-manager > /dev/null; then
tprint "stopped xfce4-power-manager" @$(pgrep -f xfce4-power-manager)
kill -9 $(pgrep -f xfce4-power-manager)
fi
# wait for client to load
tprint "${ACCT}: loading tf2..." @$(hl2_pid),$(both_mem)
while ! grep -q Disconnect "${CON}"; do
pause
if ! hl2_pid > /dev/null; then
tprint "${ACCT}: error, client crashed {"'!}' $(steam_mem)
return 1
fi
done
# wait for item schema to apply then finish
tprint "${ACCT}: getting schema..." $(client_version),$(both_mem)
local TIMEOUT=0
while ! item_schema "${CON}" > /dev/null; do
pause
let TIMEOUT+=1
if [ ${TIMEOUT} = 180 ]; then
tprint "${ACCT}: warning, item schema missing {*}" $(both_mem)
break
elif dcat "${CON}" y | grep -q "Failed to update item schema"; then
tprint "${ACCT}: error, item schema failed {"'!}' $(both_mem)
idler_stop > /dev/null
return 1
fi
done
tprint "${ACCT}: client started" $(item_schema "${CON}"),$(both_mem)
}
function idler_play()
{
# start client
if ! hl2_pid > /dev/null; then
idler_login || return 1
tprint "${ACCT}: preparing tf2..." \$$(tf2_license),$(steam_mem) \
| tee "${CON}"
echo _acmd30\;_amove\;_mping > "${TF}"/cfg/alias-${ACCT//./}.cfg
load
fi
}
function idler_command()
{
# parse or accept input then run command on the client
if hl2_pid > /dev/null; then
COMMAND="${1}"
if [ -z "${COMMAND}" ]; then
printf "[$(date +%H:%M:%S)] ${ACCT}: input command: "
read COMMAND
if [ -z "${COMMAND}" ]; then
tprint "${ACCT}: fatal, no input {"'!}'
exit 1
fi
fi
tprint "${ACCT}: running '${COMMAND}'..." $(both_mem)
cmd "${COMMAND}"
fi
}
function idler_join()
{
# join specified or random team and class
if client_map > /dev/null; then
if [ -z ${TEAM} ]; then
if [[ ${1} = *-* ]]; then
TEAM=${1/-*}
CLASS=${1/*-}
if [ $(echo ${TEAM} | tr [:upper:] [:lower:]) = blu ]; then
TEAM=blue
fi
if [ $(echo ${CLASS} | tr [:upper:] [:lower:]) = heavy ]; then
CLASS=heavyweapons
fi
else
TEAM=auto
CLASS=auto
fi
fi
tprint "${ACCT}: joining team/class..." ${TEAM}/${CLASS},$(both_mem)
echo "jointeam ${TEAM};wait 300;joinclass ${CLASS}" \
> "${TF}"/cfg/join-${ACCT//./}.cfg
cmd "jointeam ${TEAM};wait 300;joinclass ${CLASS}"
fi
}
function idler_spectate()
{
# join spectators
if client_map > /dev/null; then
tprint "${ACCT}: joining spectators..." $(both_mem)
echo spectate > "${TF}"/cfg/join-${ACCT//./}.cfg
cmd spectate
fi
}
function server_version()
{
# get server version
version $(grep Server srcds/tf/steam.inf 2> /dev/null | grep -o \[0-9]*)
}
function compile_plugin()
{
# compile and install server plugin
( cd ${SMOD}/scripting
./compile.sh ${1} > /dev/null
mv compiled/${1}.smx ../plugins/${1}.smx
)
}
function server_mem()
{
# get memory usage of server process
echo $(($(grep RSS /proc/$(pgrep -fn srcds_linux.*28201)/status \
| grep -o \[0-9]*) / 1024))mb
}
function server_ircname()
{
# get irc nickname of server
cat ${SMOD}/configs/sourceirc.cfg | grep nickname\"\".* \
| sed -e s/\"nickname\"// -e s/\"//g
}
function start_server()
{
if ! pgrep -f srcds_linux.*28201 > /dev/null; then
# install steamcmd
if [ ! -e steamcmd/steamcmd.sh ]; then
tprint "installing steamcmd..."
mkdir -p steamcmd
rm -fr steamcmd/* srcds/*
download http://media.steampowered.com/client/steamcmd_linux.tar.gz
tar -xzf steamcmd_linux.tar.gz -C steamcmd
rm steamcmd_linux.tar.gz
NEW="validate"
fi
# check/update server content, create log file with the output, then link
tprint "checking/updating server content..." $(server_version)
if ! pgrep steamcmd > /dev/null; then
mv ${HOME}/.steam ${HOME}/.steam-other 2> /dev/null
mv ${HOME}/Steam ${HOME}/Steam-other 2> /dev/null
ln -sf "${DIR}"/steamcmd ${HOME}/Steam
rm -f screenlog.0
screen -dmLS idler-server$ sh steamcmd/steamcmd.sh +login anonymous \
+force_install_dir ../srcds +app_update 232250 ${NEW} +quit
fi
while ! grep -q "Success. App '232250'" screenlog.0 2> /dev/null; do
if grep -q "Failed to receive license" screenlog.0 2> /dev/null; then
tprint "fatal: server failed to update {"'!}' nolicense
exit 1
fi
pause
done
rm -fr steamcmd/userdata/*
DATE=$(date +%Y-%m-%d_%H.%M.%S)
mkdir -p logs
cat screenlog.0 > logs/${DATE}-server.log
rm -f screenlog.0
ln -sf "${DIR}"/logs/${DATE}-server.log ${SCON}
# install metamod/sourcemod
SMOD=srcds/tf/addons/sourcemod
MS=newyork.download.maverickservers.com/source/mmsource-1.10.0-linux.tar.gz
if [ ! -e srcds/tf/${MS##*/} ]; then
tprint "installing/updating metamod:source..." \
v$(echo ${MS/*mmsource-} | sed -e "s/-linux.tar.gz//")
rm -fr srcds/tf/mmsource-*-linux.tar.gz srcds/tf/addons/metamod/bin
download ${MS} srcds/tf
tar -xzf srcds/tf/${MS##*/} -C srcds/tf
download www.sourcemm.net/vdf?vdf_game=tf srcds/tf/addons/metamod.vdf
fi
SM=newyork.download.maverickservers.com/source/sourcemod-1.5.1-linux.tar.gz
if [ ! -e srcds/tf/${SM##*/} ]; then
tprint "installing/updating sourcemod..." \
v$(echo ${SM/*sourcemod-} | sed -e "s/-linux.tar.gz//")
rm -fr srcds/tf/sourcemod-*-linux.tar.gz srcds/tf/cfg/sourcemod ${SMOD}
download ${SM} srcds/tf
tar -xzf srcds/tf/${SM##*/} -C srcds/tf
sed -i -e "s/Logging\"\t\t\"on\"/Logging\"\t\t\"off\"/" \
${SMOD}/configs/core.cfg
mv ${SMOD}/plugins/*.smx ${SMOD}/plugins/disabled
mv ${SMOD}/extensions/dbi.*.ext.so ${SMOD}/plugins/disabled
echo // > srcds/tf/cfg/sourcemod/sourcemod.cfg
fi
# install sourceirc
if [ -z ${IRC_SERVER} ]; then
IRC_SERVER=irc.freenode.net
fi
if [ -z ${IRC_SERVER_PASS} ]; then
IRC_SERVER_PASS=""
fi
if [ -z ${IRC_SERVER_PORT} ]; then
IRC_SERVER_PORT=6667
fi
if [ -z ${IRC_CHANNEL} ]; then
IRC_CHANNEL=primarydataloop
fi
if [ -z ${IRC_CHANNEL_PASS} ]; then
IRC_CHANNEL_PASS=""
fi
if [ ! -z ${IRC_SERVER} ] && [ ${IRC_SERVER} != none ]; then
if [ ! -e ${SMOD}/sourceirc.zip ]; then
download http://tinyurl.com/l7j97dk ${SMOD}/sourceirc.zip
unzip -ud ${SMOD} ${SMOD}/sourceirc.zip > /dev/null
VER=$(cat ${SMOD}/scripting/include/sourceirc.inc | grep -o -m1 \".*\" \
| sed -e "s/\"//g" -e "s/ /_/g")
tprint "installing sourceirc..." ${VER}
download http://tinyurl.com/n85heef srcds/tf/socket_3.0.1.zip
unzip -ud srcds/tf srcds/tf/socket_3.0.1.zip > /dev/null
mkdir -p ${SMOD}/scripting/compiled/SourceIRC
OPTS="StrEqual(command, \"366\")) {\n\t\tPrintToServer(\"pdlirc\");"
sed -i -e "s/CloseHandle(connected);/&\n\t} else if (${OPTS}/" \
${SMOD}/scripting/SourceIRC/sourceirc.sp
compile_plugin SourceIRC/sourceirc
sed -i -e "s/GetClientCount()/GetClientCount(false)/g" \
${SMOD}/scripting/SourceIRC/sourceirc-status.sp
compile_plugin SourceIRC/sourceirc-status
download http://tinyurl.com/kl2vew8 srcds/tf/ItemBotLite_v1.2.0.zip
unzip -ud srcds/tf/addons srcds/tf/ItemBotLite_v1.2.0.zip > /dev/null
NAME=$(hostname | sed -e s/-// -e s/_// | cut -c 1-10)${RANDOM:0:3}
sed -i -e "s/name.*\"/name\"\"${NAME}\"/" -e "s/\"cmd_/\/\/&/" \
-e "s/\"relay\"/\"items\"\"1\"\n&/" ${SMOD}/configs/sourceirc.cfg
fi
mv ${SMOD}/plugins/disabled/SourceIRC ${SMOD}/plugins 2> /dev/null
OPTS="\t\t\"password\"\t\""
sed -i -e "s/\"server\"\t\".*\"/\"server\"\t\"${IRC_SERVER}\"/" \
-e "s/\"port\"\t\t\".*\"/\"port\"\t\t\"${IRC_SERVER_PORT}\"/" \
-e "s/${OPTS}.*\"/${OPTS}${IRC_SERVER_PASS}\"/" \
-e "s/\t\t${OPTS}.*\"/\t\t${OPTS}${IRC_CHANNEL_PASS}\"/" \
-e "s/\"#.*\"/\"#${IRC_CHANNEL}\"/" ${SMOD}/configs/sourceirc.cfg
else
mv ${SMOD}/plugins/SourceIRC ${SMOD}/plugins/disabled 2> /dev/null
fi
# compile idle server plugin
{
echo "#include <sdktools>"
echo "PrintPlayerCount() {"
echo " decl String:time[15];"
echo " FormatTime(time, 15, \"%D-%H:%M\", GetTime());"
echo " PrintToServer(\"[%s] Players: %d\", time, GetClientCount(false));"
echo "}"
echo "public OnPluginStart() {"
echo " PrintPlayerCount();"
echo "}"
echo "public bool:OnClientConnect(c, String:rejectmsg[], maxlen) {"
echo " decl String:tvnochat[2];"
echo " GetClientInfo(c, \"tv_nochat\", tvnochat, 2);"
echo " if (strcmp(tvnochat, \"0\", false) == 0) {"
echo " InactivateClient(c);"
echo " }"
echo " PrintPlayerCount();"
echo " return true;"
echo "}"
echo "public OnClientDisconnect_Post(c) {"
echo " PrintPlayerCount();"
echo " return true;"
echo "}"
} > ${SMOD}/scripting/pdl-idler.sp
compile_plugin pdl-idler
# start server
tprint "loading server..." $(server_version) | tee -a ${SCON}
( cd srcds
screen -dmS idler-server$ ./srcds_run ${COMMON_OPTS} -game tf -condebug \
-norestart -port 28201 +sv_cheats 1 +ip 0.0.0.0 +sv_pure 0 +fps_max 10 \
+maxplayers 32 +mp_idledealmethod 0 +mp_timelimit 0 +sv_timeout 0 \
+map cp_cloak
)
while ! grep -q "Steam servers successful" ${SCON}; do
pause
done
mv ${HOME}/.steam-other ${HOME}/.steam 2> /dev/null
mv ${HOME}/Steam-other ${HOME}/Steam 2> /dev/null
tprint "getting server schema..." $(server_mem)
while ! item_schema ${SCON} > /dev/null; do
pause
done
if [ "${IRC_SERVER}" != none ]; then
tprint "connecting server to irc..." \
$(server_ircname),$(server_mem)
while ! grep pdlirc ${SCON} > /dev/null; do
pause
done
fi
tprint "server started" $(item_schema ${SCON}),$(server_mem)
fi
}
# set command line options for textmode clients
TEXTMODE_OPTS="-noborder -nomouse"
function idler_start()
{
# start client in textmode
if ! hl2_pid > /dev/null; then
idler_login || return 1
tprint "${ACCT}: preparing textmode tf2..." \
\$$(tf2_license),$(steam_mem) | tee "${CON}"
{
echo "_acmd30;_amove;_mping"
echo "alias _ajoin \"exec join-${ACCT//./};wait 15000;_ajoin\""
echo "_ajoin"
echo "alias _ateam \"changeteam;wait 3000;_ateam\""
echo "_ateam"
echo "mat_texture_limit 0"
} > "${TF}"/cfg/alias-${ACCT//./}.cfg
load "${TEXTMODE_OPTS} -textmode" || return 1
echo _acmd30\;_amove\;_mping > "${TF}"/cfg/alias-${ACCT//./}.cfg
fi
}
function server_playercount()
{
# get player count of idle server
dcat ${SCON} y | grep -o -m 1 Players\:.* | grep -o \[0-9]*
}
function idler_connect()
{
# if specified, check location server/map
unset LOCATION TEST
if [ ! -z ${1} ]; then
TEST=${1}
if [[ ${TEST} = *.* ]]; then
TEST=${1}
if [[ ${TEST} != *:* ]]; then
TEST="${TEST} 27015"
fi
TEST="${TEST/:/ }"
if ! ping -c1 -W1 $(echo ${TEST} | awk '{print $1}') > /dev/null \
|| ! nc -vzu ${TEST} 2> /dev/null; then
tprint "warning, no server on ${1} (*)"
unset TEST
else
LOCATION="connect ${1}"
if [[ ${LOCATION} != *:* ]]; then
LOCATION="connect ${1}:27015"
fi
fi
else
LOCATION="map ${1}"
fi
fi
# if no location server, use idle server
if [ -z "${TEST}" ]; then
start_server
# get network device ip
for NET in $(cat /proc/net/dev | grep : | cut -d ':' -f 1); do
if [ ${NET} != lo ]; then
LOCATION=$(/sbin/ip addr show ${NET} | grep "inet " | awk '{print $2}' \
| sed -e "s/\/.*//")
if [ ! -z ${LOCATION} ]; then
LOCATION="connect ${LOCATION}:28201"
break
fi
fi
done
# restart low-resource client if connecting to a location server
elif hl2_pid noshaderapi > /dev/null; then
tprint "${ACCT}: warning, restarting low-resource client... {*}" $(both_mem)
idler_stop
fi
# if there is no running client, start it in textmode
if ! hl2_pid > /dev/null; then
idler_start || return 1
fi
# proceed if not already connected to specified server
if ! dcat "${CON}" y | grep -m 1 ": Disconnect\|: Connected to" \
| grep -q ${LOCATION/* /}; then
if client_connection > /dev/null; then
idler_disconnect
fi
# lower fps if connecting to the idle server
if [ -z "${TEST}" ] || [ "${LOCATION/*:}" = 28201 ] \
&& dcat "${CON}" y | grep -m 1 :\ fps | grep -q fps30; then
change_client_fps 1
fi
# issue location command then wait till connected or in-game
PLAYER_COUNT=$(server_playercount)
cmd "${LOCATION}"
if [[ "${LOCATION}" != map* ]]; then
tprint "${ACCT}: querying server..." \
$(echo ${LOCATION:8} | sed "s/:.*//"),$(both_mem)
while ! client_connection > /dev/null; do
pause
if dcat "${CON}" | grep -q Bad\ challenge; then
tprint "${ACCT}: warning, bad challenge... {*}" $(both_mem)
cmd retry
fi
done
fi
if [ ! -z "${TEST}" ] && [ "${LOCATION/*:}" != 28201 ]; then
tprint "${ACCT}: loading map..." $(both_mem)
while ! client_map > /dev/null; do
pause
done
if hl2_pid textmode > /dev/null; then
cmd "exec join-${ACCT//./}"
fi
MAP=$(client_map)
else
MAP="($((PLAYER_COUNT+1))/32)"
while [ $(server_playercount) = 0 ]; do
pause
done
fi
tprint "${ACCT}: connected" ${MAP},$(both_mem)
fi
}
function idler_farm()
{
# start idle server
start_server
# start seperate x server on next display and restore the VT if needed
export DISPLAY=:$((${DISPLAY:1:1}+1)).0
if ! xserver_pid ${DISPLAY/.*} > /dev/null; then
start_xserver
if [ -z ${XVFB} ]; then
pause 8
sudo chvt $((${X_DISPLAY:1:1}+7))
sudo -k
fi
fi
# (re)login steam in low-resource, hidden mode
if steam_pid > /dev/null && ! steam_pid farm > /dev/null; then
tprint "${ACCT}: warning, restarting steam for farming... {*}" $(both_mem)
idler_logout > /dev/null
fi
idler_login low-hide || return 1
# if there is no client, start it with 1fps/nosound/noshaderapi then connect
if ! hl2_pid > /dev/null; then
tprint "${ACCT}: preparing farm tf2..." \
\$$(tf2_license),$(steam_mem) | tee "${CON}"
{
echo "fps_max \"1\""
echo "echo \"fps1\""
echo "alias _acmd1 \"exec cmd-${ACCT//./};wait 4;_acmd1\""
echo "_acmd1"
echo "_atrig"
} > "${TF}"/cfg/alias-${ACCT//./}.cfg
load "${TEXTMODE_OPTS} -noshaderapi -nosound -wavonly +voice_enable 0" \
farm || return 1
echo _acmd30\;_amove\;_mping > "${TF}"/cfg/alias-${ACCT//./}.cfg
fi
idler_connect
# start farm helper
if ! pgrep -fn sh\ idler-helper.sh > /dev/null; then
cat << EOF > idler-helper.sh
while pgrep -fn "hl2\.exe.*farm.*\+" > /dev/null; do
for HPID in \$(pgrep -f "hl2\.exe.*farm.*\+"); do
unset FOUND
for WID in \$(xwininfo -all -root -children 2> /dev/null \\
| grep "Login\|Guard.*(\"steam\.exe" | awk '{print \$1}'); do
if xwininfo -id \${WID} | grep -q "State: IsViewable"; then
FOUND=yes
xdotool windowraise \${WID}
fi
sleep 5
done
if [ -z \${FOUND} ]; then
for WID in \$(xwininfo -all -root -children 2> /dev/null \\
| grep "Team Fortress 2.*: (\"hl2\.exe" | awk '{print \$1}'); do
PID=\$(xprop -id \${WID} 2> /dev/null | grep PID \\
| awk '{print \$3}')
if [ "\${PID}" = \${HPID} ]; then
break
fi
done
xdotool windowraise \${WID} \
mousemove --window \${WID} 613 306 2> /dev/null
sleep 1
xdotool click --delay 250 --repeat 10 1 2> /dev/null
fi
done
done
EOF
screen -dmS idler-helper$ bash idler-helper.sh
tprint "started helper" @$(pgrep -fn bash\ idler-helper.sh)
fi
}
function process_usage()
{
# get cpu usage of specified process
echo "scale=1; ($(ps ux | grep -P ^.*?\ ${1}\ [0-9]*\.[0-9] | grep -v grep \
| awk {'print $3*100'})/100)/$(nproc)" | bc
}
function steam_backend()
{
# get backend connection status from specified log
if dcat "${1}" y | grep -m 1 logged\ on\ = | grep -q 0^; then
echo 0
return 1
else
echo 1
fi
}
function steam_profile_name()
{
# get steam community profile name
cat "${STEAM}"/userdata/*/config/localconfig.vdf \
| grep PersonaName | awk '{$1=""; print $0}' | sed s/\"//g
}
function idler_status()
{
# list then show system and process statistics
if [ -z ${ONCE} ]; then
ONCE=yes
CPU=$(cat /proc/cpuinfo | grep -m 1 model\ name | sed -e "s/.*: //" \
-e "s/([m-tM-T]*)//g" \
-e "s/CPU\|GHz\|Intel\|AMD \|Processor\|Dual-Core//g")
DEVNAME=$(cat pci.ids | sed -ne /^${VENDOR}/,'$'p | grep -m 1 ${DEV} \
| sed -e s/${DEV}// -e s/\\[// -e s/\\]// -e s/Chipset// -e s/Device// \
-e s/Controller// -e s/Integrated\ Graphics// -e s/Adapter// \
-e "s/SVGA\ II/VMware &/")
read Z A B C IDLE1 REST < /proc/stat
PASS1=$((A+B+C+IDLE1))
pause 1.5
read Z A B C IDLE2 REST < /proc/stat
PASS2=$((A+B+C+IDLE2))
DOMAIN=$(dnsdomainname)
if [ ! -z ${DOMAIN} ]; then
DOMAIN=.${DOMAIN}
fi
print \($(hostname)${DOMAIN}\) \
"$(echo ${CPU} + $(echo ${DEVNAME} | sed -e 's/\"\|NVIDIA \|AMD //g'))" 46
CPU=$((100*( (PASS2-PASS1) - (IDLE2-IDLE1) ) / (PASS2-PASS1) ))
RAM=$(($(cat /proc/meminfo | grep MemFree | awk '{print $2}')/1000))
RAM=${RAM}/$(($(cat /proc/meminfo | grep MemTotal | awk '{print $2}')/1000))
MIN=$(($(cat /proc/swaps | grep partition | awk '{print $4}')/1000))
MAX=$(($(cat /proc/swaps | grep partition | awk '{print $3}')/1000))
print "" "CPU(${CPU}%%) - RAM(${RAM}) - SWP($((MAX-MIN))/${MAX})" 46
NET=$(/sbin/ip route get 8.8.8.8)
LINE="$(echo ${NET} | awk '{print $5}') ($(echo ${NET} | awk '{print $7}')"
print "" "${LINE} >> $(wget -qO- icanhazip.com))" 46
LINE="wine: $(wine_version) |"
print "" "${LINE} sv: $(server_version) | cl: $(client_version)" 46
if pgrep -fn srcds_linux.*28201 > /dev/null; then
printf "%$(($(tput cols)-1))s\n" | tr ' ' -
LINE="srcds: #$(pgrep -fn srcds_linux.*28201), $(server_mem)"
LINE="${LINE}, $(server_version), @28201"
LINE="${LINE} ($(process_usage $(pgrep -f srcds_linux.*28201))%%)"
print "(server1)" "${LINE}" 46
LINE=Players\ {$(server_playercount)/32\}
LINE="${LINE} $(cat ${SCON} | grep -m 1 Steam\ ID | sed s/.*\\[/\\[/)"
print "" "${LINE:0:(-1)}" 39
print "" $(item_schema ${SCON}),\ logged_on=$(steam_backend ${SCON}) 39
fi
fi
if steam_pid > /dev/null; then
printf "%$(($(tput cols)-1))s\n" | tr ' ' -
idler_list ${1} || return 1
if steam_pid high > /dev/null; then
LINE="steam: #$(steam_pid) {high"
elif steam_pid console > /dev/null; then
LINE="steam: #$(steam_pid) {normal"
else
LINE="steam: #$(steam_pid) {low"
fi
if steam_pid hide > /dev/null; then
LINE="${LINE}-hide} $(steam_mem)"
else
LINE="${LINE}} $(steam_mem)"
fi
LINE="${LINE} ($(process_usage $(steam_pid))%%)"
print "" "${LINE} \$$(tf2_license)" 46
LINE=$(cat "${STEAM}"/config/config.vdf | grep Rate | grep -o \[0-9]*)kb
print "" "$(steam_auth_server) @${LINE} $(prefix_size)" 39
GROUP=$(cat cred/.profile-${ACCT} \
| grep -oP -m 1 "<a href.*.com/groups/.*?\"" | sed -e "s/.*\///" \
| tr -d '\"')
LINE="$(steam_profile_name)"
if [ ! -z ${GROUP} ]; then
LINE="${LINE} {${GROUP}}"
fi
print "" "$(echo ${LINE})" 39
if hl2_pid > /dev/null; then
print "" "---------------------------------------"
if hl2_pid noshaderapi > /dev/null; then
LINE="hl2: #$(hl2_pid) {noshaderapi} $(hl2_mem)"
elif hl2_pid textmode > /dev/null; then
LINE="hl2: #$(hl2_pid) {textmode} $(hl2_mem)"
else
LINE="hl2: #$(hl2_pid) {play} $(hl2_mem)"
fi
print "" "${LINE} ($(process_usage $(hl2_pid))%%)" 44
print "" $(item_schema "${CON}"),\ logged_on=$(steam_backend "${CON}") 39
unset MAP
if client_map > /dev/null; then
MAP=\ \($(client_map)\)
fi
print "" "$(client_connection)${MAP}" 39
fi
fi
}
function idler_log()
{
# page various output and config files
LOG=$(echo ${1} | tr [:upper:] [:lower:])
if [ -z ${LOG} ] || [[ ${LOG} = *all* ]]; then
LOG=cl-sv-app-boot-cloud-conn-content-ccfg-lcfg-scfg
fi
if [ -z ${VIEWED} ] && [[ "${LOG}" = *sv* ]] \
&& pgrep -f srcds_linux.*28201 > /dev/null; then
VIEWED=yes
less -K +G ${SCON} || return 1
fi
if [ -d "${STEAM}"/logs ]; then
if [[ "${LOG}" = *cl* ]] && [ -e "${CON}" ]; then
less -K +G "${CON}" || return 1
fi
for FILE in app boot cloud conn content; do
if [[ ${LOG} = *${FILE}* ]]; then
less -K +G "${STEAM}"/logs/${FILE}*_log.txt || return 1
fi
done
if [[ ${LOG} = *ccfg* ]]; then
less "${STEAM}"/config/config.vdf || return 1
fi
if [[ ${LOG} = *lcfg* ]]; then
less "${STEAM}"/userdata/*/config/localconfig.vdf || return 1
fi
if [[ ${LOG} = *scfg* ]]; then
less "${STEAM}"/userdata/*/config/sharedconfig.vdf || return 1
fi
fi
}
function idler_utility()
{
# run shell commands or execute steam urls if steam is running
if [ -d "${WINEPREFIX}" ]; then
UTILITY=regedit
if [ ! -z "${1}" ]; then
if steam_pid > /dev/null; then
UTILITY=${1//steam\:/wine_run \"'${STEAM}'\"\/steam.exe steam\:}
elif echo ${1} | grep -q steam\:; then
tprint "${ACCT}: error, steam not running {"'!}'
return 1
fi
fi
tprint "${ACCT}: running utility..."
echo "${UTILITY}" > "${WINEPREFIX}"/.utility.sh
source "${WINEPREFIX}"/.utility.sh > "${WINEPREFIX}"/.utility.log 2>&1
fi
}
function idler_sleep()
{
# wait for a period of time to elapse or until the user hits enter 3 times
if steam_pid > /dev/null; then
if [[ "${1}" = [0-9]*[hmdsHMDS]* ]]; then
TIME=$(echo ${1} | tr [:upper:] [:lower:] \
| sed 's/\([0-9]*[hmds]\).*/\1/')
elif [[ "${1}" = *[0-9]* ]]; then
TIME=$(echo ${1} | sed -e "s/[a-zA-Z]*//g")s
else
TIME=1m
fi
if [ ${TIME:(-1)} = d ]; then
SECONDS=$((86400*${TIME:0:(-1)}))
elif [ ${TIME:(-1)} = h ]; then
SECONDS=$((3600*${TIME:0:(-1)}))
elif [ ${TIME:(-1)} = m ]; then
SECONDS=$((60*${TIME:0:(-1)}))
else
SECONDS=${TIME:0:(-1)}
fi
tprint "sleeping..." ${TIME}
COUNT=0
for i in $(seq 1 ${SECONDS}); do
if read -t 1 -s; then
let COUNT+=1
fi
if [ ${COUNT} = 3 ]; then
break
fi
done
fi
}
function idler_usage()
{
# print usage text on an invalid command
echo -e "\nUsage: pdl-idler.sh ACTION1{,/%}ACTION2=arg^x... {acct1 acct2 ...}"
echo -e "\nACTION\t\t DESCRIPTION {parameters}\n"
echo -e "install\t\t start X, prep wine, then install steam launcher"
echo -e "login{=mode}\t install then login {hide-low|high}"
echo -e "create\t\t create a new account then login"
echo -e "online\t\t if logged in, sign on to friends"
echo -e "offline\t\t if online, sign out of friends"
echo -e "enter{=id}\t join public chatroom {(103582791432273268)}"
echo -e "exit\t\t leave public chatroom then restore prior friends status"
echo -e "friend{=accounts} perform/queue friend invites {(cmdline)}"
echo -e "play{=mode}\t login then start tf2 {hide-low|high}"
echo -e "start{=mode}\t login then start tf2 in textmode {hide-low|high}"
echo -e "command{=cmd}\t if tf2 is running, execute command {(prompts)}"
echo -e "connect{=place}\t start then join game, host map, or idle {(idle)}"
echo -e "farm\t\t start lite steam/tf2, extra X, and helper, then idle"
echo -e "join{=team-class} if in-game, select team/class {(auto-auto)}"
echo -e "spectate\t if in-game, join spectators"
echo -e "disconnect\t if in-game, disconnect from the server"
echo -e "reconnect{=place} disconnect then connect {(use idle server)}"
echo -e "stop{=kill}\t if running, quit/kill client {yes}"
echo -e "restart{=kill}\t stop then start {yes}"
echo -e "logout{=kill}\t stop then close/kill steam {yes}"
echo -e "relogin{=mode}\t logout then login {hide-low|high}"
printf "website{=web}\t browse "
echo -e "{(tf2b)|tf2items|backpack|willitcraft|stm_com|stm_inv}"
echo -e "list{=ref}\t list account information {no|yes}"
echo -e "backpack{=ref}\t detail backpack contents {no|yes}"
echo -e "status{=ref}\t show system and process statistics {no|yes}"
printf "log{=files}\t page "
echo -e "{(all)-cl-sv-app-boot-cloud-conn-content-ccfg-lcfg-scfg}"
echo -e "utility{=utils}\t execute shell commands and steam urls {(regedit)}"
echo -e "sleep{=time}\t wait awhile or until enter is thrice pressed {(1m)}"
echo -e "uninstall{=kill} logout then remove wineprefix {yes}"
echo -e "reinstall{=kill} uninstall then install {yes}"
echo -e "delete{=kill}\t uninstall then remove credential backups {yes}"
echo
}
# remove dead screen sessions
for LINE in $(screen -wipe idler- | grep -o \\-.*Removed | awk '{print $1}'); do
tprint "removed dead ${LINE:1:${#LINE}-2} screen session"
done
# kill defunct processes
for HPID in $(pgrep -fx hl2\.exe); do
tprint "killing defunct hl2 process..." ${HPID}
kill -9 ${HPID}
done
for SPID in $(pgrep -fx steam\.exe); do
tprint "killing defunct steam process..." ${SPID}
kill -9 ${SPID}
done
# backup stray connection cache keys created by this machine
for FILE in cred/.host-*; do
if [ -e ${FILE} ]; then
ACCT=${FILE:11}
if [ $(cat ${FILE}) = $(hostname) ] && ! steam_pid > /dev/null; then
STEAM="${DIR}"/wine-${ACCT}/drive_c/Program\ Files/Steam
if [ $(steam_connect_hash y) != $(steam_connect_hash) ]; then
tprint "updated cred backup for ${ACCT}" \
$(steam_connect_hash y)\>$(steam_connect_hash)
backup_credentials
fi
rm ${FILE}
fi
fi
done
# check/alter system permissions
sudo -k
if [ -z ${XVFB} ]; then
for CMD in $(which chvt) ${CMD}; do
if [[ "$(sudo -n ${CMD} 2>&1 >/dev/null)" = "sudo: a password"* ]]; then
SUDO=${SUDO}${CMD}\
fi
done
elif [[ "$(sudo -n Xvfb -pdl 2>&1 >/dev/null)" = "sudo: a password"* ]]; then
SUDO=${SUDO}$(which Xvfb)\
fi
if [ -e /etc/X11/Xwrapper.config ] \
&& ! grep -q "allowed_users=anybody" /etc/X11/Xwrapper.config; then
XWRAPPER=yes
fi
if [ ! -z "${SUDO}${XWRAPPER}" ]; then
printf "[$(date +%H:%M:%S)] input sudo password: "
fi
if [ ! -z ${SUDO} ]; then
for CMD in ${SUDO}; do
echo "$(whoami) ALL=NOPASSWD: ${CMD}" | sudo -p "" tee -a /etc/sudoers \
> /dev/null || exit 1
done
fi
if [ ! -z ${XWRAPPER} ]; then
sudo -p "" sed -i -e "s/allowed_users=.*/allowed_users=anybody/" \
/etc/X11/Xwrapper.config
fi
sudo -k
# set necessary environment variables
DLLS=adminserver.dll,audio.dll,avcodec-53.dll,avformat-53.dll,avutil-51.dll
DLLS=${DLLS},binkw32.dll,bugreporter.dll,bugreporter_public.dll,commedit.dll
DLLS=${DLLS},crashhandler.dll,cserhelper.dll,datamodel.dll,dbghelp.dll
DLLS=${DLLS},dwrite.dll,filesystemopendialog.dll,haptics.dll,hammer_dll.dll
DLLS=${DLLS},headtrack_oculus.dll,icudt42.dll,msi.dll,mss.dll,pet.dll
DLLS=${DLLS},plugplay.exe,services.exe,sixense.dll,sixense_utils.dll
DLLS=${DLLS},steamservice.dll,steamservice.exe,valve_avi.dll,valve_bink.dll
DLLS=${DLLS},vaudio_miles.dll,video_bink.dll,video_quicktime.dll,vmt.dll
DLLS=${DLLS},winedbg.exe,winedevice.exe,winemenubuilder.exe,explorer.exe
DLLS=${DLLS},icudt.dll,libcef.dll,chromehtml.dll,appoverlay.dll
DLLS=${DLLS},gameoverlayrenderer.dll,gameoverlayui.dll
if [ -z ${X_DISPLAY} ]; then
X_DISPLAY=:0.0
fi
SCON=srcds/tf/console.log
TF=Team\ Fortress\ 2/tf
export WINEARCH=win32
export WINEDEBUG=-all
export WINEDLLOVERRIDES=${DLLS}=d
# deduce graphics device and vendor pci ids
if [ -z $(find . -maxdepth 1 -name pci.ids -mtime -28) ]; then
tprint "updating pci id list..." v2.2
download http://pciids.sourceforge.net/v2.2/pci.ids
touch pci.ids
fi
if [ -e /usr/bin/lspci ]; then
LSPCI=/usr/bin/lspci
else
LSPCI=/sbin/lspci
fi
VENDOR=10de
if lsmod | grep -q "^nvidia "; then
DEV=$(cat /proc/bus/pci/devices | grep nvidia | awk '{print $2}' | cut -c 5-8)
elif lsmod | grep -q "^nouveau "; then
DEV=$(cat /proc/bus/pci/devices | grep nouveau | awk '{print $2}' \
| cut -c 5-8)
elif lsmod | grep -q "^i915 "; then
VENDOR=8086
DEV=$(cat /proc/bus/pci/devices | grep i915 | awk '{print $2}' | cut -c 5-8)
elif ${LSPCI} | grep VGA | grep -q "VirtualBox"; then
VENDOR=80ee
DEV=beef
elif ${LSPCI} | grep VGA | grep -q "VMware"; then
VENDOR=15ad
DEV=0405
else
VENDOR=1002
if lsmod | grep -q "^fglrx "; then
DEV=$(cat /proc/bus/pci/devices | grep fglrx | awk '{print $2}' \
| cut -c 5-8)
else
DEV=$(cat /proc/bus/pci/devices | grep ati | awk '{print $2}' | cut -c 5-8)
fi
fi
# select target accounts
if [ -e pdl-idler.conf ]; then
source pdl-idler.conf 2> /dev/null
fi
INPUT="$* "
INPUT="${INPUT#* }"
if [ ! -z "${ACCOUNTS}" ]; then
ACCOUNTS_ARRAY=(null ${ACCOUNTS})
for BLOCK in $(echo ${INPUT} | tr ' ' '\n' | grep \:[0-9]*); do
unset MINUS
if [ ${BLOCK:0:1} = - ]; then
MINUS=-
BLOCK=${BLOCK:1}
fi
unset ACCTS
for ACCT in ${ACCOUNT_BLOCKS[${BLOCK:1}]}; do
ACCTS="${ACCTS} ${MINUS}${ACCT}"
done
INPUT=${INPUT/${MINUS}${BLOCK}/${ACCTS}}
done
for INDEX in $(echo ${INPUT} | tr ' ' '\n' | grep +[0-9]*); do
unset MINUS
if [ ${INDEX:0:1} = - ]; then
MINUS=-
fi
INPUT="${INPUT/${INDEX}/${MINUS}${ACCOUNTS_ARRAY[${INDEX:1}]}}"
done
fi
INPUT=\ ${INPUT}\
for MINUS in $(echo ${INPUT} | tr ' ' '\n' | grep \\-.*); do
INPUT=${INPUT// ${MINUS:1} / }
done
if echo \ ${INPUT} | grep -oiq -m 1 " [a-z0-9]"; then
unset ACCOUNTS
for ACCT in ${INPUT}; do
if [ ${ACCT:0:1} != - ]; then
ACCOUNTS="${ACCOUNTS} ${ACCT}"
fi
done
else
if [ -z "${ACCOUNTS}" ]; then
for ACCT in wine-*; do
if [ -d ${ACCT} ]; then
ACCOUNTS="${ACCOUNTS} ${ACCT/wine-/} "
fi
done
for ACCT in cred/cred-*; do
if [ -e ${ACCT} ]; then
ACCT=$(echo ${ACCT:10} | grep -o .*_)
if [[ ${ACCOUNTS} != *${ACCT:0:(-1)}\ * ]]; then
ACCOUNTS="${ACCOUNTS} ${ACCT:0:(-1)} "
fi
fi
done
fi
ACCOUNTS=" ${ACCOUNTS} "
for MINUS in $(echo ${INPUT} | tr ' ' '\n' | grep \\-.*); do
ACCOUNTS=${ACCOUNTS// ${MINUS:1} / }
done
fi
# run action sets with specified accounts
if [ -z "$(echo ${ACCOUNTS})" ]; then
tprint "error, no initiated or specified accounts {"'!}'
else
if [ -z "${1}" ]; then
idler_usage
tprint "error, no supplied actions {"'!}'
elif [[ ${1} = *help* ]] || [[ ${1} = *usage* ]]; then
idler_usage
else
for ACTION in $(echo ${1} | tr '[%,]' '\n' | tr [:upper:] [:lower:]); do
if ! declare -f | grep -q ^idler_$(echo ${ACTION/=*} \
| sed s/^re//)\ ; then
idler_usage
tprint "error, invalid action '${ACTION/=*}' {"'!}'
INVALID=yes
break
fi
done
if [ -z ${INVALID} ]; then
for ACTIONS in $(echo ${1} | tr ',' '\n'); do
for ACCT in ${ACCOUNTS}; do
export DISPLAY=${X_DISPLAY}
set_account ${ACCT}
for ACTION in $(echo ${ACTIONS} | tr '%' '\n'); do
if [[ ${ACTION} = *=* ]]; then
ARG=${ACTION/*=}
else
unset ARG
fi
case $(echo ${ACTION/=*} | tr [:upper:] [:lower:]) in
install )
idler_install
;;
login )
idler_login ${ARG}
;;
create )
idler_create || break
;;
online )
idler_online
;;
offline )
idler_offline
;;
enter )
idler_enter ${ARG} || break
;;
exit )
idler_exit
;;
friend )
idler_friend ${ARG}
;;
play )
idler_play ${ARG}
;;
start )
idler_start ${ARG}
;;
command )
idler_command "${ARG//^/ }"
;;
connect )
idler_connect ${ARG}
;;
farm )
idler_farm
;;
join )
idler_join ${ARG}
;;
spectate )
idler_spectate
;;
disconnect )
idler_disconnect
;;
reconnect )
idler_disconnect yes
idler_connect ${ARG}
;;
stop )
idler_stop ${ARG}
;;
restart )
idler_stop ${ARG}
idler_start
;;
logout )
idler_logout ${ARG}
;;
relogin )
idler_logout
idler_login ${ARG}
;;
website )
idler_website ${ARG}
;;
list )
idler_list ${ARG}
;;
backpack )
idler_backpack ${ARG}
;;
status )
idler_status ${ARG}
;;
log )
idler_log ${ARG} || break 2
;;
uninstall )
idler_uninstall ${ARG}
;;
reinstall )
idler_uninstall ${ARG}
idler_install
;;
delete )
idler_delete ${ARG}
;;
utility )
idler_utility "${ARG//^/ }"
;;
sleep )
idler_sleep ${ARG}
if [[ ${ACTIONS} != *%* ]] && [ ! -z ${COUNT} ]; then
break 2
fi
;;
esac
done
done
done
fi
fi
fi
# respond to queued friend invites for active accounts
unset FRIEND_WGET
for FILE in cred/.friend-*; do
if [ -e ${FILE} ]; then
unset SENT
ACCT=${FILE:13}
if steam_pid > /dev/null; then
for ADD in $(cat ${FILE}); do
TIME=$(cat cred/.friend-${ADD/\#*} | grep ^${ACCT}\#)
if (( ${ADD/*\#} <= ${TIME/*\#} )); then
if ! is_friend ${ADD/\#*}; then
if [ -z ${SENT} ]; then
SENT=yes
tprint "${ACCT}: sending invite(s)..." $(steam_mem)
fi
invite_friend ${ADD/\#*} ${ACCT}
sed -i -e "s/${ADD}/${ADD/\#*}#$(($(date +%s)+1))/" \
cred/.friend-${ACCT}
else
sed -i -e "/^${ADD}$/d" cred/.friend-${ACCT}
sed -i -e "/^${ACCT}#[0-9]*$/d" cred/.friend-${ADD/\#*}
fi
fi
done
fi
fi
done
if [ -e ${FILE} ]; then
find cred/ -maxdepth 1 -name .friend-* -empty -exec rm {} \;
fi
# if no clients are connected, stop the server
if pgrep -f srcds_linux.*28201 > /dev/null \
&& [ $(server_playercount) = 0 ]; then
tprint "stopped server" $(server_version),$(server_mem)
kill -9 $(pgrep -f srcds_linux.*28201)
rm ${HOME}/Steam
fi
function stop_xserver()
{
# stop the regular or farming X server and x11vnc
unset TYPE X11VNC
DISPLAY=${X_DISPLAY}
SERVER=X
if [ "${1}" = farm ]; then
DISPLAY=:$((${X_DISPLAY:1:1}+1)).0
TYPE=farm,
if [ ! -z ${XVFB} ]; then
SERVER=Xvfb
fi
fi
TYPE=${TYPE}${DISPLAY},
if pgrep -fn x11vnc\ -display\ ${DISPLAY/.*} > /dev/null; then
X11VNC=" + x11vnc"
kill $(pgrep -fn x11vnc\ -display\ ${DISPLAY/.*})
fi
tprint "stopping ${SERVER}${X11VNC}..." ${TYPE}@$(xserver_pid ${DISPLAY})
while pgrep -n wineserver.*${TYPE:0:(-1)} > /dev/null; do
pause
done
kill -9 $(xserver_pid ${DISPLAY/.*})
rm x${DISPLAY:1:1}.pid
}
# if there are no steam farm processes, undo client ui modifications
if ! pgrep -fn steam\.exe\ farm > /dev/null; then
rm -fr "${TF}"/custom/pdl
# if there are no steam processes, stop x server(s)
if xserver_pid :$((${X_DISPLAY:1:1}+1)) > /dev/null; then
stop_xserver farm
fi
fi
if ! pgrep -fn steam\.exe\ main > /dev/null && [ -e x${X_DISPLAY:1:1}.pid ] \
&& [ "$(xserver_pid ${X_DISPLAY/.*})" = $(cat x${X_DISPLAY:1:1}.pid) ]; then
stop_xserver
fi
# if there are no hl2 processes, start power management
if ! pgrep -fn hl2\.exe.*28101 > /dev/null; then
if pgrep -x gnome-session > /dev/null \
&& ! pgrep -f gnome-power-manager > /dev/null; then
gnome-power-manager > /dev/null 2>&1
tprint "started gnome-power-manager" @$(pgrep -f gnome-power-manager)
elif pgrep -x xfce4-session > /dev/null \
&& ! pgrep -f xfce4-power-manager > /dev/null; then
xfce4-power-manager > /dev/null 2>&1
tprint "started xfce4-power-manager" @$(pgrep -f xfce4-power-manager)
fi
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment