Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on May 13, 2022. It is now read-only.
/sshdeployPublic archive

Commitd62c5bd

Browse files
authored
Merge pull request#20 from unosquare/Issue18-AutomaticallyChmodExecutable
Automatically chmod execute permission
2 parents73f0973 +60070a2 commitd62c5bd

File tree

6 files changed

+76
-50
lines changed

6 files changed

+76
-50
lines changed

‎README.md‎

Lines changed: 32 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -100,23 +100,24 @@ If your project happens to target multiple runtimes, i.e. `win-x64` and `linux-a
100100
###XML Tags
101101
Heres a complete list of arguments with their corresponding XML tag.
102102

103-
| Args| XML Tag|
104-
| :--------------:| :------------------:|
105-
| -m,--monitor|`<SshDeployMonitorFile>`|
106-
| -f,--framework|`<TargetFramework>`|
107-
| -r,--runtime|`<RuntimeIdentifier>`|
108-
| -s, --source|`<SshDeploySourcePath>`|
109-
| -t,--target|`<SshDeployTargetPath>`|
110-
| --pre|`<SshDeployPreCommand>`|
111-
| --post|`<SshDeployPostCommand>`|
112-
| --clean|`<SshDeployClean/>`|
113-
| --exclude|`<SshDeployExclude>`|
114-
| -v,--verbose|`<SshDeployVerbose/>`|
115-
| -h,--host|`<SshDeployHost>`|
116-
| -p,--port|`<SshDeployPort>`|
117-
| -u,--username|`<SshDeployUsername>`|
118-
| -w,--password|`<SshDeployPassword>`|
119-
| -l,--legacy|`<SshDeployLegacy/>`|
103+
| Args| XML Tag|
104+
| :--------------| :----------------------------:|
105+
| -m,--monitor|`<SshDeployMonitorFile>`|
106+
| -f,--framework|`<TargetFramework>`|
107+
| -r,--runtime|`<RuntimeIdentifier>`|
108+
| -s, --source|`<SshDeploySourcePath>`|
109+
| -t,--target|`<SshDeployTargetPath>`|
110+
| --pre|`<SshDeployPreCommand>`|
111+
| --post|`<SshDeployPostCommand>`|
112+
| --clean|`<SshDeployClean/>`|
113+
| --exclude|`<SshDeployExclude>`|
114+
| -v,--verbose|`<SshDeployVerbose/>`|
115+
| -h,--host|`<SshDeployHost>`|
116+
| -p,--port|`<SshDeployPort>`|
117+
| -u,--username|`<SshDeployUsername>`|
118+
| -w,--password|`<SshDeployPassword>`|
119+
| -l,--legacy|`<SshDeployLegacy/>`|
120+
| -x, --execute|`<SshDeployExecutePermission>`|
120121

121122
###Old school way
122123
####Push
@@ -221,20 +222,20 @@ Ground Control to Major Tom: Have a nice trip in space!
221222
###Push Mode
222223

223224

224-
225-
|Short Argument| Long Argument| Description| Default| Required|
226-
|:-------------:| :-----------:|:----------------------------------------------------:| :-----------:| :-----------:|
227-
| -c|--configuration| Target configuration.| Debug|:x:|
228-
|-f|--framework|The source framework||:heavy_check_mark:|
229-
|| --pre| Command to executeprior file transfer to target||:x:|
230-
| |--post |Command to execute after file transfer to target||:x:
231-
|| --clean|Deletes all files and folders on the target before pushing the new files| True|:x:|
232-
|| --exclude| a pipe (\|) separated list of file suffixestoignore while deploying.|.ready\|.vshost.exe\|.vshost.exe.config|:x:|
233-
| -v| --verbose|Add this option to print messages to standard error and standard output streams.|True|:x:|
234-
| -h| --host| Hostname or IP Address of the target. -- Must be running an SSH server.||:heavy_check_mark:|
235-
| -p| --port| Port onwhichSSH is running.| 22|:x:|
236-
| -u|--username| The username under which the connection will be established.|pi|:x:|
237-
| -w| --password|The password for the given username.| raspberry|:x:|
225+
|Short Argument| Long Argument| Description| Default| Required|
226+
|:-------------| :--------------| :----------------------------------------------------:| :-----------:| :---------------:|
227+
| -c| --configuration|Target configuration.| Debug|:x:|
228+
| -f| --framework| The source framework.||:heavy_check_mark:|
229+
|| --pre| Command to execute prior file transfer to target.||:x:|
230+
|| --post| Command to executeafter file transfer to target.||:x:|
231+
|| --clean|Deletes all files and folders on the targetbefore pushing the new files.| True|:x:|
232+
|| --exclude|a pipe (\|) separated list of file suffixes to ignore while deploying.|.ready\|.vshost.exe\|.vshost.exe.config|:x:|
233+
|-v| --verbose| Add this option to print messagestostandard error and standard output streams.| True|:x:|
234+
|-h| --host| Hostname or IP Address of the target. -- Must be running an SSH server.||:heavy_check_mark:|
235+
|-p| --port| Port on which SSH is running.| 22|:x:|
236+
| -u| --username| The username underwhichthe connection will be established.| pi|:x:|
237+
|-w| --password| Thepassword for the givenusername.| raspberry|:x:|
238+
|-x| --execute| Adds user execute permissions to the deployed files.| False|:x:|
238239

239240

240241
##Special Thanks

‎Unosquare.Labs.SshDeploy/DeploymentManager.Monitor.cs‎

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ private static void RunSshClientCommand(SshClient sshClient, CliExecuteOptionsBa
233233
if(string.IsNullOrWhiteSpace(commandText))return;
234234

235235
" Executing SSH client command.".WriteLine(ConsoleColor.Green);
236-
varresult=sshClient.RunCommand(commandText);
236+
varresult=RunCommand(sshClient,commandText);
237237
$" SSH TX:{commandText}".WriteLine(ConsoleColor.DarkYellow);
238238
$" SSH RX: [{result.ExitStatus}]{result.Result}{result.Error}".WriteLine(ConsoleColor.DarkYellow);
239239
}
@@ -244,11 +244,27 @@ private static void RunCommand(SshClient sshClient, string type, string command)
244244

245245
$" Executing SSH{type} command.".WriteLine(ConsoleColor.Green);
246246

247-
varresult=sshClient.RunCommand(command);
247+
varresult=RunCommand(sshClient,command);
248248
$" SSH TX:{command}".WriteLine(ConsoleColor.DarkYellow);
249249
$" SSH RX: [{result.ExitStatus}]{result.Result}{result.Error}".WriteLine(ConsoleColor.DarkYellow);
250250
}
251251

252+
privatestaticvoidAllowExecute(SshClientsshClient,PushVerbOptionsverbOptions)
253+
{
254+
if(bool.TryParse(verbOptions.Execute,outvarvalue)&&value)
255+
{
256+
$" Changing mode.".WriteLine(ConsoleColor.Green);
257+
vartarget=Path.Combine(verbOptions.TargetPath,"*").Replace(WindowsDirectorySeparatorChar,LinuxDirectorySeparatorChar);
258+
varcommand=$"chmod -R u+x{target}";
259+
varresult=RunCommand(sshClient,command);
260+
$" SSH TX:{command}".WriteLine(ConsoleColor.DarkYellow);
261+
$" SSH RX: [{result.ExitStatus}]{result.Result}{result.Error}".WriteLine(ConsoleColor.DarkYellow);
262+
}
263+
}
264+
265+
privatestaticSshCommandRunCommand(SshClientsshClient,stringcommand)=>
266+
sshClient.RunCommand(command);
267+
252268
/// <summary>
253269
/// Prints the currently supplied monitor mode options.
254270
/// </summary>

‎Unosquare.Labs.SshDeploy/DeploymentManager.Push.cs‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ internal static void ExecutePushVerb(PushVerbOptions verbOptions)
1717
varpsi=newProcessStartInfo
1818
{
1919
FileName="dotnet",
20-
Arguments=" msbuild /t:Publish "+
20+
Arguments=" msbuild-restore/t:Publish "+
2121
$" /p:Configuration={verbOptions.Configuration};BuildingInsideSshDeploy=true;"+
2222
$"TargetFramework={verbOptions.Framework};RuntimeIdentifier={verbOptions.Runtime};"+
2323
"PreBuildEvent=\"\";PostBuildEvent=\"\""
@@ -55,9 +55,7 @@ internal static void ExecutePushVerb(PushVerbOptions verbOptions)
5555

5656
privatestaticvoidNormalizePushVerbOptions(PushVerbOptionsverbOptions)
5757
{
58-
vartargetPath=verbOptions.TargetPath.Trim();
59-
60-
verbOptions.TargetPath=targetPath;
58+
verbOptions.TargetPath=verbOptions.TargetPath.Trim();
6159
}
6260

6361
privatestaticvoidPrintPushOptions(PushVerbOptionsverbOptions)
@@ -97,6 +95,7 @@ private static void CreateNewDeployment(
9795
CreateTargetPath(sftpClient,verbOptions);
9896
PrepareTargetPath(sftpClient,verbOptions);
9997
UploadFilesToTarget(sftpClient,verbOptions.SourcePath,verbOptions.TargetPath,verbOptions.ExcludeFileSuffixes);
98+
AllowExecute(sshClient,verbOptions);
10099
}
101100
catch(Exceptionex)
102101
{

‎Unosquare.Labs.SshDeploy/Options/PushVerbOptions.cs‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,12 @@ public class PushVerbOptions : CliExecuteOptionsBase
1616
[ArgumentOption('f',"framework",HelpText="The target framework has to be specified in the project file.",Required=true)]
1717
publicstringFramework{get;set;}
1818

19-
[ArgumentOption('r',"runtime",HelpText="The given runtime used for creating a self-contained deployment",DefaultValue="",Required=false)]
19+
[ArgumentOption('r',"runtime",HelpText="The given runtime used for creating a self-contained deployment.",DefaultValue="",Required=false)]
2020
publicstringRuntime{get;set;}
2121

22+
[ArgumentOption('x',"execute",HelpText="Adds user execute mode permission to files transferred.",DefaultValue="",Required=false)]
23+
publicstringExecute{get;set;}
24+
2225
publicstringSourcePath=>IgnoreTargetFrameworkToOutputPath?
2326
Path.Combine(Program.CurrentDirectory,BinFolder,Configuration,Runtime,PublishFolder):
2427
Path.Combine(Program.CurrentDirectory,BinFolder,Configuration,Framework,Runtime,PublishFolder);

‎Unosquare.Labs.SshDeploy/Unosquare.Labs.SshDeploy.csproj‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,11 @@
55
<TargetFramework>netcoreapp2.2</TargetFramework>
66
<IsPackable>true</IsPackable>
77
<PackAsTool>true</PackAsTool>
8+
<PackageOutputPath>./nupkg</PackageOutputPath>
89
<AssemblyName>dotnet-sshdeploy</AssemblyName>
910
<PackageId>dotnet-sshdeploy</PackageId>
10-
<Version>0.3.2</Version>
11-
<PackageVersion>0.3.2</PackageVersion>
11+
<Version>0.3.3</Version>
12+
<PackageVersion>0.3.3</PackageVersion>
1213
<Authors>Unosquare</Authors>
1314
<Description>A command-line tool that enables quick deployments over SSH. This is program was specifically designed to streamline .NET application development for the Raspberry Pi running Raspbian.</Description>
1415

‎Unosquare.Labs.SshDeploy/Utils/CsProjNuGetMetadata.cs‎

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public class CsProjNuGetMetadata : CsProjMetadataBase
2121
[Push(ShortName="-c",LongName="--configuration")]
2222
publicstringSshDeployConfiguration=>FindElement(nameof(SshDeployConfiguration))?.Value;
2323

24-
[Run(ShortName="-c",LongName="--command")]
24+
[Run(ShortName="-c",LongName="--command")]
2525
publicstringSshDeployCommand=>FindElement(nameof(SshDeployCommand))?.Value;
2626

2727
[Push(LongName="--pre")]
@@ -38,15 +38,15 @@ public class CsProjNuGetMetadata : CsProjMetadataBase
3838

3939
[Push(LongName="--exclude")]
4040
[Monitor(LongName="--exclude")]
41-
publicstringSshDeployExclude=>FindElement(nameof(SshDeployExclude))?.Value;
42-
41+
publicstringSshDeployExclude=>FindElement(nameof(SshDeployExclude))?.Value;
42+
4343
[Push(ShortName="-h",LongName="--host")]
4444
[Monitor(ShortName="-h",LongName="--host")]
4545
[Shell(ShortName="-h",LongName="--host")]
4646
[Run(ShortName="-h",LongName="--host")]
4747
publicstringSshDeployHost=>FindElement(nameof(SshDeployHost))?.Value;
4848

49-
[Push(ShortName="-p",LongName="--port")]
49+
[Push(ShortName="-p",LongName="--port")]
5050
[Monitor(ShortName="-p",LongName="--port")]
5151
[Shell(ShortName="-p",LongName="--port")]
5252
[Run(ShortName="-p",LongName="--port")]
@@ -64,7 +64,7 @@ public class CsProjNuGetMetadata : CsProjMetadataBase
6464
[Run(ShortName="-w",LongName="--password")]
6565
publicstringSshDeployPassword=>FindElement(nameof(SshDeployPassword))?.Value;
6666

67-
[Monitor(ShortName="-s",LongName="--source")]
67+
[Monitor(ShortName="-s",LongName="--source")]
6868
publicstringSshDeploySourcePath=>FindElement(nameof(SshDeploySourcePath))?.Value;
6969

7070
[Monitor(ShortName="-t",LongName="--target")]
@@ -74,6 +74,9 @@ public class CsProjNuGetMetadata : CsProjMetadataBase
7474
[Push(ShortName="-r",LongName="--runtime")]
7575
publicstringRuntimeIdentifier=>FindElement(nameof(RuntimeIdentifier))?.Value;
7676

77+
[Push(ShortName="-x",LongName="--execute")]
78+
publicstringSshDeployExecutePermission=>FindElement(nameof(SshDeployExecutePermission))?.Value;
79+
7780
publicoverridevoidParseCsProjTags(refstring[]args)
7881
{
7982
varargsList=args.ToList();
@@ -82,18 +85,21 @@ public override void ParseCsProjTags(ref string[] args)
8285

8386
foreach(varpropertyInfoinprops)
8487
{
85-
if(propertyInfo.GetValue(this)==null)continue;
88+
varvalue=propertyInfo.GetValue(this);
89+
if(value==null)
90+
continue;
8691

8792
varattribute=(VerbAttributeBase)propertyInfo.GetCustomAttribute(type);
8893

89-
if(!(!args.Contains(attribute.LongName)&!args.Contains(attribute.ShortName)))continue;
94+
if(args.Contains(attribute.LongName)||args.Contains(attribute.ShortName))
95+
continue;
9096

91-
if(!(propertyInfo.GetValue(this)isbool))
97+
if(!(valueisbool))
9298
{
9399
argsList.Add(!string.IsNullOrWhiteSpace(attribute.ShortName)?attribute.ShortName:attribute.LongName);
94-
argsList.Add(propertyInfo.GetValue(this).ToString());
100+
argsList.Add(value.ToString());
95101
}
96-
elseif(bool.Parse(propertyInfo.GetValue(this).ToString()))
102+
elseif((bool)value)
97103
{
98104
argsList.Add(!string.IsNullOrWhiteSpace(attribute.ShortName)?attribute.ShortName:attribute.LongName);
99105
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp