Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /********************************************************************************************/
- /*Installer for iPhoneOS 2/3.x Copyright (c) 2012 Ethan Laur (phyrrus9) <phyrrus9@gmail.com>*/
- /*This application is open source, meaning that you may do whatever the hell you want with */
- /* it. I do this mainly because I am too goddamn lazy to ACTUALLY enforce copyright on any */
- /* of this shit ... so have at it, but please leave my original copyright in any and all of */
- /* the files included with the package you recieved either by web or package from cydia stor*/
- /*Project created February 6th 2012 at 12:28 PM. what a lonely monday morning bored as hell */
- /********************************************************************************************/
- /*Additional copyrights and special thanks to: the private dev team, @iAmJake648 */
- /********************************************************************************************/
- #include <iostream>
- #include <stdlib.h>
- #include <fstream>
- #include <sstream>
- #include <string.h>
- #define BUILD "0.1-1.1"
- using namespace std;
- string trash = "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz";
- string HOST = "abcdefghijklmnopqrstuvwxyz";
- string CACHE = "abcdefghijklmnopqrstuvwxyz";
- string IOS_VER = "abcdefghijklmnopqrstuvwxyz";
- string FILT = "abcdefghijklmnopqrstuvwxyz";
- void output(string type, string out) //this allows me to make it look neater
- {
- cout << "<" << type << ">[" << out << "]" << endl;
- }
- int init()
- {
- cout << "Welcome to commander!" << endl << "Copyright 2012 phyrrus9/private dev team" << endl;
- ifstream infile("/var/db/installer.conf");
- if (infile.good())
- {
- output("sys", "LOADING CONFIG");
- infile >> HOST;
- infile >> CACHE;
- infile >> IOS_VER;
- infile >> FILT;
- output("host", HOST);
- output("cache", CACHE);
- output("iOS", IOS_VER);
- output("filter", FILT);
- infile.close(); //oops! I can see LOTS of corruption nightmares again
- return 0;
- }
- else
- return 1;
- }
- void search(string package)
- {
- trash = "cat /var/db/installer.cache | grep ";
- trash+=package + " ::" + FILT + "::";
- system(trash.c_str());
- }
- void download(string package)
- {
- trash = "wget " + HOST + "/" + IOS_VER + "/" + package + ".zip -O /var/tmp/installer.zip -o /var/tmp/installer.log";
- string URL = HOST + package + ".zip";
- system(trash.c_str());
- }
- void install(string package)
- {
- output("install", "BEGIN EXTRACT");
- system("unzip -o /var/tmp/installer.zip -d /");
- output("install", "RUN EXTRACT SCRIPT");
- trash = "sh /var/scripts/installer/" + package + "-extract.sh";
- system(trash.c_str());
- output("install", "CLEANING UP");
- system("rm /var/tmp/installer.zip");
- }
- void remove(string package)
- {
- trash = "sh /var/scripts/installer/" + package + "-remove.sh";
- system(trash.c_str());
- }
- void usage()
- {
- /*I am not using output() here because it would overflow the screen*/
- cout << "Installer.bin build " << BUILD << endl;
- cout << "Usage:" << endl;
- cout << ".. search xxx :search for a package" << endl;
- cout << ".. install xxx :install a package" << endl;
- cout << ".. remove xxx :remove a package" << endl;
- cout << ".. config xxx :rerun config script" << endl;
- cout << ".. upgrade :upgrade commander" << endl;
- cout << ".. update :updates the caches" << endl;
- cout << ".. *broken* :Ignore me .. just a placeholder" << endl;
- cout << ".. yyy :shows this dialog" << endl;
- }
- int main(int argc, char* argv[])
- {
- int init_err = 0;
- string parameter, filter = "empty";
- if (argc == 0)
- return -1;
- if (argc > 1)
- parameter = argv[1];
- if (argc > 2)
- filter = argv[3];
- string package_in;
- if (argc > 2)
- package_in = argv[2];
- init_err = init();
- ofstream write("/var/tmp/installer.conf");
- if (init_err == 1)
- {
- output("ERR", "UNABLE TO LOAD CONFIG");
- return -1;
- }
- if (init_err == 0)
- {
- if (parameter == "search")
- {
- trash = "Searching database for " + package_in;
- output("main", trash);
- search(package_in);
- output("main", "Search complete");
- }
- else if (parameter == "install")
- {
- trash = "Attempting to install " + package_in;
- output("main", trash);
- download(package_in);
- install(package_in);
- output("main", "Install complete");
- }
- else if (parameter == "remove")
- {
- trash = "Removing package " + package_in;
- output("main", trash);
- remove(package_in);
- output("main", "Package removal compelte");
- }
- else if (parameter == "config")
- {
- output("install", "Running config");
- trash = "sh /var/scripts/installer/" + package_in + "-extract.sh";
- system(trash.c_str());
- }
- else if (parameter == "upgrade")
- {
- output("main", "Downloading");
- download("phyrrus9.installer");
- output("main", "Transferring to install");
- install("phyrrus9.installer");
- return 9001;
- }
- else if (parameter == "update")
- {
- output("sys", "DOWNLOADING CACHE");
- trash = "wget " + CACHE + " -O /var/tmp/installer.zip -o /var/tmp/installer.log";
- system(trash.c_str());
- output("sys", "EXTRACT CACHE");
- system("unzip -o /var/tmp/installer.zip -d /var/db");
- output("sys", "cLEANING UP");
- system("rm /var/tmp/installer.zip");
- output("sys", "COMPLETED!");
- }
- else if (filter != "empty")
- {
- trash = "Setting the filter to " + filter;
- output("filter", trash);
- FILT = filter;
- output("filter", "Writing to temporary file");
- write << HOST << endl << CACHE << endl << IOS_VER << endl << FILT;
- output("filter", "Transferring file");
- system("mv /var/tmp/installer.cache /var/db/installer.cache");
- output("filter", "Settings applied!\nTo change back just set filter to all");
- return 0;
- }
- else
- {
- output("ERR", "NO PARAMETERS");
- usage();
- }
- }
- else
- {
- output("ERR", "UNKNOWN!");
- return -1;
- }
- return 0;
- }
Add Comment
Please, Sign In to add comment