26 #include "wget_agent.h" 29 char BuildVersion[]=
"wget_agent build version: " VERSION_S
" r(" COMMIT_HASH_S
").\n";
107 int main (
int argc,
char *argv[])
111 char *TempFileDir=NULL;
116 char *agent_desc =
"Network downloader. Uses wget(1).";
127 char agent_rev[STRMAX];
133 while((c = getopt(argc,argv,
"d:Gg:ik:A:R:l:Cc:Vvh")) != -1)
143 SG = getgrnam(optarg);
185 if (argc - optind > 1)
198 COMMIT_HASH =
fo_sysconfig(
"wget_agent",
"COMMIT_HASH");
200 sprintf(agent_rev,
"%s.%s", VERSION, COMMIT_HASH);
208 for(arg=optind; arg < argc; arg++)
214 LOG_VERBOSE0(
"Command-line: %s",
GlobalURL);
218 LOG_VERBOSE0(
"It's a URL");
221 LOG_FATAL(
"Download of %s failed.",
GlobalURL);
239 if (0 == CmdlineFlag)
255 LOG_ERROR(
"You have no update permissions on upload %d", upload_pk);
259 char TempDir[STRMAX];
260 memset(TempDir,
'\0',STRMAX);
261 snprintf(TempDir, STRMAX-1,
"%s/wget", TempFileDir);
262 struct stat Status = {};
273 LOG_FATAL(
"upload %ld File retrieval failed: uploadpk=%ld tempfile=%s URL=%s Type=%s",
282 LOG_FATAL(
"Failed to archive. GlobalURL, GlobalTempFile, TempFileDir are: %s, %s, %s, " 298 LOG_FATAL(
"upload %ld File retrieval failed: uploadpk=%ld tempfile=%s URL=%s",
char * PathCheck(char *DirPath)
Check if path contains a "%U" or "%H". If so, substitute a unique ID for U.
gid_t ForceGroup
Set to group id to be used for download files.
int Archivefs(char *Path, char *TempFile, char *TempFileDir, struct stat Status)
Copy downloaded files to temporary directory.
PGconn * pgConn
Database connection.
long GlobalUploadKey
Input for this system.
char GlobalParam[STRMAX]
Additional parameters.
char * fo_scheduler_current()
Get the last read string from the scheduler.
int GetURL(char *TempFile, char *URL, char *TempFileDir)
Do the wget.
void fo_scheduler_connect(int *argc, char **argv, PGconn **db_conn)
Establish a connection between an agent and the scheduler.
char GlobalType[STRMAX]
Type of download (FILE/version control)
int agent_verbose
Common verbose flags for the agents, this is used so that the scheduler can change the verbose level ...
void GetProxy()
Get proxy from fossology.conf.
char GlobalURL[URLMAX]
URL to download.
void SetEnv(char *S, char *TempFileDir)
Convert input pairs into globals.
void DBLoadGold()
Insert a file into the database and repository.
char GlobalTempFile[STRMAX]
Temp file to be used.
int fo_scheduler_userID()
Gets the id of the user that created the job that the agent is running.
Usage()
Print Usage statement.
int GetVersionControl()
Get source code from version control system.
int main(int argc, char *argv[])
main function for the pkgagent
FUNCTION int fo_GetAgentKey(PGconn *pgConn, const char *agent_name, long Upload_pk, const char *rev, const char *agent_desc)
Get the latest enabled agent key (agent_pk) from the database.
char * fo_scheduler_next()
Get the next data to process from the scheduler.
int GlobalImportGold
Set to 0 to not store file in gold repository.
void fo_scheduler_heart(int i)
This function must be called by agents to let the scheduler know they are alive and how many items th...
FUNCTION int GetUploadPerm(PGconn *pgConn, long UploadPk, int user_pk)
Get users permission to this upload.
void SafeExit(int rc)
Close scheduler and database connections, then exit.
char * fo_sysconfig(const char *sectionname, const char *variablename)
gets a system configuration variable from the configuration data.
#define PERM_WRITE
Read-Write permission.