I mistakenly deleted codedeploy-agent folder now I cannot run install or codedeploy erase,
Stop codedeploy-agent in preun hook if this is an erase.
Stopping codedeploy-agent:/etc/init.d/codedeploy-agent: line 45: cd: /opt/codedeploy-agent/: No such file or directory
Unable to stop the running codedeploy-agent
Canceling uninstall of the agent..
error: %preun(codedeploy-agent-1.3.2-1902.noarch) scriptlet failed, exit status 1
Error in PREUN scriptlet in rpm package codedeploy-agent-1.3.2-1902.noarch
Verifying : codedeploy-agent-1.3.2-1902.noarch 1/1
Failed:
codedeploy-agent.noarch 0:1.3.2-1902
how do I reinstall codedeploy-agent or erase it now?
I’ve tried sudo ./install auto
I, [2022-08-19T16:28:49.233152 #3540] INFO -- : Starting Ruby version check.
I, [2022-08-19T16:28:49.233406 #3540] INFO -- : Starting update check.
I, [2022-08-19T16:28:49.233511 #3540] INFO -- : Attempting to automatically detect supported package manager type for system...
I, [2022-08-19T16:28:49.241988 #3540] INFO -- : Checking AWS_REGION environment variable for region information...
I, [2022-08-19T16:28:49.242075 #3540] INFO -- : Checking EC2 metadata service for region information...
I, [2022-08-19T16:28:49.266428 #3540] INFO -- : Checking AWS_DOMAIN environment variable for domain information...
I, [2022-08-19T16:28:49.266506 #3540] INFO -- : Checking EC2 metadata service for domain information...
I, [2022-08-19T16:28:49.273211 #3540] INFO -- : Downloading version file from bucket aws-codedeploy-us-east-1 and key latest/LATEST_VERSION...
I, [2022-08-19T16:28:49.273619 #3540] INFO -- : Endpoint: https://aws-codedeploy-us-east-1.s3.us-east-1.amazonaws.com/latest/LATEST_VERSION
I, [2022-08-19T16:28:49.351061 #3540] INFO -- : Running version matches target version, skipping install
I, [2022-08-19T16:28:49.351223 #3540] INFO -- : Update check complete.
I, [2022-08-19T16:28:49.351255 #3540] INFO -- : Stopping updater.
it doesn’t install
2
Answers
I have fixed the error, because I deleted the codedeploy-agent folder in /opt, install and erase command returned errors, because /etc/init.d was making reference to the files in an attempt to install or erase. So I deleted the codedeploy-agent folder in /etc/init.d by running
"cd /etc/init.d sudo rm -r codedeploy-agent"
then "cd" to return to starting directory, then ran
sudo yum erase codedeploy-agent sudo ./install auto
Please note before running sudo ./install auto, you must have ran
"sudo yum -y update sudo yum -y install ruby sudo yum -y install wget cd /home/ec2-user wget https://aws-codedeploy-us-east-1.s3.amazonaws.com/latest/install sudo chmod +x ./install"
If you’re using Ubuntu, check the version you’re running by:
If your Ubuntu server version is >= 16.04 just enter the following commands:
then
Now check if the service is running by:
If you’re not using Ubuntu or your version is lower than the one I mentioned, check AWS official tutorial by clicking here.
If you deleted the folder because of the copies Codedeploy-agent generates each deployment process which can make your disk out of space, next time, just delete the folders inside deployment-root and set Codedeploy’s max_revision. See more.