14 #include "wget_agent.h"
18 char BuildVersion[]=
"wget_agent build version: " VERSION_S
" r(" COMMIT_HASH_S
").\n";
96 int main (
int argc,
char *argv[])
100 char *TempFileDir=NULL;
105 char *agent_desc =
"Network downloader. Uses wget(1).";
116 char agent_rev[STRMAX];
122 while((c = getopt(argc,argv,
"d:Gg:ik:A:R:l:Cc:Vvh")) != -1)
132 SG = getgrnam(optarg);
174 if (argc - optind > 1)
188 gcry_check_version(NULL);
189 gcry_control (GCRYCTL_DISABLE_SECMEM, 0);
190 gcry_control (GCRYCTL_INITIALIZATION_FINISHED, 0);
192 COMMIT_HASH =
fo_sysconfig(
"wget_agent",
"COMMIT_HASH");
194 sprintf(agent_rev,
"%s.%s", VERSION, COMMIT_HASH);
202 for(arg=optind; arg < argc; arg++)
208 LOG_VERBOSE0(
"Command-line: %s",
GlobalURL);
212 LOG_VERBOSE0(
"It's a URL");
215 LOG_FATAL(
"Download of %s failed.",
GlobalURL);
233 if (0 == CmdlineFlag)
249 LOG_ERROR(
"You have no update permissions on upload %d",
upload_pk);
253 char TempDir[STRMAX];
254 memset(TempDir,
'\0',STRMAX);
255 snprintf(TempDir, STRMAX-1,
"%s/wget", TempFileDir);
256 struct stat Status = {};
267 LOG_FATAL(
"upload %ld File retrieval failed: uploadpk=%ld tempfile=%s URL=%s Type=%s",
276 LOG_FATAL(
"Failed to archive. GlobalURL, GlobalTempFile, TempFileDir are: %s, %s, %s, "
292 LOG_FATAL(
"upload %ld File retrieval failed: uploadpk=%ld tempfile=%s URL=%s",
PGconn * pgConn
Database connection.
Usage()
Print Usage statement.
FUNCTION int GetUploadPerm(PGconn *pgConn, long UploadPk, int user_pk)
Get users permission to this upload.
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.
#define PERM_WRITE
Read-Write permission.
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...
char * fo_sysconfig(const char *sectionname, const char *variablename)
gets a system configuration variable from the configuration data.
int agent_verbose
Common verbose flags for the agents, this is used so that the scheduler can change the verbose level ...
int fo_scheduler_userID()
Gets the id of the user that created the job that the agent is running.
char * fo_scheduler_current()
Get the last read string from the scheduler.
char * fo_scheduler_next()
Get the next data to process from the scheduler.
void fo_scheduler_connect(int *argc, char **argv, PGconn **db_conn)
Establish a connection between an agent and the scheduler.
int main(int argc, char *argv[])
main function for the pkgagent
void SafeExit(int rc)
Close scheduler and database connections, then exit.
char * PathCheck(char *DirPath)
Check if path contains a "%U" or "%H". If so, substitute a unique ID for U.
char GlobalParam[STRMAX]
Additional parameters.
char GlobalType[STRMAX]
Type of download (FILE/version control)
int GetURL(char *TempFile, char *URL, char *TempFileDir)
Do the wget.
char GlobalURL[URLMAX]
URL to download.
int GetVersionControl()
Get source code from version control system.
void SetEnv(char *S, char *TempFileDir)
Convert input pairs into globals.
long GlobalUploadKey
Input for this system.
gid_t ForceGroup
Set to group id to be used for download files.
char GlobalTempFile[STRMAX]
Temp file to be used.
void DBLoadGold()
Insert a file into the database and repository.
void GetProxy()
Get proxy from fossology.conf.
int GlobalImportGold
Set to 0 to not store file in gold repository.
int Archivefs(char *Path, char *TempFile, char *TempFileDir, struct stat Status)
Copy downloaded files to temporary directory.