public static void InitDB(DeployeSetting setting, DB database)
        {
            Console.WriteLine("Creating database...");
            string arg = string.Join(" ", " -u", database.user, "-e", "\"CREATE DATABASE " + database.db + "\"");

            ProcessManager.ProcessGenerator(setting.MYSQL, arg, setting);
            Console.WriteLine("Succesfully create database.");
        }
示例#2
0
        public static Boolean MakeEnv(MYSQLHandler.DB db, DeployeSetting setting)
        {
            try
            {
                Console.WriteLine("Downloading environment...");
                string urlAddress = "https://raw.githubusercontent.com/laravel/laravel/master/.env.example";

                HttpWebRequest  request  = (HttpWebRequest)WebRequest.Create(urlAddress);
                HttpWebResponse response = (HttpWebResponse)request.GetResponse();

                if (response.StatusCode == HttpStatusCode.OK)
                {
                    Stream       receiveStream = response.GetResponseStream();
                    StreamReader readStream    = null;

                    if (String.IsNullOrWhiteSpace(response.CharacterSet))
                    {
                        readStream = new StreamReader(receiveStream);
                    }
                    else
                    {
                        readStream = new StreamReader(receiveStream, Encoding.GetEncoding(response.CharacterSet));
                    }

                    string data = readStream.ReadToEnd();

                    response.Close();
                    readStream.Close();

                    string envPath = Path.GetDirectoryName(setting.PROJECT) + @"\.env";
                    //delete env if exists
                    if (File.Exists(envPath))
                    {
                        File.Delete(envPath);
                    }
                    using (StreamWriter sw = File.CreateText(envPath))
                    {
                        sw.WriteLine(data);
                    }
                    string text = File.ReadAllText(envPath);
                    text = text.Replace("DB_DATABASE=laravel", "DB_DATABASE=" + db.db);
                    text = text.Replace("DB_USERNAME=root", "DB_USERNAME="******"Succesfully created environment file.");
                }
            }
            catch (WebException e)
            {
                Console.WriteLine("Failed to connect, please check your connection.");
                return(false);
            }
            return(true);
        }
示例#3
0
        public static void ProcessGenerator(string filename, string arg, DeployeSetting setting)
        {
            psInfo = new ProcessStartInfo();
            psInfo.UseShellExecute        = false;
            psInfo.RedirectStandardError  = true;
            psInfo.RedirectStandardOutput = true;
            psInfo.RedirectStandardInput  = true;
            psInfo.WindowStyle            = ProcessWindowStyle.Hidden;
            psInfo.CreateNoWindow         = true;
            psInfo.FileName = filename;
            if (setting.PROJECT != null)
            {
                psInfo.WorkingDirectory = Path.GetDirectoryName(setting.PROJECT);
            }

            psInfo.Arguments = arg;
            var process = Process.Start(psInfo);
            var err     = "";

            process.OutputDataReceived += (o, e) =>
            {
                if (e.Data == null)
                {
                    err = e.Data;
                }
                else
                {
                    Console.WriteLine(e.Data);
                }
            };
            process.BeginOutputReadLine();

            process.ErrorDataReceived += (o, e) =>
            {
                if (e.Data == null)
                {
                    err = e.Data;
                }
                else
                {
                    Console.WriteLine(e.Data);
                }
            };

            process.BeginErrorReadLine();
            process.WaitForExit();
        }
示例#4
0
        public static void KillAll(string pname, DeployeSetting setting)
        {
            string clear2 = "/f /im php.exe";

            ProcessGenerator("taskkill", clear2, setting);
        }