I'm trying to update an app remotely. All devices are rooted.
Due to the nature of the apps and devices, there are no users, the devices monitor a range of sensors and send the info back to a server from key locations.
I know that
"pm install -r app.apk\n"
will install a downloaded apk.
But how would I get it to run without a user.
Once this command executes the app stops and all it's services stop aswell.
So is there a command to install + run ?
am start -n com.package.name/com.package.name.ActivityName
does not get executed and wont start the services because this code is not reached after the install command
edit:
this is the code once the apk is downloaded
dataOutputStream.WriteBytes("mount -o rw,remount -t /system\n");
dataOutputStream.Flush();
dataOutputStream.WriteBytes("chmod -R 777 "+localPath+"\n");
dataOutputStream.Flush();
dataOutputStream.WriteBytes("mount -o ro,remount -t /system\n");
dataOutputStream.Flush();
dataOutputStream.WriteBytes("pm install -r "+localPath+"\n");
dataOutputStream.Flush();
//The code below is not reached because the install kills the app
dataOutputStream.WriteBytes("am start -n com.company.remote/com.company.remote.RebootServices\n");
dataOutputStream.Flush();
Whenever you install an app through Android Studio, it installs your app and launches it immediately afterwards. By looking into the commands it executes, I have found the following line, it might help you:
adb shell am start -n "com.package.name/com.package.name.ActivityName" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER
Notice the intent filter flags: -a for "action" and -c for "category" as defined in manifest. If you have an intent filter, you can use those too.
EDIT: After reading the comment of SushiHangover, this is indeed a duplicate of this question: https://stackoverflow.com/a/4567928/3673616
According to the answer from there, instead of am start[...] you need to use adb shell am start[...]
Related
I have an application built in C# .dotnet 6 on macos.
I want the application to be able to seamlessly update itself.
It's downloads the latest pkg and my problem is how I run it.
I want to start this process using "sudo installer -pkg /tmp/mypackage.pkg -target /" but sudo ask for password on the standard input.
How can I start a process with escalated privileges where the user permissions are asked first through something like:
You can use AppleScript to create a graphical authentication prompt:
#!/bin/sh
osascript -e "do shell script \"$*\" with administrator privileges"
Other methods: Is there any graphical "sudo" for Mac OS X?
You could try the option -S of sudo for accepting the password from standard input. After use echo password and | to pass the password to the command:
echo myPassword | sudo -S installer -pkg /tmp/mypackage.pkg -target
I wrote an dotnet core app for running on linux.
published a single executable file with self-contained enabled.
dotnet publish -c Release -r linux-x64 -o ${dst_path} -v n /p:PublishTrimmed=true /p:PublishSingleFile=true
But strangely it can only run a single instance.
Because when it's running, it will remove the execute permission of the file.
$ ./Test
10/21/2020 11:50:27 AM [Info] Server started at ws://0.0.0.0:12500 (actual port 12500)
$ ls -l Test <---------Test is running, ls -l is executed in another terminal
-rw-rw-rw- 1 root root 53081298 10月 21 11:50 Test
And execute permission is added back after the runnning process exited.
$ ls -l Test <------------Test is not running.
-rwxrwxrwx 1 root root 53081298 10月 21 11:50 Test
So I can not start more than one process.
I am really confused with this problem.
Could anyone help?
Sorry for bothering, I found the root reason.
Just in case other may encount the same stupid situation, leave a message here.
My problem is caused by virutalBox.
Because I put my published assembly Test in the shared directory of my host between shared virtual machine.
After move my file Test to virtual machine's home directory, it works well.
And thank you for your help #jdoer1997
I am referencing this article on Microsoft's documentation:
https://learn.microsoft.com/en-us/aspnet/core/host-and-deploy/linux-apache?view=aspnetcore-3.1
Has anyone tried to accomplish these steps in Docker container?
I have been at this for a couple of days and I can't get the kestrel-helloapp.service file to start my application automatically when I run the container.
After running the container I am able to manually go into it and start my application with dotnet WebApplication3.dll.
I am under the impression that this should happen automatically after enabling the service file.
The only way I am able to get it to work is by adding this to the Dockerfile:
ENTRYPOINT ["dotnet" ,"WebApplication3.dll"]
But when I do this it causes the Apache server to not start up automatically.
Here is my Dockerfile:
FROM centos:7
# install sudo and dotnet sdk
RUN yum install sudo -y
RUN sudo rpm -Uvh https://packages.microsoft.com/config/centos/7/packages-microsoft-prod.rpm
RUN yum install epel-release -y
RUN yum install dnf -y
RUN sudo dnf install dotnet-sdk-3.1 -y
# copy app files over
COPY ["./publish/", "/var/www/helloapp/publish/"]
# install apache and enable it
RUN sudo yum -y install httpd mod_ssl
RUN systemctl enable httpd.service
RUN yum install initscripts -y
RUN sudo service httpd configtest
# copy and enable service file
COPY ["./kestrel-helloapp.service", "/etc/systemd/system/"]
RUN sudo systemctl enable kestrel-helloapp.service
# start apache
CMD ["-D", "FOREGROUND"]
ENTRYPOINT ["/usr/sbin/httpd"]
EXPOSE 80
docker run command:
docker run -v "C:\Users\Nick\source\repos\docker-testing\version1\helloapp.conf:/etc/httpd/conf.d/helloapp.conf" -e "ASPNETCORE_URLS=http://+:8080" -p 80:80 -p 8080:8080 -t version1
helloapp.conf file:
<VirtualHost *:*>
RequestHeader set "X-Forwarded-Proto" expr="http"
</VirtualHost>
<VirtualHost *:8080>
ProxyPreserveHost On
ProxyPass / http://127.0.0.1:5000/
ProxyPassReverse / http://127.0.0.1:5000/
ServerName www.example.com
ServerAlias *.example.com
ErrorLog /var/log/httpd/helloapp-error.log
CustomLog /var/log/httpd/helloapp-access.log common
</VirtualHost>
kesterl-helloapp.service file:
[Unit]
Description=Example .NET Web MVC App running on CentOS 7
[Service]
WorkingDirectory=/var/www/helloapp/publish
ExecStart=/usr/local/bin/dotnet /var/www/helloapp/publish/WebApplication3.dll
Restart=always
# Restart service after 10 seconds if the dotnet service crashes:
RestartSec=10
KillSignal=SIGINT
SyslogIdentifier=dotnet-example
User=apache
Environment=ASPNETCORE_ENVIRONMENT=Production
[Install]
WantedBy=multi-user.target
I know the configuration is correct because everything works fine when I start the application manually. The service file just seems to be not starting the application on boot.
Any help would be greatly appreciated. Thanks!
I've run into a similar problem (just with an ubuntu base image). The problem that you are likely experiencing is related to the fact that there is one process launched from the docker container on entry point and that is not the system daemon (init, systemd, not sure which one centos is using). As a result, your services are actually not started as you described, because they would be launched on system run level change, by that exact same system daemon.
In my opinion, not launching the system daemon is a good thing as you want to minimize services running inside of your container.
On the other hand, you might actually want multiple services inside of the container. An actual solution to your problem is to write an entry point shell script and launch the services that you want to run in parallel of your main application. In my case, I wanted a customized Jenkins image, which has an entry point of /usr/local/bin/jenkins.sh. You can find this in the Dockerfile of the base image that you are using.
I've replaced the original entry point:
ENTRYPOINT ["/bin/tini", "--", "/usr/local/bin/jenkins.sh"]
with:
ENTRYPOINT ["/bin/tini", "--", "/docker-entrypoint.sh"]
Where the content of /docker-entrypoint.sh is:
#! /bin/bash
/usr/bin/cron & # This is the additional service I wanted in the background
/usr/local/bin/jenkins.sh
I am getting the error "wslpath : The term 'wslpath' is not recognized as the name of a cmdlet" in the command" when I execute the preceding task in task.json in vscode.
Executing task: cmd /c "dotnet publish -r linux-arm -o bin\linux-arm\publish
"C:\Users\SibeeshVenu\SourceCode\raspberrypi.net.core\raspberrypi.net.core.csproj""
| bash -c "rsync -rvuz $(wslpath
'C:\Users\SibeeshVenu\SourceCode\raspberrypi.net.core')/bin/linux-arm/publish/
pi#192.168.0.80:~/raspberrypi.net.core"
I am not sure what exactly the problem is. The idea is to deploy my .net core application to my Raspberry Pi. I run WSL1 in my Windows.
The problem was because of the default terminal in VSCode. So I had to change that to Command Prompt. To do that, just press F1 in VSCode and type “Terminal: Select Default Shell”, and then select Command Prompt.
Hope this helps.
I've been searching for quite some time now, and can't seem to find an answer to this problem. Found only two questions/answers on SO and they still don't answer this question (https://stackoverflow.com/search?q=netcore+publish+mac+app).
I'm working with DotNetCore on Mac, using Visual Studio as the IDE. The app is a Console App, not an ASP.Net app, simple "Hello World" app in C#:
...
Console.Writeline("Hello World");
...
So here's the question... To run the app, I know I can use the "dotnet" command to run it. I'm trying to build/publish the app, as you normally would do in Windows by creating an .exe file, but now on Mac by creating a native binary file.
I have found zero documentation on how to do this, and deploy the application as a self contained app that can run independently without having to call the program using the "dotnet" command. Maybe I'm looking in the wrong places but haven't even found anything on Microsoft's documentation, they all point to documentation for building ASP.Net apps on .NetCore.
Any suggestions?
Found the answer by looking at the "dotnet publish" options:
dotnet publish -c Release --self-contained -r osx.10.13-x64
Where --self-contained includes all required libraries, and -r specifies the runtime target.
$ dotnet publish -c Release --self-contained -a x64
Determining projects to restore...
Restored /Users/walshca/code/temp/MutexThrow/MutexThrow.csproj (in 155 ms).
MutexThrow -> /Users/walshca/code/temp/MutexThrow/bin/Release/net6.0/osx-x64/MutexThrow.dll
MutexThrow -> /Users/walshca/code/temp/MutexThrow/bin/Release/net6.0/osx-x64/publish/
dotnet publish docs
Then I run ./bin/Release/net6.0/osx-x64/publish/MutexThrow
This didn't specify the --output cli arg, so you can see in the build output it defaulted to [project_file_folder]/bin/[configuration]/[framework]/[runtime]/publish/
(In dotnet 6.0 instead of -r runtime target, you can specify --arch x86 and it uses the default RID for your system.)
If your project props sets a different build output, can you find the executable by enumerating files by unix file permissions:
$ gci -r -file | ? UnixMode -match 'x$' | % FullName
/Users/walshca/code/temp/MutexThrow/obj/Release/net6.0/osx-x64/apphost
/Users/walshca/code/temp/MutexThrow/bin/Release/net6.0/osx-x64/MutexThrow
/Users/walshca/code/temp/MutexThrow/bin/Release/net6.0/osx-x64/publish/MutexThrow